Skip to content

Instantly share code, notes, and snippets.

@wulfgarpro
Created November 15, 2011 10:54
Show Gist options
  • Save wulfgarpro/1366772 to your computer and use it in GitHub Desktop.
Save wulfgarpro/1366772 to your computer and use it in GitHub Desktop.
DAO pattern with Factory Method
public interface GenericDao<T, K> {
public K insert(T object);
}
public class GenericDaoMongoDBImpl<T, K> implements GenericDao<T, K> {
public K insert(T object) {
return null;
}
}
public interface ObjectDao extends GenericDao<Object, ObjectId> {
}
public class ObjectDaoMongoDBImpl extends GenericDaoMongoDBImpl<Object, ObjectId> implements ObjectDao {
}
public class DaoFactory {
public static GenericDao<Object, ObjectId> createDao() {
return new ObjectDaoMongoDBImpl();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment