Class ManagedFilterPipeline

  • All Implemented Interfaces:
    FilterPipeline

    class ManagedFilterPipeline
    extends java.lang.Object
    implements FilterPipeline
    Central routing/dispatch class handles lifecycle of managed filters, and delegates to the servlet pipeline.
    • Method Detail

      • collectFilterDefinitions

        private FilterDefinition[] collectFilterDefinitions​(Injector injector)
        Introspects the injector and collects all instances of bound List<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:
        initPipeline in interface FilterPipeline
        Throws:
        javax.servlet.ServletException
      • dispatch

        public void dispatch​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain proceedingFilterChain)
                      throws java.io.IOException,
                             javax.servlet.ServletException
        Specified by:
        dispatch in interface FilterPipeline
        Throws:
        java.io.IOException
        javax.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).