org.hibernate.tutorial.web
Class SessionFactoryInitializer

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

public class SessionFactoryInitializer
extends Object
implements javax.servlet.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(javax.servlet.ServletContextEvent event)
           
 void contextInitialized(javax.servlet.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(javax.servlet.ServletContextEvent event)
Specified by:
contextInitialized in interface javax.servlet.ServletContextListener

contextDestroyed

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


Copyright © null-null Red Hat Middleware, LLC. All Rights Reserved