public abstract class DispatchCommand extends Object implements Command
Modifier and Type | Field and Description |
---|---|
protected static Class[] |
DEFAULT_SIGNATURE
The base implementation expects dispatch methods to take a
Context
as their only argument. |
CONTINUE_PROCESSING, PROCESSING_COMPLETE
Constructor and Description |
---|
DispatchCommand() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
evaluateResult(Object o)
Evaluate the result of the method invocation as a boolean value.
|
boolean |
execute(Context context)
Look up the method specified by either "method" or "methodKey" and invoke it,
returning a boolean value as interpreted by
evaluateResult . |
protected Method |
extractMethod(Context context)
Extract the dispatch method.
|
protected Object[] |
getArguments(Context context)
Get the arguments to be passed into the dispatch method.
|
String |
getMethod()
Return the method name.
|
String |
getMethodKey()
Return the Context key for the method name.
|
protected Class[] |
getSignature()
Return a
Class[] describing the expected signature of the method. |
void |
setMethod(String method)
Set the method name.
|
void |
setMethodKey(String methodKey)
Set the Context key for the method name.
|
protected static final Class[] DEFAULT_SIGNATURE
Context
as their only argument.public boolean execute(Context context) throws Exception
evaluateResult
.execute
in interface Command
context
- The Context to be processed by this Command.IllegalStateException
- if neither 'method' nor 'methodKey' properties are definedException
- if any is thrown by the invocation. Note that if invoking the method
results in an InvocationTargetException, the cause of that exception is thrown instead of
the exception itself, unless the cause is an Error
or other Throwable
which is not an Exception
.protected Method extractMethod(Context context) throws NoSuchMethodException
method
property as the name of a method to look up, or, if that is not defined,
looks up the the method name in the Context using the methodKey
.context
- The Context being processed by this Command.NoSuchMethodException
- if no method can be found under the specified name.NullPointerException
- if no methodName cannot be determinedprotected boolean evaluateResult(Object o)
o
- The result of the methid executionprotected Class[] getSignature()
Class[]
describing the expected signature of the method.protected Object[] getArguments(Context context)
getSignature()
context
- The Context being processed by this Command.public String getMethod()
public String getMethodKey()
public void setMethod(String method)
method
- The method name.public void setMethodKey(String methodKey)
methodKey
- The Context key for the method name.Copyright © 2003–2021 The Apache Software Foundation. All rights reserved.