Package com.google.inject.servlet
Class GuiceServletContextListener
java.lang.Object
com.google.inject.servlet.GuiceServletContextListener
- All Implemented Interfaces:
jakarta.servlet.ServletContextListener,EventListener
public abstract class GuiceServletContextListener
extends 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
- Author:
- Kevin Bourrillion (kevinb@google.com)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontextDestroyed(jakarta.servlet.ServletContextEvent servletContextEvent) voidcontextInitialized(jakarta.servlet.ServletContextEvent servletContextEvent) protected abstract com.google.inject.InjectorOverride this method to create (or otherwise obtain a reference to) your injector.
-
Constructor Details
-
GuiceServletContextListener
public GuiceServletContextListener()
-
-
Method Details
-
contextInitialized
public void contextInitialized(jakarta.servlet.ServletContextEvent servletContextEvent) - Specified by:
contextInitializedin interfacejakarta.servlet.ServletContextListener
-
contextDestroyed
public void contextDestroyed(jakarta.servlet.ServletContextEvent servletContextEvent) - Specified by:
contextDestroyedin interfacejakarta.servlet.ServletContextListener
-
getInjector
protected abstract com.google.inject.Injector getInjector()Override this method to create (or otherwise obtain a reference to) your injector.
-