Commit fa5608c2 authored by Administrator's avatar Administrator

Refactorizes the backend

Some backend classes have been refactorized and simplified.
parent 940c14a8
......@@ -24,8 +24,10 @@ import es.uvigo.esei.daa.rest.UsersResource;
public class DAAExampleApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
return Stream.of(PeopleResource.class, UsersResource.class)
.collect(toSet());
return Stream.of(
PeopleResource.class,
UsersResource.class
).collect(toSet());
}
@Override
......
......@@ -5,7 +5,6 @@ import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
......@@ -27,11 +26,8 @@ public abstract class DAO {
* Constructs a new instance of {@link DAO}.
*/
public DAO() {
Context initContext;
try {
initContext = new InitialContext();
this.dataSource = (DataSource) initContext.lookup(JNDI_NAME);
this.dataSource = (DataSource) new InitialContext().lookup(JNDI_NAME);
} catch (NamingException e) {
LOG.log(Level.SEVERE, "Error initializing DAO", e);
throw new RuntimeException(e);
......
......@@ -19,6 +19,7 @@ import es.uvigo.esei.daa.entities.User;
public class UsersDAO extends DAO {
private final static Logger LOG = Logger.getLogger(UsersDAO.class.getName());
// Yes, SALT should come from external configuration (for example, a property in Tomcat's context).
private final static String SALT = "daaexample-";
/**
......
......@@ -89,7 +89,7 @@ public class Person {
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
if (!(obj instanceof Person))
return false;
Person other = (Person) obj;
if (id != other.id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment