org.hibernate.tutorial.web
Class SessionFactoryInitializer

java.lang.Object
  extended by org.hibernate.tutorial.web.SessionFactoryInitializer
All Implemented Interfaces:
EventListener, ServletContextListener

public class SessionFactoryInitializer
extends Object
implements ServletContextListener

Demonstrates good practice of making sure the SessionFactory is initialized on application startup, rather than on first request. Here we register as a listener to the servlet context lifecycle for building/closing of the SessionFactory.

Author:
Steve Ebersole

Constructor Summary
SessionFactoryInitializer()
           
 
Method Summary
 void contextDestroyed(ServletContextEvent event)
           
 void contextInitialized(ServletContextEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionFactoryInitializer

public SessionFactoryInitializer()
Method Detail

contextInitialized

public void contextInitialized(ServletContextEvent event)
Specified by:
contextInitialized in interface ServletContextListener

contextDestroyed

public void contextDestroyed(ServletContextEvent event)
Specified by:
contextDestroyed in interface ServletContextListener


Copyright © 2009 Hibernate.org. All Rights Reserved.