|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| CacheContextListener.java | - | 0% | 0% | 0% |
|
||||||||||||||
| 1 | /* | |
| 2 | * Copyright (c) 2002-2003 by OpenSymphony | |
| 3 | * All rights reserved. | |
| 4 | */ | |
| 5 | package com.opensymphony.oscache.web; | |
| 6 | ||
| 7 | import javax.servlet.ServletContext; | |
| 8 | import javax.servlet.ServletContextEvent; | |
| 9 | import javax.servlet.ServletContextListener; | |
| 10 | ||
| 11 | /** | |
| 12 | * Class for a clean startup and shutdown of the ServletCacheAdministrator and its application scoped cache. | |
| 13 | * @author <a href="mailto:chris@swebtec.com">Chris Miller</a> | |
| 14 | */ | |
| 15 | public class CacheContextListener implements ServletContextListener { | |
| 16 | ||
| 17 | /** | |
| 18 | * This notification occurs when the webapp is ready to process requests.<p> | |
| 19 | * We use this hook to cleanly start up the {@link ServletCacheAdministrator} | |
| 20 | * and create the application scope cache (which will consequentially | |
| 21 | * initialize any listeners configured for it that implement <code>LifecycleAware</code>.)<p> | |
| 22 | * | |
| 23 | * As of Servlet 2.4, this is guaranteed to be called before any Servlet.init() | |
| 24 | * methods. | |
| 25 | */ | |
| 26 | 0 | public void contextInitialized(ServletContextEvent servletContextEvent) { |
| 27 | 0 | ServletContext context = servletContextEvent.getServletContext(); |
| 28 | 0 | ServletCacheAdministrator.getInstance(context); |
| 29 | } | |
| 30 | ||
| 31 | /** | |
| 32 | * This notification occurs when the servlet context is about to be shut down. | |
| 33 | * We use this hook to cleanly shut down the cache. | |
| 34 | */ | |
| 35 | 0 | public void contextDestroyed(ServletContextEvent servletContextEvent) { |
| 36 | 0 | ServletContext context = servletContextEvent.getServletContext(); |
| 37 | 0 | ServletCacheAdministrator.destroyInstance(context); |
| 38 | } | |
| 39 | ||
| 40 | } |
|
||||||||||