Class ChainProcessor
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.apache.commons.chain.web.ChainServlet
-
- org.apache.commons.chain.web.servlet.ChainProcessor
-
- All Implemented Interfaces:
java.io.Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
public class ChainProcessor extends ChainServlet
Custom subclass of
ChainServletthat also dispatches incoming requests to a configurableCommandloaded from the specifiedCatalog.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 configuredCatalogused to process all incoming servlet requests. If not specified, defaults tocommand.
Also, the
org.apache.commons.chain.CONFIG_ATTRinit parameter is also used to identify theContextattribute under which our configuredCatalogwill be made available toCommands processing our requests, in addition to its definition of theServletContextattribute key under which theCatalogis available.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringattributeThe name of the context attribute under which ourCatalogis stored.private java.lang.StringcatalogThe name of theCatalogto retrieve from theCatalogFactoryfor this application, ornullto select the defaultCatalog.static java.lang.StringCATALOGThe name of the servlet init parameter containing the name of theCatalogto use for processing incoming requests.static java.lang.StringCATALOG_DEFAULTprivate java.lang.StringcommandThe name of theCommandto be executed for each incoming request.static java.lang.StringCOMMANDprivate static java.lang.StringCOMMAND_DEFAULTThe 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 Constructor Description ChainProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Clean up as this application is shut down.voidinit()Cache the name of the command we should execute for each request.voidservice(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Configure aServletWebContextfor 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
-
-
-
-
Field Detail
-
CATALOG
public static final java.lang.String CATALOG
The name of the servlet init parameter containing the name of the
Catalogto use for processing incoming requests.- See Also:
- Constant Field Values
-
CATALOG_DEFAULT
public static final java.lang.String CATALOG_DEFAULT
- See Also:
- Constant Field Values
-
COMMAND
public static final java.lang.String COMMAND
The name of the servlet init parameter containing the name of the
Command(loaded from our configuredCatalogto use for processing each incoming request.- See Also:
- Constant Field Values
-
COMMAND_DEFAULT
private static final java.lang.String COMMAND_DEFAULT
The default command name.
- See Also:
- Constant Field Values
-
attribute
private java.lang.String attribute
The name of the context attribute under which our
Catalogis 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 appropriateCatalogretrieved from ourCatalogFactory.
-
catalog
private java.lang.String catalog
The name of the
Catalogto retrieve from theCatalogFactoryfor this application, ornullto select the defaultCatalog.
-
command
private java.lang.String command
The name of the
Commandto be executed for each incoming request.
-
-
Method Detail
-
destroy
public void destroy()
Clean up as this application is shut down.
- Specified by:
destroyin interfacejavax.servlet.Servlet- Overrides:
destroyin classChainServlet
-
init
public void init() throws javax.servlet.ServletExceptionCache the name of the command we should execute for each request.
- Overrides:
initin 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 java.io.IOException, javax.servlet.ServletExceptionConfigure a
ServletWebContextfor the current request, and pass it to theexecute()method of the specifiedCommand, loaded from our configuredCatalog.- Overrides:
servicein classChainServlet- Parameters:
request- The request we are processingresponse- The response we are creating- Throws:
java.io.IOException- if an input/output error occursjavax.servlet.ServletException- if a servlet exception occurs
-
-