public abstract class AbstractCommandClient extends Object implements CommandClient
This superclass provides the hooks by which users of the client can select the
location of the remote endpoint where the command is to be
invoked.
RemoteCommunicator defines a particular remote
framework.
The users of this object may manually connect and
disconnect that communicator. Typically, there will not be a need to connect
since it will be done automatically when appropriate; however, it is good practice to tell this object to disconnect
its communicator when this object is no longer needed to issue commands to the remote endpoint.
All subclasses should include a no-arg constructor so they can be built dynamically by the cmdline client.
| Constructor and Description |
|---|
AbstractCommandClient()
Constructor for
AbstractCommandClient that initializes the client with no remote communicator defined. |
AbstractCommandClient(RemoteCommunicator communicator)
Constructor for
AbstractCommandClient that allows you to specify the
remote communicator to use. |
| Modifier and Type | Method and Description |
|---|---|
void |
connectRemoteCommunicator()
Provides a mechanism by which users can notify this object that the user is about to issue commands and that a
remoting communicator should be created and should connect to the remote server.
|
void |
disconnectRemoteCommunicator()
Provides a mechanism by which users can notify this object that the user is no longer interested in issuing
commands to the remote server.
|
RemoteCommunicator |
getRemoteCommunicator()
Gets the object that encapsulates the underlying remote framework implementation.
|
CommandResponse |
invoke(Command command)
Invokes the actual command by utilizing the remoting communicator to transport the command to the server.
|
CommandResponse |
invoke(Map<String,Object> params)
Invokes the actual command by utilizing the remoting communicator to transport the command to the server.
|
void |
setRemoteCommunicator(RemoteCommunicator communicator)
Sets the object that encapsulates the underlying remote framework implementation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateNewCommandpublic AbstractCommandClient()
AbstractCommandClient that initializes the client with no remote communicator defined. It
must later be specified through setRemoteCommunicator(RemoteCommunicator) before any commands can be
issued.
Note that all subclasses are strongly urged to include this no-arg constructor so it can plug into the cmdline client seamlessly.
public AbstractCommandClient(RemoteCommunicator communicator)
AbstractCommandClient that allows you to specify the
remote communicator to use. communicator may be null, in
which case, it must later be specified through setRemoteCommunicator(RemoteCommunicator) before any
commands can be issued.communicator - the remote communicator to be used to send commands to a remote endpointpublic void setRemoteCommunicator(RemoteCommunicator communicator)
CommandClientsetRemoteCommunicator in interface CommandClientcommunicator - the remote communicator object that is specific to a particular underlying remote
framework.CommandClient.setRemoteCommunicator(RemoteCommunicator)public RemoteCommunicator getRemoteCommunicator()
CommandClientgetRemoteCommunicator in interface CommandClientCommandClient.getRemoteCommunicator()public void connectRemoteCommunicator()
throws Exception
CommandClientconnectRemoteCommunicator in interface CommandClientException - if failed to connect to the remote server for any reasonCommandClient.connectRemoteCommunicator()public void disconnectRemoteCommunicator()
CommandClientNote that the user may later on change its mind and reconnect simply by calling
CommandClient.connectRemoteCommunicator(). Calling that method will reconnect the remoting communicator.
disconnectRemoteCommunicator in interface CommandClientCommandClient.disconnectRemoteCommunicator()public CommandResponse invoke(Map<String,Object> params) throws Throwable
CommandClientThis method is typically used in conjunction with CmdlineClient to invoke commands that are unknown at
compile-time. In this case, params typically contain values of type String - these are
text-based parameters that were entered via a script or cmdline. That text-based data will be
converted to meaningful Java types in order to be able to build
the proper Command objects.
invoke in interface CommandClientparams - a set of command parameters that are to be used to execute the proper command (may be
null)Throwable - on any error (either during the sending or execution of the command)CommandClient.invoke(Map)public CommandResponse invoke(Command command) throws Throwable
CommandClientThis is the prefered method for clients to call when it needs to invoke commands since each Command is
strongly typed and provides compile-time error checking. However, in order to be able to invoke this method on
subclasses, concrete implementations must be used and hence the actual command that is to be issued must be known
at compile time. Should a dynamic runtime client be needed to invoke commands unknown at compile time (see
CmdlineClient), the use of CommandClient.invoke(Map) will be required.
invoke in interface CommandClientcommand - encapsulates the command that is to be executed (must not be null)Throwable - on any error (either during the sending or execution of the command)CommandClient.invoke(Command)Copyright © 2008-2013 Red Hat, Inc.. All Rights Reserved.