Package com.google.inject.servlet
Class ManagedFilterPipeline
java.lang.Object
com.google.inject.servlet.ManagedFilterPipeline
- All Implemented Interfaces:
FilterPipeline
Central routing/dispatch class handles lifecycle of managed filters, and delegates to the servlet
pipeline.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final TypeLiteral<FilterDefinition>private final FilterDefinition[]private booleanprivate final Injectorprivate final Provider<javax.servlet.ServletContext>private final ManagedServletPipeline -
Constructor Summary
ConstructorsConstructorDescriptionManagedFilterPipeline(Injector injector, ManagedServletPipeline servletPipeline, Provider<javax.servlet.ServletContext> servletContext) -
Method Summary
Modifier and TypeMethodDescriptionprivate FilterDefinition[]collectFilterDefinitions(Injector injector) Introspects the injector and collects all instances of boundList<FilterDefinition>into a master list.voidvoiddispatch(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain proceedingFilterChain) voidinitPipeline(javax.servlet.ServletContext servletContext) private javax.servlet.ServletRequestwithDispatcher(javax.servlet.ServletRequest servletRequest, ManagedServletPipeline servletPipeline) Used to create an proxy that dispatches either to the guice-servlet pipeline or the regular pipeline based on uri-path match.
-
Field Details
-
filterDefinitions
-
servletPipeline
-
servletContext
-
injector
-
initialized
private volatile boolean initialized -
FILTER_DEFS
-
-
Constructor Details
-
ManagedFilterPipeline
@Inject public ManagedFilterPipeline(Injector injector, ManagedServletPipeline servletPipeline, Provider<javax.servlet.ServletContext> servletContext)
-
-
Method Details
-
collectFilterDefinitions
Introspects the injector and collects all instances of boundList<FilterDefinition>into a master list.We have a guarantee that
Injector.getBindings()returns a map that preserves insertion order in entry-set iterators. -
initPipeline
public void initPipeline(javax.servlet.ServletContext servletContext) throws javax.servlet.ServletException - Specified by:
initPipelinein interfaceFilterPipeline- Throws:
javax.servlet.ServletException
-
dispatch
public void dispatch(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain proceedingFilterChain) throws IOException, javax.servlet.ServletException - Specified by:
dispatchin interfaceFilterPipeline- Throws:
IOExceptionjavax.servlet.ServletException
-
withDispatcher
private javax.servlet.ServletRequest withDispatcher(javax.servlet.ServletRequest servletRequest, ManagedServletPipeline servletPipeline) Used to create an proxy that dispatches either to the guice-servlet pipeline or the regular pipeline based on uri-path match. This proxy also provides minimal forwarding support.We cannot forward from a web.xml Servlet/JSP to a guice-servlet (because the filter pipeline is not called again). However, we can wrap requests with our own dispatcher to forward the *other* way. web.xml Servlets/JSPs can forward to themselves as per normal.
This is not a problem cuz we intend for people to migrate from web.xml to guice-servlet, incrementally, but not the other way around (which, we should actively discourage).
-
destroyPipeline
public void destroyPipeline()- Specified by:
destroyPipelinein interfaceFilterPipeline
-