Class ChainProcessor
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
Custom subclass of ChainServlet
that also dispatches incoming
requests to a configurable Command
loaded from the specified
Catalog
.
In addition to the servlet init parameters supported by
ChainServlet
, this class supports the following additional
parameters:
- org.apache.commons.chain.CATALOG - Name of the catalog from which to acquire commands to be executed. If not specified, the default catalog for this application will be used.
- org.apache.commons.chain.COMMAND - Name of the
Command
(looked up in our configuredCatalog
used to process all incoming servlet requests. If not specified, defaults tocommand
.
Also, the org.apache.commons.chain.CONFIG_ATTR
init parameter is also used to identify the
Context
attribute under
which our configured Catalog
will be made available to
Command
s processing our requests, in addition to its definition
of the ServletContext
attribute key under which the
Catalog
is available.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The name of the context attribute under which ourCatalog
is stored.private String
The name of theCatalog
to retrieve from theCatalogFactory
for this application, ornull
to select the defaultCatalog
.static final String
The name of the servlet init parameter containing the name of theCatalog
to use for processing incoming requests.static final String
private String
The name of theCommand
to be executed for each incoming request.static final String
private static final String
The default command name.Fields inherited from class org.apache.commons.chain.web.ChainServlet
CONFIG_ATTR, CONFIG_CLASS_RESOURCE, CONFIG_WEB_RESOURCE, RULE_SET
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Clean up as this application is shut down.void
init()
Cache the name of the command we should execute for each request.void
service
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Configure aServletWebContext
for the current request, and pass it to theexecute()
method of the specifiedCommand
, loaded from our configuredCatalog
.Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
CATALOG
The name of the servlet init parameter containing the name of the
Catalog
to use for processing incoming requests.- See Also:
-
CATALOG_DEFAULT
- See Also:
-
COMMAND
The name of the servlet init parameter containing the name of the
Command
(loaded from our configuredCatalog
to use for processing each incoming request.- See Also:
-
COMMAND_DEFAULT
The default command name.
- See Also:
-
attribute
The name of the context attribute under which our
Catalog
is stored. This value is also used as the name of the context attribute under which the catalog is exposed to commands. If not specified, we will look up commands in the appropriateCatalog
retrieved from ourCatalogFactory
. -
catalog
The name of the
Catalog
to retrieve from theCatalogFactory
for this application, ornull
to select the defaultCatalog
. -
command
The name of the
Command
to be executed for each incoming request.
-
-
Constructor Details
-
ChainProcessor
public ChainProcessor()
-
-
Method Details
-
destroy
public void destroy()Clean up as this application is shut down.
- Specified by:
destroy
in interfacejavax.servlet.Servlet
- Overrides:
destroy
in classChainServlet
-
init
public void init() throws javax.servlet.ServletExceptionCache the name of the command we should execute for each request.
- Overrides:
init
in classChainServlet
- Throws:
javax.servlet.ServletException
- if an initialization error occurs
-
service
public void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException Configure a
ServletWebContext
for the current request, and pass it to theexecute()
method of the specifiedCommand
, loaded from our configuredCatalog
.- Overrides:
service
in classChainServlet
- Parameters:
request
- The request we are processingresponse
- The response we are creating- Throws:
IOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet exception occurs
-