Package org.apache.struts.chain
Class ComposableRequestProcessor
java.lang.Object
org.apache.struts.action.RequestProcessor
org.apache.struts.chain.ComposableRequestProcessor
- All Implemented Interfaces:
Serializable
ComposableRequestProcessor uses the Chain Of Responsibility design pattern
(as implemented by the commons-chain package in Jakarta Commons) to support
external configuration of command chains to be used. It is configured via
the following context initialization parameters:
- [org.apache.struts.chain.CATALOG_NAME] - Name of the Catalog in which we will look up the Command to be executed for each request. If not specified, the default value is struts.
- org.apache.struts.chain.COMMAND_NAME - Name of the Command which we will execute for each request, to be looked up in the specified Catalog. If not specified, the default value is servlet-standard.
- Since:
- Struts 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringToken for ActionContext class so that it can be stored in the ControllerConfig.protected Catalog<ActionContext> TheCatalogcontaining all of the available command chains for this module.protected CatalogFactory<ActionContext> TheCatalogFactoryfrom which catalog containing the the base request-processingCommandwill be retrieved.protected Command<ActionContext> TheCommandto be executed for each request.Fields inherited from class org.apache.struts.action.RequestProcessor
actions, INCLUDE_PATH_INFO, INCLUDE_SERVLET_PATH, moduleConfig, servlet -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ActionContextcontextInstance(HttpServletRequest request, HttpServletResponse response) Provide the initializedActionContextinstance which will be used by this request.protected ActionContextcreateActionContextInstance(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) Create a new instance ofActionContextaccording to configuration.voiddestroy()Clean up in preparation for a shutdown of this application.voidinit(ActionServlet servlet, ModuleConfig moduleConfig) Initialize this request processor instance.protected voidinitCatalogFactory(ActionServlet servlet, ModuleConfig moduleConfig) Establish the CatalogFactory which will be used to look up the catalog which has the request processing command.protected voidinitializeActionContext(ActionContext context) Set common properties on the givenActionContextinstance so that commands in the chain can count on their presence.voidprocess(HttpServletRequest request, HttpServletResponse response) Process anHttpServletRequestand create the correspondingHttpServletResponse.protected HttpServletRequestprocessMultipart(HttpServletRequest request) If this is a multipart request, wrap it with a special wrapper.voidsetCatalogFactory(CatalogFactory<ActionContext> catalogFactory) Set theCatalogFactoryinstance which should be used to find the request-processing command.Methods inherited from class org.apache.struts.action.RequestProcessor
doForward, doInclude, getInternal, getServletContext, internalModuleRelativeForward, internalModuleRelativeInclude, processActionCreate, processActionForm, processActionPerform, processCachedMessages, processContent, processException, processForward, processForwardConfig, processInclude, processLocale, processMapping, processNoCache, processPath, processPopulate, processPreprocess, processRoles, processValidate
-
Field Details
-
ACTION_CONTEXT_CLASS
Token for ActionContext class so that it can be stored in the ControllerConfig.- See Also:
-
catalogFactory
TheCatalogFactoryfrom which catalog containing the the base request-processingCommandwill be retrieved. -
catalog
TheCatalogcontaining all of the available command chains for this module. -
command
TheCommandto be executed for each request.
-
-
Constructor Details
-
ComposableRequestProcessor
public ComposableRequestProcessor()
-
-
Method Details
-
destroy
public void destroy()Clean up in preparation for a shutdown of this application.- Overrides:
destroyin classRequestProcessor
-
init
Initialize this request processor instance.- Overrides:
initin classRequestProcessor- Parameters:
servlet- The ActionServlet we are associated withmoduleConfig- The ModuleConfig we are associated with.- Throws:
ServletException- If an error occurs during initialization
-
initCatalogFactory
Establish the CatalogFactory which will be used to look up the catalog which has the request processing command.The base implementation simply calls CatalogFactory.getInstance(), unless the catalogFactory property of this object has already been set, in which case it is not changed.
- Parameters:
servlet- The ActionServlet we are processingmoduleConfig- The ModuleConfig we are processing
-
process
public void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException Process anHttpServletRequestand create the correspondingHttpServletResponse.- Overrides:
processin classRequestProcessor- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creating- Throws:
IOException- if an input/output error occursServletException- if a processing exception occurs
-
contextInstance
protected ActionContext contextInstance(HttpServletRequest request, HttpServletResponse response) throws ServletException Provide the initializedActionContextinstance which will be used by this request. Internally, this simply callscreateActionContextInstancefollowed byinitializeActionContext.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creating- Returns:
- Initiliazed ActionContext
- Throws:
ServletException- if a processing exception occurs
-
createActionContextInstance
protected ActionContext createActionContextInstance(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws ServletException Create a new instance ofActionContextaccording to configuration. If no alternative was specified at initialization, a new instanceServletActionContextis returned. If an alternative was specified using theACTION_CONTEXT_CLASSproperty, then that value is treated as a classname, and an instance of that class is created. If that class implements the same constructor thatServletActionContextdoes, then that constructor will be used:ServletContext, HttpServletRequest, HttpServletResponse; otherwise, it is assumed that the class has a no-arguments constructor. If these constraints do not suit you, simply override this method in a subclass.- Parameters:
servletContext- The servlet context we are processingrequest- The servlet request we are processingresponse- The servlet response we are creating- Returns:
- New instance of ActionContext
- Throws:
ServletException- if a processing exception occurs
-
initializeActionContext
Set common properties on the givenActionContextinstance so that commands in the chain can count on their presence. Note that while this method does not require that its argument be an instance ofServletActionContext, at this time many common Struts commands will be expecting to receive anActionContextwhich is also aServletActionContext.- Parameters:
context- The ActionContext we are processing
-
processMultipart
If this is a multipart request, wrap it with a special wrapper. Otherwise, return the request unchanged.- Overrides:
processMultipartin classRequestProcessor- Parameters:
request- The HttpServletRequest we are processing- Returns:
- Original or wrapped request as appropriate
-
setCatalogFactory
Set theCatalogFactoryinstance which should be used to find the request-processing command. In the base implementation, if this value is not already set, then it will be initialized wheninitCatalogFactory(org.apache.struts.action.ActionServlet, org.apache.struts.config.ModuleConfig)is called.- Parameters:
catalogFactory- Our CatalogFactory instance
-