|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rhq.enterprise.communications.command.client.JBossRemotingRemoteCommunicator
public class JBossRemotingRemoteCommunicator
Provides basic functionality to all command clients that want to use JBoss/Remoting as the remoting framework.
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.
The users of this object may manually connect and disconnect that remoting
client. 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 remoting client when this object is no longer needed to
issue commands to the remote server.
All subclasses should include a no-arg constructor so they can be built dynamically by the cmdline client.
| Field Summary | |
|---|---|
static String |
DEFAULT_SUBSYSTEM
The default subsystem to use when sending messages via the JBoss/Remoting client. |
| Constructor Summary | |
|---|---|
JBossRemotingRemoteCommunicator()
Constructor for JBossRemotingRemoteCommunicator that initializes the client with no invoker locator
defined. |
|
JBossRemotingRemoteCommunicator(org.jboss.remoting.InvokerLocator locator)
Constructor for JBossRemotingRemoteCommunicator that allows you to specify the
invoker locator to use. |
|
JBossRemotingRemoteCommunicator(org.jboss.remoting.InvokerLocator locator,
Map<String,String> client_config)
Constructor for JBossRemotingRemoteCommunicator that allows you to specify the
invoker locator to use. |
|
JBossRemotingRemoteCommunicator(org.jboss.remoting.InvokerLocator locator,
String subsystem)
Constructor for JBossRemotingRemoteCommunicator that allows you to specify the
invoker locator to use. |
|
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. |
|
JBossRemotingRemoteCommunicator(String locatorUri,
String subsystem)
Constructor for JBossRemotingRemoteCommunicator that allows you to indicate the
invoker locator to use by specifying the locator's URI. |
|
JBossRemotingRemoteCommunicator(String locatorUri,
String subsystem,
Map<String,String> client_config)
Constructor for JBossRemotingRemoteCommunicator that allows you to indicate the
invoker locator to use by specifying the locator's URI. |
|
| Method Summary | |
|---|---|
void |
connect()
Connects this communicator object with the remote endpoint. |
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. |
protected org.jboss.remoting.Client |
getRemotingClient()
Returns the remoting client that is to be used to transport the command request to the server. |
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 |
setInvokerLocator(org.jboss.remoting.InvokerLocator locator)
Sets the invoker locator that this communicator should use for its subsequent command client invocations. |
void |
setInvokerLocator(org.jboss.remoting.InvokerLocator locator,
Map<String,String> client_config)
Sets the invoker locator that this communicator should use for its subsequent command client invocations. |
void |
setInvokerLocator(String locatorUri)
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. |
void |
setInvokerLocator(String locatorUri,
Map<String,String> client_config)
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. |
void |
setRemoteEndpoint(String endpoint)
Sets the remote endpoint that this communicator object will send commands to. |
void |
setSubsystem(String subsystem)
Sets the value of the subsystem that will be used to target command invocations. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_SUBSYSTEM
| Constructor Detail |
|---|
public JBossRemotingRemoteCommunicator()
JBossRemotingRemoteCommunicator that initializes the client with no invoker locator
defined. It must later be specified through setInvokerLocator(InvokerLocator) before any client commands
can be issued. In addition, the getSubsystem() will be set to the DEFAULT_SUBSYSTEM.
Note that all subclasses are strongly urged to include this no-arg constructor so it can plug into the cmdline client seamlessly.
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)
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. The subsystem will be set to the DEFAULT_SUBSYSTEM.
locator - the locator to use (may be null)
public JBossRemotingRemoteCommunicator(org.jboss.remoting.InvokerLocator locator,
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.The subsystem will be set to the DEFAULT_SUBSYSTEM. The given Map should contain
Client configuration attributes.
locator - the locator to use (may be null)client_config - the client configuration (may be null or empty)
public JBossRemotingRemoteCommunicator(org.jboss.remoting.InvokerLocator locator,
String subsystem)
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)
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 JBossRemotingRemoteCommunicator(String locatorUri,
String subsystem)
throws MalformedURLException
JBossRemotingRemoteCommunicator that allows you to indicate the
invoker locator to use by specifying the locator's URI.
locatorUri - the locator's URI (must not be null)subsystem - the subsystem (or command domain) in which commands will be invoked (may be null)
MalformedURLException - if failed to create the locator (see InvokerLocator.InvokerLocator(String))
public JBossRemotingRemoteCommunicator(String locatorUri,
String subsystem,
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 given Map should
contain Client configuration attributes.
locatorUri - the locator's URI (must not 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)
MalformedURLException - if failed to create the locator (see InvokerLocator.InvokerLocator(String))| Method Detail |
|---|
public org.jboss.remoting.InvokerLocator getInvokerLocator()
null is
returned, this communicator will not be able to issue commands.
public void setInvokerLocator(String locatorUri)
throws MalformedURLException
setInvokerLocator(String, Map) if you want to
reconfigure the client with different properties that are more appropriate for the new locator.
locatorUri - 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))setInvokerLocator(InvokerLocator)
public void setInvokerLocator(String locatorUri,
Map<String,String> client_config)
throws MalformedURLException
locatorUri - the new invoker locator's URI to use for future command client invocations (must not be
null)client_config - the client configuration for any new remoting clients that are created (may be
null or empty)
MalformedURLException - if failed to create the locator (see InvokerLocator.InvokerLocator(String))setInvokerLocator(InvokerLocator)public void setInvokerLocator(org.jboss.remoting.InvokerLocator locator)
setInvokerLocator(InvokerLocator, Map) if you want to reconfigure the client with different properties
that are more appropriate for the new locator.
locator - the new invoker locator to use for future command client invocations (must not be
null)
IllegalArgumentException - if locator is null
public void setInvokerLocator(org.jboss.remoting.InvokerLocator locator,
Map<String,String> client_config)
locator - the new invoker locator to use for future command client invocations (must not be
null)client_config - the client configuration for any new remoting clients that are created (may be
null or empty)
IllegalArgumentException - if locator is nullpublic String getSubsystem()
null)public void setSubsystem(String subsystem)
If a remoting client already exists, its subsystem will be changed to the given subsystem.
subsystem - the new value of subsystem (may be null)public FailureCallback getFailureCallback()
RemoteCommunicator
getFailureCallback 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()
RemoteCommunicator
getInitializeCallback 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()
RemoteCommunicator
getRemoteEndpoint in interface RemoteCommunicator
public void setRemoteEndpoint(String endpoint)
throws Exception
RemoteCommunicator
setRemoteEndpoint in interface RemoteCommunicatorendpoint - the new remote endpoint
Exception - if the communicator could not point to the new remote endpointpublic Map<String,String> getClientConfiguration()
setInvokerLocator(InvokerLocator, Map) or setInvokerLocator(String, Map) to
change the map contents.
null or empty)
public void connect()
throws Exception
RemoteCommunicator
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 otherise
public 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)public String toString()
toString in class Object
protected org.jboss.remoting.Client getRemotingClient()
throws Exception
setInvokerLocator(InvokerLocator)).
This method will cache the client and connect to the server automatically. Note that the client will be
disconnected whenever the invoker is reset via setInvokerLocator(InvokerLocator). Therefore, callers
should never cache the returned object themselves - always call this method to obtain a reference to the
client.
Exception - if failed to create the client for whatever reason
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||