|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.chain.generic.LookupCommand org.apache.commons.chain.generic.DispatchLookupCommand
public class DispatchLookupCommand
This command combines elements of the LookupCommand
with the
DispatchCommand
. Look up a specified Command
(which could
also be a Chain
) in a
Catalog
, and delegate execution to
it. Introspection is used to lookup the appropriate method to delegate
execution to. If the delegated-to Command
is also a
Filter
, its postprocess()
method will also be invoked
at the appropriate time.
The name of the Command
can be specified either directly (via
the name
property) or indirectly (via the nameKey
property). Exactly one of these must be set.
The name of the method to be called can be specified either directly
(via the method
property) or indirectly (via the
methodKey
property). Exactly one of these must be set.
If the optional
property is set to true
,
failure to find the specified command in the specified catalog will be
silently ignored. Otherwise, a lookup failure will trigger an
IllegalArgumentException
.
Field Summary |
---|
Fields inherited from interface org.apache.commons.chain.Command |
---|
CONTINUE_PROCESSING, PROCESSING_COMPLETE |
Constructor Summary | |
---|---|
DispatchLookupCommand()
Create an instance with an unspecified catalogFactory property. |
|
DispatchLookupCommand(CatalogFactory factory)
Create an instance and initialize the catalogFactory property
to given factory . |
Method Summary | |
---|---|
boolean |
execute(Context context)
Look up the specified command, and (if found) execute it. |
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 org.apache.commons.chain.generic.LookupCommand |
---|
getCatalog, getCatalogFactory, getCatalogName, getCommand, getCommandName, getName, getNameKey, isIgnoreExecuteResult, isIgnorePostprocessResult, isOptional, postprocess, setCatalogFactory, setCatalogName, setIgnoreExecuteResult, setIgnorePostprocessResult, setName, setNameKey, setOptional |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.commons.chain.Filter |
---|
postprocess |
Constructor Detail |
---|
public DispatchLookupCommand()
catalogFactory
property.
This property can be set later using setProperty
, or if it is not set,
the static singleton instance from CatalogFactory.getInstance()
will be used.
public DispatchLookupCommand(CatalogFactory factory)
catalogFactory
property
to given factory
.
factory
- The Catalog Factory.Method Detail |
---|
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.public boolean execute(Context context) throws Exception
Look up the specified command, and (if found) execute it.
execute
in interface Command
execute
in class LookupCommand
context
- The context for this request
false
if no command is found.
Exception
- if no such Command
can be found and the
optional
property is set to false
protected Class[] getSignature()
Return a Class[]
describing the expected signature of
the method. The default is a signature that just accepts the command's
Context
. The method can be overidden to provide a different
method signature.
protected Object[] getArguments(Context context)
getSignature()
context
- The context associated with the request
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |