Save This Page
Home » commons-chain-1.2-src » org.apache.commons » chain » generic » [javadoc | source]
org.apache.commons.chain.generic
public class: DispatchLookupCommand [javadoc | source]
java.lang.Object
   org.apache.commons.chain.generic.LookupCommand
      org.apache.commons.chain.generic.DispatchLookupCommand

All Implemented Interfaces:
    Filter

This command combines elements of the LookupCommand with the DispatchCommand . Look up a specified Command (which could also be a org.apache.commons.chain.Chain ) in a org.apache.commons.chain.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.

Constructor:
 public DispatchLookupCommand() 
 public DispatchLookupCommand(CatalogFactory factory) 
    Create an instance and initialize the catalogFactory property to given factory.
    Parameters:
    factory - The Catalog Factory.
Method from org.apache.commons.chain.generic.DispatchLookupCommand Summary:
execute,   getArguments,   getMethod,   getMethodKey,   getSignature,   setMethod,   setMethodKey
Methods from org.apache.commons.chain.generic.LookupCommand:
execute,   getCatalog,   getCatalogFactory,   getCatalogName,   getCommand,   getCommandName,   getName,   getNameKey,   isIgnoreExecuteResult,   isIgnorePostprocessResult,   isOptional,   postprocess,   setCatalogFactory,   setCatalogName,   setIgnoreExecuteResult,   setIgnorePostprocessResult,   setName,   setNameKey,   setOptional
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.chain.generic.DispatchLookupCommand Detail:
 public boolean execute(Context context) throws Exception 

    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. Default implementation simply returns the context which was passed in, but subclasses could use this to wrap the context in some other type, or extract key values from the context to pass in. The length and types of values returned by this must coordinate with the return value of getSignature()
 public String getMethod() 
    Return the method name.
 public String getMethodKey() 
    Return the Context key for the method name.
 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.

 public  void setMethod(String method) 
    Set the method name.
 public  void setMethodKey(String methodKey) 
    Set the Context key for the method name.