View Javadoc
1 2 package inklings.jgatms.command; 3 4 import java.util.List; 5 6 import net.sf.hibernate.Session; 7 import net.sf.hibernate.SessionFactory; 8 import net.sf.hibernate.cfg.Configuration; 9 10 import org.apache.commons.chain.Context; 11 12 import org.apache.commons.logging.Log; 13 import org.apache.commons.logging.LogFactory; 14 15 import inklings.jgatms.ContextKeys; 16 17 /*** 18 * Initializes the Hibernate Session Factory. 19 * 20 * @author Greg Reddin 21 */ 22 public class BuildSessionFactory extends BaseCommand { 23 24 private static Log log = LogFactory.getLog(BuildSessionFactory.class); 25 26 public boolean execute(Context context) throws Exception { 27 28 SessionFactory sf = (SessionFactory) 29 context.get(getHibernateSessionFactoryKey()); 30 31 if (sf == null) { 32 try { 33 sf = new Configuration().configure().buildSessionFactory(); 34 } catch (Exception e) { 35 log.fatal("Unable to initialize database connection", e); 36 context.put(ContextKeys.DISPATCH_KEY, 37 ContextKeys.FATAL_DISPATCH); 38 return true; 39 } 40 } 41 42 context.put(getHibernateSessionFactoryKey(), sf); 43 return false; 44 } 45 46 }

This page was automatically generated by Maven