|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.struts.action.RequestProcessor
public class RequestProcessor
RequestProcessor contains the processing logic that the
ActionServlet
performs as it receives each servlet request from the
container. You can customize the request processing behavior by subclassing
this class and overriding the method(s) whose behavior you are interested
in changing.
Field Summary | |
---|---|
protected java.util.HashMap |
actions
The set of Action instances that have been created and
initialized, keyed by the fully qualified Java class name of the
Action class. |
static java.lang.String |
INCLUDE_PATH_INFO
The request attribute under which the path information is stored for processing during a RequestDispatcher.include call. |
static java.lang.String |
INCLUDE_SERVLET_PATH
The request attribute under which the servlet path information is stored for processing during a RequestDispatcher.include
call. |
protected static org.apache.commons.logging.Log |
log
Commons Logging instance. |
protected ModuleConfig |
moduleConfig
The ModuleConfiguration with which we are
associated. |
protected ActionServlet |
servlet
The servlet with which we are associated. |
Constructor Summary | |
---|---|
RequestProcessor()
|
Method Summary | |
---|---|
void |
destroy()
Clean up in preparation for a shutdown of this application. |
protected void |
doForward(java.lang.String uri,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Do a forward to specified URI using a RequestDispatcher . |
protected void |
doInclude(java.lang.String uri,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Do an include of specified URI using a RequestDispatcher . |
protected MessageResources |
getInternal()
Return the MessageResources instance containing our
internal message strings. |
protected javax.servlet.ServletContext |
getServletContext()
Return the ServletContext for the web application in
which we are running. |
void |
init(ActionServlet servlet,
ModuleConfig moduleConfig)
Initialize this request processor instance. |
protected void |
internalModuleRelativeForward(java.lang.String uri,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Do a module relative forward to specified URI using request dispatcher. |
protected void |
internalModuleRelativeInclude(java.lang.String uri,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Do a module relative include to specified URI using request dispatcher. |
void |
process(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Process an HttpServletRequest and create the
corresponding HttpServletResponse or dispatch to another
resource. |
protected Action |
processActionCreate(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ActionMapping mapping)
Return an Action instance that will be used to process
the current request, creating a new one if necessary. |
protected ActionForm |
processActionForm(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ActionMapping mapping)
Retrieve and return the ActionForm associated with this
mapping, creating and retaining one if necessary. |
protected ActionForward |
processActionPerform(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Action action,
ActionForm form,
ActionMapping mapping)
Ask the specified Action instance to handle this
request. |
protected void |
processCachedMessages(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Removes any ActionMessages object stored in the session
under Globals.MESSAGE_KEY and Globals.ERROR_KEY
if the messages' isAccessed method returns true. |
protected void |
processContent(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Set the default content type (with optional character encoding) for all responses if requested. |
protected ActionForward |
processException(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Exception exception,
ActionForm form,
ActionMapping mapping)
Ask our exception handler to handle the exception. |
protected boolean |
processForward(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ActionMapping mapping)
Process a forward requested by this mapping (if any). |
protected void |
processForwardConfig(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ForwardConfig forward)
Forward or redirect to the specified destination, by the specified mechanism. |
protected boolean |
processInclude(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ActionMapping mapping)
Process an include requested by this mapping (if any). |
protected void |
processLocale(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Automatically select a Locale for the current user, if
requested. |
protected ActionMapping |
processMapping(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String path)
Select the mapping used to process the selection path for this request. |
protected javax.servlet.http.HttpServletRequest |
processMultipart(javax.servlet.http.HttpServletRequest request)
If this is a multipart request, wrap it with a special wrapper. |
protected void |
processNoCache(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Set the no-cache headers for all responses, if requested. |
protected java.lang.String |
processPath(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Identify and return the path component (from the request URI) that we will use to select an ActionMapping with which to
dispatch. |
protected void |
processPopulate(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ActionForm form,
ActionMapping mapping)
Populate the properties of the specified ActionForm
instance from the request parameters included with this request. |
protected boolean |
processPreprocess(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
General-purpose preprocessing hook that can be overridden as required by subclasses. |
protected boolean |
processRoles(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ActionMapping mapping)
If this action is protected by security roles, make sure that the current user possesses at least one of them. |
protected boolean |
processValidate(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ActionForm form,
ActionMapping mapping)
If this request was not cancelled, and the request's ActionMapping has not disabled validation, call the
validate method of the specified ActionForm , and
forward to the input path if there were any errors. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String INCLUDE_PATH_INFO
The request attribute under which the path information is stored for
processing during a RequestDispatcher.include
call.
public static final java.lang.String INCLUDE_SERVLET_PATH
The request attribute under which the servlet path information is
stored for processing during a RequestDispatcher.include
call.
protected static org.apache.commons.logging.Log log
Commons Logging instance.
protected java.util.HashMap actions
The set of Action
instances that have been created and
initialized, keyed by the fully qualified Java class name of the
Action
class.
protected ModuleConfig moduleConfig
The ModuleConfiguration
with which we are
associated.
protected ActionServlet servlet
The servlet with which we are associated.
Constructor Detail |
---|
public RequestProcessor()
Method Detail |
---|
public void destroy()
Clean up in preparation for a shutdown of this application.
public void init(ActionServlet servlet, ModuleConfig moduleConfig) throws javax.servlet.ServletException
Initialize this request processor instance.
servlet
- The ActionServlet we are associated withmoduleConfig
- The ModuleConfig we are associated with.
javax.servlet.ServletException
- If an error occor during initializationpublic void process(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Process an HttpServletRequest
and create the
corresponding HttpServletResponse
or dispatch to another
resource.
request
- The servlet request we are processingresponse
- The servlet response we are creating
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a processing exception occursprotected Action processActionCreate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionMapping mapping) throws java.io.IOException
Return an Action
instance that will be used to process
the current request, creating a new one if necessary.
request
- The servlet request we are processingresponse
- The servlet response we are creatingmapping
- The mapping we are using
Action
instance that will be used to process
the current request.
java.io.IOException
- if an input/output error occursprotected ActionForm processActionForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionMapping mapping)
Retrieve and return the ActionForm
associated with this
mapping, creating and retaining one if necessary. If there is no
ActionForm
associated with this mapping, return
null
.
request
- The servlet request we are processingresponse
- The servlet response we are creatingmapping
- The mapping we are using
ActionForm
associated with this mapping.protected void processForwardConfig(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ForwardConfig forward) throws java.io.IOException, javax.servlet.ServletException
Forward or redirect to the specified destination, by the specified
mechanism. This method uses a ForwardConfig
object
instead an ActionForward
.
request
- The servlet request we are processingresponse
- The servlet response we are creatingforward
- The ForwardConfig controlling where we go next
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occursprotected ActionForward processActionPerform(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException
Ask the specified Action
instance to handle this
request. Return the ActionForward
instance (if any)
returned by the called Action
for further processing.
request
- The servlet request we are processingresponse
- The servlet response we are creatingaction
- The Action instance to be usedform
- The ActionForm instance to pass to this Actionmapping
- The ActionMapping instance to pass to this Action
ActionForward
instance (if any) returned by
the called Action
.
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occursprotected void processCachedMessages(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Removes any ActionMessages
object stored in the session
under Globals.MESSAGE_KEY
and Globals.ERROR_KEY
if the messages' isAccessed
method returns true. This
allows messages to be stored in the session, display one time, and be
released here.
request
- The servlet request we are processing.response
- The servlet response we are creating.protected void processContent(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Set the default content type (with optional character encoding) for
all responses if requested. NOTE - This header will
be overridden automatically if a RequestDispatcher.forward
call is ultimately invoked.
request
- The servlet request we are processingresponse
- The servlet response we are creatingprotected ActionForward processException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Exception exception, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException
Ask our exception handler to handle the exception. Return the
ActionForward
instance (if any) returned by the called
ExceptionHandler
.
request
- The servlet request we are processingresponse
- The servlet response we are processingexception
- The exception being handledform
- The ActionForm we are processingmapping
- The ActionMapping we are using
ActionForward
instance (if any) returned by
the called ExceptionHandler
.
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occursprotected boolean processForward(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException
Process a forward requested by this mapping (if any). Return
true
if standard processing should continue, or
false
if we have already handled this request.
request
- The servlet request we are processingresponse
- The servlet response we are creatingmapping
- The ActionMapping we are using
true
to continue normal processing;
false
if a response has been created.
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occursprotected boolean processInclude(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException
Process an include requested by this mapping (if any). Return
true
if standard processing should continue, or
false
if we have already handled this request.
request
- The servlet request we are processingresponse
- The servlet response we are creatingmapping
- The ActionMapping we are using
true
to continue normal processing;
false
if a response has been created.
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if thrown by invoked methodsprotected void processLocale(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Automatically select a Locale
for the current user, if
requested. NOTE - configuring Locale selection will
trigger the creation of a new HttpSession
if
necessary.
request
- The servlet request we are processingresponse
- The servlet response we are creatingprotected ActionMapping processMapping(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String path) throws java.io.IOException
Select the mapping used to process the selection path for this
request. If no mapping can be identified, create an error response and
return null
.
request
- The servlet request we are processingresponse
- The servlet response we are creatingpath
- The portion of the request URI for selecting a mapping
java.io.IOException
- if an input/output error occursprotected javax.servlet.http.HttpServletRequest processMultipart(javax.servlet.http.HttpServletRequest request)
If this is a multipart request, wrap it with a special wrapper. Otherwise, return the request unchanged.
request
- The HttpServletRequest we are processing
protected void processNoCache(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Set the no-cache headers for all responses, if requested.
NOTE - This header will be overridden automatically if
a RequestDispatcher.forward
call is ultimately
invoked.
request
- The servlet request we are processingresponse
- The servlet response we are creatingprotected java.lang.String processPath(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
Identify and return the path component (from the request URI) that
we will use to select an ActionMapping
with which to
dispatch. If no such path can be identified, create an error response
and return null
.
request
- The servlet request we are processingresponse
- The servlet response we are creating
java.io.IOException
- if an input/output error occursprotected void processPopulate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionForm form, ActionMapping mapping) throws javax.servlet.ServletException
Populate the properties of the specified ActionForm
instance from the request parameters included with this request. In
addition, request attribute Globals.CANCEL_KEY
will be set
if the request was submitted with a button created by
CancelTag
.
request
- The servlet request we are processingresponse
- The servlet response we are creatingform
- The ActionForm instance we are populatingmapping
- The ActionMapping we are using
javax.servlet.ServletException
- if thrown by RequestUtils.populate()protected boolean processPreprocess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
General-purpose preprocessing hook that can be overridden as
required by subclasses. Return true
if you want standard
processing to continue, or false
if the response has
already been completed. The default implementation does nothing.
request
- The servlet request we are processingresponse
- The servlet response we are creating
true
to continue normal processing;
false
if a response has been created.protected boolean processRoles(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException
If this action is protected by security roles, make sure that the
current user possesses at least one of them. Return true
to continue normal processing, or false
if an appropriate
response has been created and processing should terminate.
request
- The servlet request we are processingresponse
- The servlet response we are creatingmapping
- The mapping we are using
true
to continue normal processing;
false
if a response has been created.
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occursprotected boolean processValidate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException, InvalidCancelException
If this request was not cancelled, and the request's ActionMapping
has not disabled validation, call the
validate
method of the specified ActionForm
, and
forward to the input path if there were any errors. Return
true
if we should continue processing, or
false
if we have already forwarded control back to the
input form.
request
- The servlet request we are processingresponse
- The servlet response we are creatingform
- The ActionForm instance we are populatingmapping
- The ActionMapping we are using
true
to continue normal processing;
false
if a response has been created.
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occurs
InvalidCancelException
- if a cancellation is attempted
without the proper action configuration.protected void internalModuleRelativeForward(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Do a module relative forward to specified URI using request dispatcher. URI is relative to the current module. The real URI is compute by prefixing the module name.
This method is used internally and is not part of the public API. It is advised to not use it in subclasses.
uri
- Module-relative URI to forward torequest
- Current page requestresponse
- Current page response
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occursprotected void internalModuleRelativeInclude(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Do a module relative include to specified URI using request dispatcher. URI is relative to the current module. The real URI is compute by prefixing the module name.
This method is used internally and is not part of the public API. It is advised to not use it in subclasses.
uri
- Module-relative URI to includerequest
- Current page requestresponse
- Current page response
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occursprotected void doForward(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Do a forward to specified URI using a RequestDispatcher
.
This method is used by all internal method needing to do a
forward.
uri
- Context-relative URI to forward torequest
- Current page requestresponse
- Current page response
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occursprotected void doInclude(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Do an include of specified URI using a RequestDispatcher
.
This method is used by all internal method needing to do an
include.
uri
- Context-relative URI to includerequest
- Current page requestresponse
- Current page response
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet exception occursprotected MessageResources getInternal()
Return the MessageResources
instance containing our
internal message strings.
MessageResources
instance containing our
internal message strings.protected javax.servlet.ServletContext getServletContext()
Return the ServletContext
for the web application in
which we are running.
ServletContext
for the web application.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |