public interface CommandHandler
Command
and input to the Command before it
is executed, or after it is executed.
CommandHandlers can be chained together to achieve layered services,
by configuring #getNextCommandHandler()NextCommandHandler
with the next Command Handler to invoke and invoking
executeCommand()
of the NextCommandHandler
in the
executeCommand()
method.
If CommandHandler
is doing pre processing then it should
do it before invoking the NextCommandHandler
, and if it is
doing post processing it should do it after invoking the
NextCommandHandler
CommandHandlers can take either a Map or List as input to their
executeCommand()
method.
At the end of any configured chain of CommandHandlers must be a CommandHandler that is capable of executing the Command that was passed to it. That is, there is a CommandHandler that actually executes the Command object.
Examples of CommandHandlers are: post processing by moving data from a results bucket to an exceptions bucket, caching command calls, and auditing.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION |
Modifier and Type | Method and Description |
---|---|
CommandResult |
executeCommand(Command pCommand,
java.lang.Object pInput)
Process the
Command and input to the Command before
or after invoking the NextCommandHandler . |
CommandHandler |
getNextCommandHandler()
Returns Next CommandHandler in the command invocation chain to invoke.
|
static final java.lang.String CLASS_VERSION
CommandHandler getNextCommandHandler()
CommandHandler
is the end of command invocation chain
then this property is not expected to be set.CommandResult executeCommand(Command pCommand, java.lang.Object pInput) throws CommandInvocationException, CommandTimeoutException, InvalidInputException
Command
and input to the Command before
or after invoking the NextCommandHandler
. If this is the
end of the invocation chain then this CommandHandler
is
expected to execute the Command
directly.
If this CommandHandler
is doing pre processing then
it should do it before invoking the executeCommand()
of the NextCommandHandler
, and if it is doing post
processing it should do it after invoking the executeCommand()
of the NextCommandHandler
pCommand
- the command to execute.pInput
- the input to the commandCommandInvocationException
- if any error occurs, or any exception
is thrown while executing the Command.CommandTimeoutException
- if timeout occurs while invoking the command.InvalidInputException
- if input object passed is invalid.