|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.chain.generic.LookupCommand
public class LookupCommand
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
.
Field Summary | |
---|---|
private java.lang.String |
catalogName
|
private java.lang.String |
name
|
private java.lang.String |
nameKey
|
private boolean |
optional
|
Constructor Summary | |
---|---|
LookupCommand()
|
Method Summary | |
---|---|
boolean |
execute(Context context)
Look up the specified command, and (if found) execute it. |
java.lang.String |
getCatalogName()
Return the name of the Catalog to be searched, or
null to search the default Catalog . |
private Command |
getCommand(Context context)
Return the Command instance to be delegated to. |
java.lang.String |
getName()
Return the name of the Command that we will look up and
delegate execution to. |
java.lang.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,
java.lang.Exception exception)
If the executed command was itself a Filter , call the
postprocess() method of that Filter as well. |
void |
setCatalogName(java.lang.String catalogName)
Set the name of the Catalog to be searched, or
null to search the default Catalog . |
void |
setName(java.lang.String name)
Set the name of the Command that we will look up and
delegate execution to. |
void |
setNameKey(java.lang.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 |
Field Detail |
---|
private java.lang.String catalogName
private java.lang.String name
private java.lang.String nameKey
private boolean optional
Constructor Detail |
---|
public LookupCommand()
Method Detail |
---|
public java.lang.String getCatalogName()
public void setCatalogName(java.lang.String catalogName)
Set the name of the Catalog
to be searched, or
null
to search the default Catalog
.
catalogName
- The new Catalog
name or null
public java.lang.String getName()
Return the name of the Command
that we will look up and
delegate execution to.
public void setName(java.lang.String name)
Set the name of the Command
that we will look up and
delegate execution to.
name
- The new command namepublic java.lang.String getNameKey()
Return the context attribute key under which the Command
name is stored.
public void setNameKey(java.lang.String nameKey)
Set the context attribute key under which the Command
name is stored.
nameKey
- The new context attribute keypublic boolean isOptional()
Return true
if locating the specified command
is optional.
public void setOptional(boolean optional)
Set the optional flag for finding the specified command.
optional
- The new optional flagpublic boolean execute(Context context) throws java.lang.Exception
Look up the specified command, and (if found) execute it.
execute
in interface Command
context
- The context for this request
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
java.lang.IllegalArgumentException
- if no such Command
can be found and the optional
property is set
to false
java.lang.Exception
- general purpose exception return
to indicate abnormal terminationpublic boolean postprocess(Context context, java.lang.Exception exception)
If the executed command was itself a Filter
, call the
postprocess()
method of that Filter
as well.
postprocess
in interface Filter
context
- The context for this requestexception
- Any Exception
thrown by command execution
exception
was "handled" by this
method (and therefore need not be rethrown), return true
;
otherwise return false
java.lang.Exception
- if thrown by the postprocess()
methodprivate Command getCommand(Context context)
Return the Command
instance to be delegated to.
context
- Context
for this request
java.lang.IllegalArgumentException
- if no such Command
can be found and the optional
property is set
to false
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |