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 FilterPipelineWe allow both the static and dynamic versions of the pipeline to exist.(package private) static final ThreadLocal<GuiceFilter.Context>private static final Loggerprivate 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 TypeMethodDescriptionvoiddestroy()voiddoFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) private static GuiceFilter.ContextgetContext(Key<?> key) private FilterPipeline(package private) static javax.servlet.http.HttpServletRequestgetOriginalRequest(Key<?> key) (package private) static javax.servlet.http.HttpServletRequestgetRequest(Key<?> key) (package private) static javax.servlet.http.HttpServletResponsegetResponse(Key<?> key) (package private) static javax.servlet.ServletContextvoidinit(javax.servlet.FilterConfig filterConfig) (package private) static voidreset()(package private) static voidsetPipeline(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:
doFilterin interfacejavax.servlet.Filter- Throws:
IOExceptionjavax.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:
initin interfacejavax.servlet.Filter- Throws:
javax.servlet.ServletException
-
destroy
public void destroy()- Specified by:
destroyin interfacejavax.servlet.Filter
-
getFilterPipeline
-