Class UrlPipeline

java.lang.Object
org.eclipse.jgit.http.server.glue.UrlPipeline
Direct Known Subclasses:
RegexPipeline, SuffixPipeline

abstract class UrlPipeline extends Object
Encapsulates the entire serving stack for a single URL.

Subclasses provide the implementation of match(HttpServletRequest), which is called by MetaServlet in registration order to determine the pipeline that will be used to handle a request.

The very bottom of each pipeline is a single HttpServlet that will handle producing the response for this pipeline's URL. Filters may also be registered and applied around the servlet's processing, to manage request attributes, set standard response headers, or completely override the response generation.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final javax.servlet.Filter[]
    Filters to apply around servlet; may be empty but never null.
    private final javax.servlet.http.HttpServlet
    Instance that must generate the response; never null.
  • Constructor Summary

    Constructors
    Constructor
    Description
    UrlPipeline(javax.servlet.Filter[] filters, javax.servlet.http.HttpServlet servlet)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    destroy(Set<Object> destroyed)
    Destroy all contained filters and servlets.
    private static void
    destroyFilter(javax.servlet.Filter ref, Set<Object> destroyed)
     
    private static void
    destroyServlet(javax.servlet.http.HttpServlet ref, Set<Object> destroyed)
     
    (package private) void
    init(javax.servlet.ServletContext context, Set<Object> inited)
    Initialize all contained filters and servlets.
    private static void
    initFilter(javax.servlet.Filter ref, javax.servlet.ServletContext context, Set<Object> inited)
     
    private static void
    initServlet(javax.servlet.http.HttpServlet ref, javax.servlet.ServletContext context, Set<Object> inited)
     
    (package private) abstract boolean
    match(javax.servlet.http.HttpServletRequest req)
    Determine if this pipeline handles the request's URL.
    (package private) void
    service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp)
    Execute the filters and the servlet on the request.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • filters

      private final javax.servlet.Filter[] filters
      Filters to apply around servlet; may be empty but never null.
    • servlet

      private final javax.servlet.http.HttpServlet servlet
      Instance that must generate the response; never null.
  • Constructor Details

    • UrlPipeline

      UrlPipeline(javax.servlet.Filter[] filters, javax.servlet.http.HttpServlet servlet)
  • Method Details

    • init

      void init(javax.servlet.ServletContext context, Set<Object> inited) throws javax.servlet.ServletException
      Initialize all contained filters and servlets.
      Parameters:
      context - the servlet container context our MetaServlet is running within.
      inited - (input/output) the set of filters and servlets which have already been initialized within the container context. If those same instances appear in this pipeline they are not initialized a second time. Filters and servlets that are first initialized by this pipeline will be added to this set.
      Throws:
      javax.servlet.ServletException - a filter or servlet is unable to initialize.
    • initFilter

      private static void initFilter(javax.servlet.Filter ref, javax.servlet.ServletContext context, Set<Object> inited) throws javax.servlet.ServletException
      Throws:
      javax.servlet.ServletException
    • initServlet

      private static void initServlet(javax.servlet.http.HttpServlet ref, javax.servlet.ServletContext context, Set<Object> inited) throws javax.servlet.ServletException
      Throws:
      javax.servlet.ServletException
    • destroy

      void destroy(Set<Object> destroyed)
      Destroy all contained filters and servlets.
      Parameters:
      destroyed - (input/output) the set of filters and servlets which have already been destroyed within the container context. If those same instances appear in this pipeline they are not destroyed a second time. Filters and servlets that are first destroyed by this pipeline will be added to this set.
    • destroyFilter

      private static void destroyFilter(javax.servlet.Filter ref, Set<Object> destroyed)
    • destroyServlet

      private static void destroyServlet(javax.servlet.http.HttpServlet ref, Set<Object> destroyed)
    • match

      abstract boolean match(javax.servlet.http.HttpServletRequest req)
      Determine if this pipeline handles the request's URL.

      This method should match on the request's getPathInfo() method, as MetaServlet passes the request along as-is to each pipeline's match method.

      Parameters:
      req - current HTTP request being considered by MetaServlet.
      Returns:
      true if this pipeline is configured to handle the request; false otherwise.
    • service

      void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp) throws javax.servlet.ServletException, IOException
      Execute the filters and the servlet on the request.

      Invoked by MetaServlet once match(HttpServletRequest) has determined this pipeline is the correct pipeline to handle the current request.

      Parameters:
      req - current HTTP request.
      rsp - current HTTP response.
      Throws:
      javax.servlet.ServletException - request cannot be completed.
      IOException - IO error prevents the request from being completed.