org.apache.commons.chain.generic
Class LookupCommand

java.lang.Object
  extended byorg.apache.commons.chain.generic.LookupCommand
All Implemented Interfaces:
Command, Filter

public class LookupCommand
extends Object
implements Filter

Look up a specified Command (which could also be a Chain) in a Catalog, and delegate execution to it. 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.

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.

Version:
$Revision: 1.10 $ $Date: 2004/11/30 05:52:23 $
Author:
Craig R. McClanahan

Constructor Summary
LookupCommand()
           
 
Method Summary
 boolean execute(Context context)
          Look up the specified command, and (if found) execute it.
 String getCatalogName()
          Return the name of the Catalog to be searched, or null to search the default Catalog.
 String getName()
          Return the name of the Command that we will look up and delegate execution to.
 String getNameKey()
          Return the context attribute key under which the Command name is stored.
 boolean isOptional()
          Return true if locating the specified command is optional.
 boolean postprocess(Context context, Exception exception)
          If the executed command was itself a Filter, call the postprocess() method of that Filter as well.
 void setCatalogName(String catalogName)
          Set the name of the Catalog to be searched, or null to search the default Catalog.
 void setName(String name)
          Set the name of the Command that we will look up and delegate execution to.
 void setNameKey(String nameKey)
          Set the context attribute key under which the Command name is stored.
 void setOptional(boolean optional)
          Set the optional flag for finding the specified command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookupCommand

public LookupCommand()
Method Detail

getCatalogName

public String getCatalogName()

Return the name of the Catalog to be searched, or null to search the default Catalog.


setCatalogName

public void setCatalogName(String catalogName)

Set the name of the Catalog to be searched, or null to search the default Catalog.

Parameters:
catalogName - The new Catalog name or null

getName

public String getName()

Return the name of the Command that we will look up and delegate execution to.


setName

public void setName(String name)

Set the name of the Command that we will look up and delegate execution to.

Parameters:
name - The new command name

getNameKey

public String getNameKey()

Return the context attribute key under which the Command name is stored.


setNameKey

public void setNameKey(String nameKey)

Set the context attribute key under which the Command name is stored.

Parameters:
nameKey - The new context attribute key

isOptional

public boolean isOptional()

Return true if locating the specified command is optional.


setOptional

public void setOptional(boolean optional)

Set the optional flag for finding the specified command.

Parameters:
optional - The new optional flag

execute

public boolean execute(Context context)
                throws Exception

Look up the specified command, and (if found) execute it.

Specified by:
execute in interface Command
Parameters:
context - The context for this request
Returns:
true if the processing of this Context has been completed, or false if the processing of this Context should be delegated to a subsequent Command in an enclosing Chain
Throws:
IllegalArgumentException - if no such Command can be found and the optional property is set to false
Exception - general purpose exception return to indicate abnormal termination

postprocess

public boolean postprocess(Context context,
                           Exception exception)

If the executed command was itself a Filter, call the postprocess() method of that Filter as well.

Specified by:
postprocess in interface Filter
Parameters:
context - The context for this request
exception - Any Exception thrown by command execution
Returns:
If a non-null exception was "handled" by this method (and therefore need not be rethrown), return true; otherwise return false
Throws:
Exception - if thrown by the postprocess() method


Copyright © 2003-2005 The Apache Software Foundation. All Rights Reserved.