Package com.google.inject.servlet
Class GuiceServletContextListener
java.lang.Object
com.google.inject.servlet.GuiceServletContextListener
- All Implemented Interfaces:
EventListener
,javax.servlet.ServletContextListener
public abstract class GuiceServletContextListener
extends Object
implements javax.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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
contextDestroyed
(javax.servlet.ServletContextEvent servletContextEvent) Receives notification that the ServletContext is about to be shut down.void
contextInitialized
(javax.servlet.ServletContextEvent servletContextEvent) Receives notification that the web application initialization process is starting.protected abstract Injector
Override this method to create (or otherwise obtain a reference to) your injector.
-
Constructor Details
-
GuiceServletContextListener
public GuiceServletContextListener()
-
-
Method Details
-
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent servletContextEvent) Description copied from interface:javax.servlet.ServletContextListener
Receives notification that the web application initialization process is starting.All ServletContextListeners are notified of context initialization before any filters or servlets in the web application are initialized.
- Specified by:
contextInitialized
in interfacejavax.servlet.ServletContextListener
- Parameters:
servletContextEvent
- the ServletContextEvent containing the ServletContext that is being initialized
-
contextDestroyed
public void contextDestroyed(javax.servlet.ServletContextEvent servletContextEvent) Description copied from interface:javax.servlet.ServletContextListener
Receives notification that the ServletContext is about to be shut down.All servlets and filters will have been destroyed before any ServletContextListeners are notified of context destruction.
- Specified by:
contextDestroyed
in interfacejavax.servlet.ServletContextListener
- Parameters:
servletContextEvent
- the ServletContextEvent containing the ServletContext that is being destroyed
-
getInjector
Override this method to create (or otherwise obtain a reference to) your injector.
-