|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.chain.generic.DispatchCommand
public abstract class DispatchCommand
An abstract base command which uses introspection to look up a method to execute. For use by developers who prefer to group related functionality into a single class rather than an inheritance family.
Field Summary | |
---|---|
protected static Class[] |
DEFAULT_SIGNATURE
The base implementation expects dispatch methods to take a Context
as their only argument. |
Fields inherited from interface org.apache.commons.chain.Command |
---|
CONTINUE_PROCESSING, PROCESSING_COMPLETE |
Constructor Summary | |
---|---|
DispatchCommand()
|
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Class[] DEFAULT_SIGNATURE
Context
as their only argument.
Constructor Detail |
---|
public DispatchCommand()
Method Detail |
---|
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 defined
Exception
- 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 execution
protected 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |