Package com.google.inject.servlet
Class GuiceFilter
java.lang.Object
com.google.inject.servlet.GuiceFilter
- All Implemented Interfaces:
javax.servlet.Filter
Apply this filter in web.xml above all other filters (typically), to all requests where you plan
to use servlet scopes. This is also needed in order to dispatch requests to injectable filters
and servlets:
<filter> <filter-name>guiceFilter</filter-name> <filter-class>com.google.inject.servlet.GuiceFilter</filter-class> </filter> <filter-mapping> <filter-name>guiceFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>This filter must appear before every filter that makes use of Guice injection or servlet scopes functionality. Typically, you will only register this filter in web.xml and register any other filters (and servlets) using a
ServletModule
.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FilterPipeline
We allow both the static and dynamic versions of the pipeline to exist.(package private) static final ThreadLocal
<GuiceFilter.Context> private static final Logger
private static final String
(package private) static FilterPipeline
(package private) static WeakReference
<javax.servlet.ServletContext> Used to inject the servlets configured viaServletModule
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
void
doFilter
(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) private static GuiceFilter.Context
getContext
(Key<?> key) private FilterPipeline
(package private) static javax.servlet.http.HttpServletRequest
getOriginalRequest
(Key<?> key) (package private) static javax.servlet.http.HttpServletRequest
getRequest
(Key<?> key) (package private) static javax.servlet.http.HttpServletResponse
getResponse
(Key<?> key) (package private) static javax.servlet.ServletContext
void
init
(javax.servlet.FilterConfig filterConfig) (package private) static void
reset()
(package private) static void
setPipeline
(FilterPipeline pipeline)
-
Field Details
-
localContext
-
pipeline
-
injectedPipeline
We allow both the static and dynamic versions of the pipeline to exist. -
servletContext
Used to inject the servlets configured viaServletModule
-
MULTIPLE_INJECTORS_WARNING
-
LOGGER
-
-
Constructor Details
-
GuiceFilter
public GuiceFilter() -
GuiceFilter
-
-
Method Details
-
setPipeline
-
reset
static void reset() -
doFilter
public void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws IOException, javax.servlet.ServletException - Specified by:
doFilter
in interfacejavax.servlet.Filter
- Throws:
IOException
javax.servlet.ServletException
-
getOriginalRequest
-
getRequest
-
getResponse
-
getServletContext
static javax.servlet.ServletContext getServletContext() -
getContext
-
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException - Specified by:
init
in interfacejavax.servlet.Filter
- Throws:
javax.servlet.ServletException
-
destroy
public void destroy()- Specified by:
destroy
in interfacejavax.servlet.Filter
-
getFilterPipeline
-