abstract class UrlPipeline
extends java.lang.Object
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.
| Modifier and Type | Class and Description |
|---|---|
private static class |
UrlPipeline.Chain |
| Modifier and Type | Field and Description |
|---|---|
private javax.servlet.Filter[] |
filters
Filters to apply around
servlet; may be empty but never null. |
private javax.servlet.http.HttpServlet |
servlet
Instance that must generate the response; never null.
|
| Constructor and Description |
|---|
UrlPipeline(javax.servlet.Filter[] filters,
javax.servlet.http.HttpServlet servlet) |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
destroy(java.util.Set<java.lang.Object> destroyed)
Destroy all contained filters and servlets.
|
private static void |
destroyFilter(javax.servlet.Filter ref,
java.util.Set<java.lang.Object> destroyed) |
private static void |
destroyServlet(javax.servlet.http.HttpServlet ref,
java.util.Set<java.lang.Object> destroyed) |
(package private) void |
init(javax.servlet.ServletContext context,
java.util.Set<java.lang.Object> inited)
Initialize all contained filters and servlets.
|
private static void |
initFilter(javax.servlet.Filter ref,
javax.servlet.ServletContext context,
java.util.Set<java.lang.Object> inited) |
private static void |
initServlet(javax.servlet.http.HttpServlet ref,
javax.servlet.ServletContext context,
java.util.Set<java.lang.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.
|
private final javax.servlet.Filter[] filters
servlet; may be empty but never null.private final javax.servlet.http.HttpServlet servlet
UrlPipeline(javax.servlet.Filter[] filters,
javax.servlet.http.HttpServlet servlet)
void init(javax.servlet.ServletContext context,
java.util.Set<java.lang.Object> inited)
throws javax.servlet.ServletException
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.javax.servlet.ServletException - a filter or servlet is unable to initialize.private static void initFilter(javax.servlet.Filter ref,
javax.servlet.ServletContext context,
java.util.Set<java.lang.Object> inited)
throws javax.servlet.ServletException
javax.servlet.ServletExceptionprivate static void initServlet(javax.servlet.http.HttpServlet ref,
javax.servlet.ServletContext context,
java.util.Set<java.lang.Object> inited)
throws javax.servlet.ServletException
javax.servlet.ServletExceptionvoid destroy(java.util.Set<java.lang.Object> destroyed)
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.private static void destroyFilter(javax.servlet.Filter ref,
java.util.Set<java.lang.Object> destroyed)
private static void destroyServlet(javax.servlet.http.HttpServlet ref,
java.util.Set<java.lang.Object> destroyed)
abstract boolean match(javax.servlet.http.HttpServletRequest req)
This method should match on the request's getPathInfo() method,
as MetaServlet passes the request along as-is to each pipeline's
match method.
req - current HTTP request being considered by MetaServlet.true if this pipeline is configured to handle the
request; false otherwise.void service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse rsp)
throws javax.servlet.ServletException,
java.io.IOException
Invoked by MetaServlet once match(HttpServletRequest)
has determined this pipeline is the correct pipeline to handle the
current request.
req - current HTTP request.rsp - current HTTP response.javax.servlet.ServletException - request cannot be completed.java.io.IOException - IO error prevents the request from being completed.