public class JBossRemotingRemoteCommunicator extends Object implements RemoteCommunicator
This superclass provides the hooks by which users of the client can select the
location of the remote server and the subsystem
where the command is to be invoked.
Under the covers, a remoting client is created and maintained by this object.
There is no need to call connect() since it will be done automatically when appropriate; however,
it is good practice to tell this object to disconnect() its client when no longer necessary to
issue commands to the remote server.
All subclasses should include a no-arg constructor so they can be built dynamically by the command line client.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_SUBSYSTEM
The default subsystem to use when sending messages via the JBoss/Remoting client.
|
| Constructor and Description |
|---|
JBossRemotingRemoteCommunicator(org.jboss.remoting.InvokerLocator locator,
String subsystem,
Map<String,String> client_config)
Constructor for
JBossRemotingRemoteCommunicator that allows you to specify the
invoker locator to use. |
JBossRemotingRemoteCommunicator(String locatorUri)
Constructor for
JBossRemotingRemoteCommunicator that allows you to indicate the
invoker locator to use by specifying the locator's URI. |
JBossRemotingRemoteCommunicator(String locatorUri,
Map<String,String> client_config)
Constructor for
JBossRemotingRemoteCommunicator that allows you to indicate the
invoker locator to use by specifying the locator's URI. |
| Modifier and Type | Method and Description |
|---|---|
void |
connect()
Does nothing; send a request to connect.
|
void |
disconnect()
Disconnects this communicator object from the remote endpoint.
|
Map<String,String> |
getClientConfiguration()
Returns the map of name/value pairs of client configuration settings used when creating the client.
|
FailureCallback |
getFailureCallback()
Returns the failure callback currently configured within this object.
|
InitializeCallback |
getInitializeCallback()
Returns the initialize callback currently configured within this object.
|
org.jboss.remoting.InvokerLocator |
getInvokerLocator()
Returns the invoker locator that is to be used to find the remote JBoss/Remoting server.
|
String |
getRemoteEndpoint()
Returns a string representation of the remote endpoint this communicator is configured to talk to.
|
String |
getSubsystem()
Returns the value of the subsystem that will be used to target command invocations.
|
boolean |
isConnected()
Returns
true if this object has established a live connection with the remote endpoint. |
CommandResponse |
send(Command command)
Sends the given command to the remote endpoint by utilizing a remoting framework supported by the specific
communicator implementation.
|
CommandResponse |
sendWithoutCallbacks(Command command)
This is the same as
RemoteCommunicator.send(Command) except, on error, this method will not attempt
to call the failure callback, if one was set. |
CommandResponse |
sendWithoutInitializeCallback(Command command)
This is the same as
RemoteCommunicator.send(Command) except this method will not attempt
to call the initialize callback,
thus allowing this method to be called from the initialize callback itself. |
void |
setFailureCallback(FailureCallback callback)
Sets the given failure callback as the one that will be notified when this object sees a comm failure.
|
void |
setInitializeCallback(InitializeCallback callback)
Sets the given initialize callback as the one that will be notified when this object attempts
to send its very first message after a
RemoteCommunicator.connect(). |
void |
setRemoteEndpoint(String endpoint)
Sets the invoker locator URI and creates a new locator that is to be used to find the remote JBoss/Remoting
server for its subsequent command client invocations.
|
String |
toString() |
public static final String DEFAULT_SUBSYSTEM
public JBossRemotingRemoteCommunicator(String locatorUri) throws MalformedURLException
JBossRemotingRemoteCommunicator that allows you to indicate the
invoker locator to use by specifying the locator's URI. The subsystem will be set to the
DEFAULT_SUBSYSTEM.locatorUri - the locator's URI (must not be null)MalformedURLException - if failed to create the locator (see InvokerLocator.InvokerLocator(String))public JBossRemotingRemoteCommunicator(String locatorUri, Map<String,String> client_config) throws MalformedURLException
JBossRemotingRemoteCommunicator that allows you to indicate the
invoker locator to use by specifying the locator's URI. The subsystem will be set to the
DEFAULT_SUBSYSTEM. The given Map should contain Client configuration
attributes.locatorUri - the locator's URI (must not be null)client_config - the client configuration (may be null or empty)MalformedURLException - if failed to create the locator (see InvokerLocator.InvokerLocator(String))public JBossRemotingRemoteCommunicator(org.jboss.remoting.InvokerLocator locator,
String subsystem,
Map<String,String> client_config)
JBossRemotingRemoteCommunicator that allows you to specify the
invoker locator to use. locator may be null, in which case, it
must later be specified through #setInvokerLocator(InvokerLocator) before any client commands can be
issued.locator - the locator to use (may be null)subsystem - the subsystem (or command domain) in which commands will be invoked (may be
null)client_config - the client configuration (may be null or empty)public org.jboss.remoting.InvokerLocator getInvokerLocator()
null is
returned, this communicator will not be able to issue commands.public void setRemoteEndpoint(String endpoint) throws Exception
#setInvokerLocator(String, Map) if you want to
reconfigure the client with different properties that are more appropriate for the new locator.setRemoteEndpoint in interface RemoteCommunicatorlocatorUri - the new invoker locator's URI to use for future command client invocations (must not be
null)MalformedURLException - if failed to create the locator (see InvokerLocator.InvokerLocator(String))Exception - if the communicator could not point to the new remote endpointpublic String getSubsystem()
null)public FailureCallback getFailureCallback()
RemoteCommunicatorgetFailureCallback in interface RemoteCommunicatornull)public void setFailureCallback(FailureCallback callback)
RemoteCommunicatornull if you don't need this object to notify anything when a failure is detected.
The callback can be used to reconfigure this communicator and retry the failed message (useful to implement
failover algorithms).setFailureCallback in interface RemoteCommunicatorcallback - the object that listens to failures and may trigger retries (may be null)public InitializeCallback getInitializeCallback()
RemoteCommunicatorgetInitializeCallback in interface RemoteCommunicatornull)public void setInitializeCallback(InitializeCallback callback)
RemoteCommunicatorRemoteCommunicator.connect(). This allows the callback to perform
additional initialization procedures prior to the first message getting sent to the remote
endpoint. The callback is free to send its own messages via RemoteCommunicator.sendWithoutCallbacks(Command)
or RemoteCommunicator.sendWithoutInitializeCallback(Command).setInitializeCallback in interface RemoteCommunicatorpublic String getRemoteEndpoint()
RemoteCommunicatorgetRemoteEndpoint in interface RemoteCommunicatorpublic Map<String,String> getClientConfiguration()
#setInvokerLocator(InvokerLocator, Map) or #setInvokerLocator(String, Map) to
change the map contents.null or empty)public void connect()
throws Exception
connect in interface RemoteCommunicatorException - if failed to connect to the remote endpoint for any reasonRemoteCommunicator.disconnect()public void disconnect()
RemoteCommunicatorNote that the user may later on change its mind and reconnect simply by calling RemoteCommunicator.connect().
disconnect in interface RemoteCommunicatorpublic boolean isConnected()
RemoteCommunicatortrue if this object has established a live connection with the remote endpoint.isConnected in interface RemoteCommunicatortrue if connected to a remote endpoint; false otherisepublic CommandResponse sendWithoutCallbacks(Command command) throws Throwable
RemoteCommunicatorRemoteCommunicator.send(Command) except, on error, this method will not attempt
to call the failure callback, if one was set. This is useful when the caller wants to
explicitly handle any failure that might occur without any interference with a failure callback.
This method will also not attempt to call the initialize callback,
thus allowing this method to be called from the initialize callback itself.sendWithoutCallbacks in interface RemoteCommunicatorcommand - 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)public CommandResponse sendWithoutInitializeCallback(Command command) throws Throwable
RemoteCommunicatorRemoteCommunicator.send(Command) except this method will not attempt
to call the initialize callback,
thus allowing this method to be called from the initialize callback itself.sendWithoutInitializeCallback in interface RemoteCommunicatorcommand - 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)public CommandResponse send(Command command) throws Throwable
RemoteCommunicatorfailure callback
is defined, this method will notify that callback of the problem and ask it if it should retry.send in interface RemoteCommunicatorcommand - 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)Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.