public interface Command
execute()
and invokeRPC()
.
The execute()
method is the one that determines how this
command should actually be executed. It might determine that it is
necessary to call a CommandHandler
before the command is
actually executed if CommandHandler
is configured with any CommandHandler
. Or, it might
determine that no CommandHandler
needs to be called and
the Command
can simply be executed and the results returned
to the calling program if no CommandHandler()
is configured.
The invokeRPC()
method is the one that actually executes
the command by mapping the Command
input onto the RPC defined
in the transport layer.
A Command's execute()
and invokeRPC()
method
throw these exceptions; CommandInvocationException
and
CommandTimeoutException
. These exceptions are intended to wrap
any underlying exceptions that might be thrown by a particular transport
or back end. These exceptions needs to wrap the underlying Exception
(as opposed to copying its message) so that stack trace printouts can
contain the information from the underlying exception.
CommandTimeoutException
is a special case of exception, since
time out doesn't indicate whether the RPC call is succeeded or not we need
to handle timeouts differently and so this exception is provided to allow
that.
InvalidInputException
indicates the input object passed to
the Command is invalid.
Also, Command's execute()
and invokeRPC()
method returns CommandResult
which is a transport independent
representation of the results from a RPC call.
A Command also contains a context
object which is a Properties
property. This property is
intended to be used as a hook for additional configuration or hints to a
transport/backend system that can not be captured in the standard input.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION |
Modifier and Type | Method and Description |
---|---|
CommandResult |
execute(java.lang.Object pInput)
Executes RPC Call at the configured back end system.
|
CommandHandler |
getCommandHandler()
Returns CommandHandler property to do pre/post processing of RPC call.
|
java.util.Map |
getContext()
Returns Hook for extra parameters
|
CommandResult |
invokeRPC(java.lang.Object pInput)
Actual method that executes the RPC Call at the back end system.
|
static final java.lang.String CLASS_VERSION
CommandHandler getCommandHandler()
java.util.Map getContext()
CommandResult execute(java.lang.Object pInput) throws CommandInvocationException, CommandTimeoutException, InvalidInputException
CommandHandler
If it does then calls the executeCommand()
on
the configured CommandHandler
. Eventually there will be
a CommandHandler that will call the invokeRPC()
method on
this command. If no CommandHandler is configured on this component then
the execute()
method just calls the invokeRPC()
method directly.pInput
- the input Map to pass as a input to RPC Call.CommandInvocationException
- if an error occurs in the middleware
or at the back end.CommandTimeoutException
- if timeout occurs while invoking the command.InvalidInputException
- if input object passed is invalid.CommandResult invokeRPC(java.lang.Object pInput) throws CommandInvocationException, CommandTimeoutException, InvalidInputException
pInput
- the input to map onto transport format and pass to back end.CommandInvocationException
- if an error occurs in the middleware
or at the back end.CommandTimeoutException
- if timeout occurs while invoking the command.InvalidInputException
- if input object passed is invalid.