Class ServletLifecycleListener

  • All Implemented Interfaces:
    EventListener, javax.servlet.ServletContextListener

    public class ServletLifecycleListener
    extends Object
    implements javax.servlet.ServletContextListener
    Listener for starting and stopping services when the servlet starts up and shuts down. In order to use this listener, reference it in your web.xml file:
         
          <xml>
              <web-app>
                  <listener>
                     <listener-class>uk.gov.gchq.gaffer.rest.ServletLifecycleListener</listener-class>
                  </listener>
              </web-app>
          </xml>
         
     
    • Constructor Detail

      • ServletLifecycleListener

        public ServletLifecycleListener()
    • Method Detail

      • contextInitialized

        public void contextInitialized​(javax.servlet.ServletContextEvent servletContextEvent)
        Code executed when the servlet starts. The CacheServiceLoader is not initialised here as it requires the store properties file. Therefore it is started when the store is initialised instead.
        Specified by:
        contextInitialized in interface javax.servlet.ServletContextListener
        Parameters:
        servletContextEvent - the context event
      • contextDestroyed

        public void contextDestroyed​(javax.servlet.ServletContextEvent servletContextEvent)
        Code executed when the servlet is being shut down. The cache service loader is shut down here to avoid ClassNotFoundExceptions which result from a Servlet's ClassLoader being shut down before the ShutdownHooks run. All Gaffer services should use this class rather than Shutdown hooks if they want to run Gaffer in a servlet such as JBOSS or Tomcat.
        Specified by:
        contextDestroyed in interface javax.servlet.ServletContextListener
        Parameters:
        servletContextEvent - the context event