|
||||||||||
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
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 |
---|
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. |
protected Catalog |
getCatalog(Context context)
Return the Catalog to look up the Command in. |
CatalogFactory |
getCatalogFactory()
Return the CatalogFactory from which lookups will be performed. |
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. |
protected String |
getCommandName(Context context)
Return the name of the Command instance to be delegated to. |
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 |
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,
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(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(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 |
---|
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 String getCatalogName()
Return the name of the Catalog
to be searched, or
null
to search the default Catalog
.
public void setCatalogName(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 String getName()
Return the name of the Command
that we will look up and
delegate execution to.
public void setName(String name)
Set the name of the Command
that we will look up and
delegate execution to.
name
- The new command namepublic String getNameKey()
Return the context attribute key under which the Command
name is stored.
public void setNameKey(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 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
IllegalArgumentException
- if no such Command
can be found and the optional
property is set
to false
Exception
- if and error occurs in the looked-up Command.public boolean postprocess(Context context, 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 Catalog getCatalog(Context context)
Return the Catalog
to look up the Command
in.
context
- Context
for this request
IllegalArgumentException
- if no Catalog
can be foundprotected Command getCommand(Context context)
Return the Command
instance to be delegated to.
context
- Context
for this request
IllegalArgumentException
- if no such Command
can be found and the optional
property is set
to false
protected String getCommandName(Context context)
Return the name of the Command
instance to be delegated to.
context
- Context
for this request
Command
instance
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |