Class UrlPipeline
- Direct Known Subclasses:
RegexPipeline,SuffixPipeline
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 -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionUrlPipeline(javax.servlet.Filter[] filters, javax.servlet.http.HttpServlet servlet) -
Method Summary
Modifier and TypeMethodDescription(package private) voidDestroy all contained filters and servlets.private static voiddestroyFilter(javax.servlet.Filter ref, Set<Object> destroyed) private static voiddestroyServlet(javax.servlet.http.HttpServlet ref, Set<Object> destroyed) (package private) voidInitialize all contained filters and servlets.private static voidinitFilter(javax.servlet.Filter ref, javax.servlet.ServletContext context, Set<Object> inited) private static voidinitServlet(javax.servlet.http.HttpServlet ref, javax.servlet.ServletContext context, Set<Object> inited) (package private) abstract booleanmatch(javax.servlet.http.HttpServletRequest req) Determine if this pipeline handles the request's URL.(package private) voidservice(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp) Execute the filters and the servlet on the request.
-
Field Details
-
filters
private final javax.servlet.Filter[] filtersFilters to apply aroundservlet; may be empty but never null. -
servlet
private final javax.servlet.http.HttpServlet servletInstance 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 ourMetaServletis 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
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
-
destroyServlet
-
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, asMetaServletpasses the request along as-is to each pipeline's match method.- Parameters:
req- current HTTP request being considered byMetaServlet.- Returns:
trueif this pipeline is configured to handle the request;falseotherwise.
-
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
MetaServletoncematch(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.
-