View Javadoc

1   package com.atlassian.config.lifecycle;
2   
3   import javax.servlet.ServletContextListener;
4   import javax.servlet.ServletContextEvent;
5   
6   /**
7    * Wrapper to convert a ServletContextListener into a LifecycleItem. This makes it easy to move code designed to run
8    * from web.xml into the lifecycle system.
9    */
10  public class ServletContextListenerWrapper implements LifecycleItem
11  {
12      private final ServletContextListener listener;
13  
14      public ServletContextListenerWrapper(ServletContextListener listener)
15      {
16          this.listener = listener;
17      }
18  
19      public void startup(LifecycleContext context)
20      {
21          listener.contextInitialized(new ServletContextEvent(context.getServletContext()));
22      }
23  
24      public void shutdown(LifecycleContext context)
25      {
26          listener.contextDestroyed(new ServletContextEvent(context.getServletContext()));
27      }
28  
29      public ServletContextListener getWrappedListener()
30      {
31          return listener;
32      }
33  }