Class GuiceServletContextListener

  • All Implemented Interfaces:
    jakarta.servlet.ServletContextListener, java.util.EventListener

    public abstract class GuiceServletContextListener
    extends java.lang.Object
    implements jakarta.servlet.ServletContextListener
    As of Guice 2.0 you can still use (your subclasses of) GuiceServletContextListener class as a logical place to create and configure your injector. This will ensure the injector is created when the web application is deployed.
    Since:
    2.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void contextDestroyed​(jakarta.servlet.ServletContextEvent servletContextEvent)  
      void contextInitialized​(jakarta.servlet.ServletContextEvent servletContextEvent)  
      protected abstract com.google.inject.Injector getInjector()
      Override this method to create (or otherwise obtain a reference to) your injector.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GuiceServletContextListener

        public GuiceServletContextListener()
    • Method Detail

      • contextInitialized

        public void contextInitialized​(jakarta.servlet.ServletContextEvent servletContextEvent)
        Specified by:
        contextInitialized in interface jakarta.servlet.ServletContextListener
      • contextDestroyed

        public void contextDestroyed​(jakarta.servlet.ServletContextEvent servletContextEvent)
        Specified by:
        contextDestroyed in interface jakarta.servlet.ServletContextListener
      • getInjector

        protected abstract com.google.inject.Injector getInjector()
        Override this method to create (or otherwise obtain a reference to) your injector.