01: package auction.dao.hibernate;
02:
03: import auction.dao.*;
04: import auction.model.*;
05: import org.apache.commons.logging.Log;
06: import org.apache.commons.logging.LogFactory;
07:
08: public class HibernateDAOFactory extends DAOFactory {
09:
10: private static Log log = LogFactory
11: .getLog(HibernateDAOFactory.class);
12:
13: public CategoryDAO getCategoryDAO() {
14: return (CategoryDAO) instantiateDAO(CategoryDAOHibernate.class);
15: }
16:
17: public UserDAO getUserDAO() {
18: return (UserDAO) instantiateDAO(UserDAOHibernate.class);
19: }
20:
21: public BookDAO getBookDAO() {
22: return (BookDAO) instantiateDAO(BookDAOHibernate.class);
23: }
24:
25: public LanguageDAO getLanguageDAO() {
26: return (LanguageDAO) instantiateDAO(LanguageDAOHibernate.class);
27: }
28:
29: private GenericHibernateDAO instantiateDAO(Class daoClass) {
30: try {
31: log.debug("Instantiating DAO: " + daoClass);
32: return (GenericHibernateDAO) daoClass.newInstance();
33: } catch (Exception ex) {
34: throw new RuntimeException("Can not instantiate DAO: "
35: + daoClass, ex);
36: }
37: }
38:
39: }
|