ehcache

net.sf.ehcache.constructs.web
Class ShutdownListener

java.lang.Object
  extended by net.sf.ehcache.constructs.web.ShutdownListener
All Implemented Interfaces:
java.util.EventListener, javax.servlet.ServletContextListener

public class ShutdownListener
extends java.lang.Object
implements javax.servlet.ServletContextListener

A ServletContextListener that shutsdown CacheManager. Use this when you want to shutdown ehcache automatically when the web application is shutdown. If the web application is in a VM which is being shutdown, the ehcache shutdown hooks will do the work and this class is not required.

To receive notification events, this class must be configured in the deployment descriptor for the web application. To do so, add the following to web.xml in your web application:

 <listener>
      net.sf.ehcache.constructs.web.ShutdownListener
 </listener>
 

Version:
$Id: ShutdownListener.java 512 2007-07-10 09:18:45Z gregluck $
Author:
Daniel Wiell, Greg Luck

Constructor Summary
ShutdownListener()
           
 
Method Summary
 void contextDestroyed(javax.servlet.ServletContextEvent servletContextEvent)
          Notification that the servlet context is about to be shut down.
 void contextInitialized(javax.servlet.ServletContextEvent servletContextEvent)
          Notification that the web application is ready to process requests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShutdownListener

public ShutdownListener()
Method Detail

contextInitialized

public void contextInitialized(javax.servlet.ServletContextEvent servletContextEvent)
Notification that the web application is ready to process requests.

Specified by:
contextInitialized in interface javax.servlet.ServletContextListener
Parameters:
servletContextEvent -

contextDestroyed

public void contextDestroyed(javax.servlet.ServletContextEvent servletContextEvent)
Notification that the servlet context is about to be shut down.

Shuts down all cache managers known to CacheManager.ALL_CACHE_MANAGERS

Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener
Parameters:
servletContextEvent -

ehcache

true