|
||||||||||
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 CatalogFactory |
catalogFactory
|
private java.lang.String |
catalogName
|
private boolean |
ignoreExecuteResult
|
private boolean |
ignorePostprocessResult
|
private java.lang.String |
name
|
private java.lang.String |
nameKey
|
private boolean |
optional
|
Fields inherited from interface org.apache.commons.chain.Command |
---|
CONTINUE_PROCESSING, PROCESSING_COMPLETE |
Constructor Summary | |
---|---|
LookupCommand()
Create an instance, setting its catalogFactory property to the
value of CatalogFactory.getInstance() . |
|
LookupCommand(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. |
CatalogFactory |
getCatalogFactory()
Return the CatalogFactory from which lookups will be performed. |
java.lang.String |
getCatalogName()
Return the name of the Catalog to be searched, or
null to search the default Catalog . |
protected 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 |
isIgnoreExecuteResult()
Return true if this command should ignore
the return value from executing the looked-up command. |
boolean |
isIgnorePostprocessResult()
Return true if this command is a Filter and
should ignore the return value from executing the looked-up Filter's
postprocess() method. |
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 |
setCatalogFactory(CatalogFactory catalogFactory)
Set the CatalogFactory from which lookups will be
performed. |
void |
setCatalogName(java.lang.String catalogName)
Set the name of the Catalog to be searched, or
null to search the default Catalog . |
void |
setIgnoreExecuteResult(boolean ignoreReturn)
Set the rules for whether or not this class will ignore or pass through the value returned from executing the looked up command. |
void |
setIgnorePostprocessResult(boolean ignorePostprocessResult)
Set the rules for whether or not this class will ignore or pass through the value returned from executing the looked up Filter's postprocess() method. |
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 CatalogFactory catalogFactory
private java.lang.String catalogName
private java.lang.String name
private java.lang.String nameKey
private boolean optional
private boolean ignoreExecuteResult
private boolean ignorePostprocessResult
Constructor Detail |
---|
public LookupCommand()
catalogFactory
property to the
value of CatalogFactory.getInstance()
.
public LookupCommand(CatalogFactory factory)
catalogFactory
property
to given factory
/
factory
- The Catalog Factory.Method Detail |
---|
public void setCatalogFactory(CatalogFactory catalogFactory)
Set the CatalogFactory
from which lookups will be
performed.
catalogFactory
- The Catalog Factory.public CatalogFactory getCatalogFactory()
CatalogFactory
from which lookups will be performed.
public java.lang.String getCatalogName()
Return the name of the Catalog
to be searched, or
null
to search the default Catalog
.
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.
true
if the Command is optional.public void setOptional(boolean optional)
Set the optional flag for finding the specified command.
optional
- The new optional flagpublic boolean isIgnoreExecuteResult()
Return true
if this command should ignore
the return value from executing the looked-up command.
Defaults to false
, which means that the return result
of executing this lookup will be whatever is returned from that
command.
true
if result of the looked up Command
should be ignored.public void setIgnoreExecuteResult(boolean ignoreReturn)
Set the rules for whether or not this class will ignore or pass through the value returned from executing the looked up command.
If you are looking up a chain which may be "aborted" and
you do not want this class to stop chain processing, then this
value should be set to true
ignoreReturn
- true
if result of the
looked up Command should be ignored.public boolean isIgnorePostprocessResult()
Return true
if this command is a Filter and
should ignore the return value from executing the looked-up Filter's
postprocess()
method.
Defaults to false
, which means that the return result
of executing this lookup will be whatever is returned from that
Filter.
true
if result of the looked up Filter's
postprocess()
method should be ignored.public void setIgnorePostprocessResult(boolean ignorePostprocessResult)
Set the rules for whether or not this class will ignore or
pass through the value returned from executing the looked up
Filter's postprocess()
method.
If you are looking up a Filter which may be "aborted" and
you do not want this class to stop chain processing, then this
value should be set to true
ignorePostprocessResult
- true
if result of the
looked up Filter's postprocess()
method should be ignored.public boolean execute(Context context) throws java.lang.Exception
Look up the specified command, and (if found) execute it.
Unless ignoreExecuteResult
is set to true
,
return the result of executing the found command. If no command
is found, return false
, unless the optional
property is false
, in which case an IllegalArgumentException
will be thrown.
execute
in interface Command
context
- The context for this request
false
if no command is found or if the command
is found but the ignoreExecuteResult
property of this
instance is true
java.lang.IllegalArgumentException
- if no such Command
can be found and the optional
property is set
to false
java.lang.Exception
- if and error occurs in the looked-up Command.public 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
postprocess
method
of the looked-up command, unless ignorePostprocessResult
is
true
. If no command is found, return false
,
unless the optional
property is false
, in which
case IllegalArgumentException
will be thrown.protected 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 |