org.apache.struts.actions
Class ActionDispatcher
java.lang.Object
org.apache.struts.actions.ActionDispatcher
public class ActionDispatcher
extends java.lang.Object
Action
helper class that dispatches to a public method in an Action.
This class is provided as an alternative mechanism to using DispatchAction
and its various flavours and means
Dispatch behaviour can be
easily implemented into any
Action
without having to
inherit from a particular super
Action
.
To implement
dispatch behaviour in an
Action
class,
create your custom Action as follows, along with the methods you
require (and optionally "cancelled" and "unspecified" methods):
public class MyCustomAction extends Action {
protected ActionDispatcher dispatcher
= new ActionDispatcher(this, ActionDispatcher.MAPPING_FLAVOR);
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return dispatcher.execute(mapping, form, request, response);
}
}
It provides three flavours of determing the name of the method:
DEFAULT_FLAVOR
- uses the parameter specified in
the struts-config.xml to get the method name from the Request
(equivalent to DispatchAction
except uses "method"
as a default if the parameter
is not specified
in the struts-config.xml).DISPATCH_FLAVOR
- uses the parameter specified in
the struts-config.xml to get the method name from the Request
(equivalent to DispatchAction
).MAPPING_FLAVOR
- uses the parameter specified in
the struts-config.xml as the method name
(equivalent to MappingDispatchAction
).
$Revision: 383720 $ $Date: 2006-03-07 00:07:59 +0000 (Tue, 07 Mar 2006) $static int | DEFAULT_FLAVOR - Indicates "default" dispatch flavor
|
static int | DISPATCH_FLAVOR - Indicates flavor compatible with DispatchAction
|
static int | MAPPING_FLAVOR - Indicates "mapping" dispatch flavor
|
protected Action | actionInstance - The associated Action to dispatch to.
|
protected Class | clazz - The Class instance of this
DispatchAction class.
|
protected int | flavor - Indicates dispatch flavor
|
protected static Log | log - Commons Logging instance.
|
protected static MessageResources | messages - The message resources for this package.
|
protected HashMap | methods - The set of Method objects we have introspected for this class,
keyed by method name.
|
protected Class[] | types - The set of argument type classes for the reflected method call.
|
protected ActionForward | cancelled(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - Dispatches to the target class' cancelled method, if present,
otherwise returns null.
|
protected ActionForward | dispatchMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String name) - Dispatch to the specified method.
|
protected ActionForward | dispatchMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String name, Method method) - Dispatch to the specified method.
|
ActionForward | execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - Process the specified HTTP request, and create the corresponding HTTP
response (or forward to another web component that will create it).
|
protected Method | getMethod(String name) - Introspect the current class to identify a method of the specified
name that accepts the same parameter types as the
execute
method does.
|
protected String | getMethodName(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String parameter) - Returns the method name, given a parameter's value.
|
|