org.jboss.remoting
Class Client

java.lang.Object
  extended byorg.jboss.remoting.Client

public class Client
extends java.lang.Object

Client is a convience method for invoking remote methods for a given subsystem


Field Summary
static int MAX_NUM_ONEWAY_THREADS
          Specifies the number of work threads in the pool for executing one way invocations on the client.
static java.lang.String RAW
           
 
Constructor Summary
Client(java.lang.ClassLoader cl, ClientInvoker (src)  invoker, java.lang.String subsystem)
           
Client(java.lang.ClassLoader cl, InvokerLocator (src)  locator, java.lang.String subsystem)
           
Client(InvokerLocator (src)  locator)
           
Client(InvokerLocator (src)  locator, java.lang.String subsystem)
           
 
Method Summary
 void addListener(InvokerCallbackHandler (src)  callbackHandler)
          Adds the specified handler as a callback listener for pull (sync) callbacks.
 void addListener(InvokerCallbackHandler (src)  callbackHandler, InvokerLocator (src)  clientLocator)
          Adds the specified handler as a callback listener for push (async) callbacks.
 void addListener(InvokerCallbackHandler (src)  callbackHandler, InvokerLocator (src)  clientLocator, java.lang.Object callbackHandlerObject)
          Adds the specified handler as a callback listener for push (async) callbacks.
 void connect()
           
 void disconnect()
           
 java.util.List getCallbacks()
           
 ClientInvoker (src) getInvoker()
           
 java.lang.String getSessionId()
           
 java.lang.String getSubsystem()
           
 java.lang.Object invoke(java.lang.Object param)
          Invokes the server invoker handler with the payload parameter passed.
 java.lang.Object invoke(java.lang.Object param, java.util.Map metadata)
          invoke the method remotely
 void invokeOneway(java.lang.Object param, java.util.Map sendPayload)
          Same as calling invokeOneway(Object param, Map sendPayload, boolean clientSide) with clientSide param being false.
 void invokeOneway(java.lang.Object param, java.util.Map sendPayload, boolean clientSide)
          Will invoke a oneway call to server without a return object.
 boolean isConnected()
           
 void removeListener(InvokerCallbackHandler (src)  callbackHandler)
          Removes callback handler as a callback listener from the server (and client in the case that it was setup to receive async callbacks).
 void setInvoker(ClientInvoker (src)  invoker)
           
 void setMarshaller(Marshaller (src)  marshaller)
           
 void setSessionId(java.lang.String sessionId)
          This will set the session id used when making invocations on server invokers.
 void setSubsystem(java.lang.String subsystem)
           
 void setUnMarshaller(UnMarshaller (src)  unmarshaller)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_NUM_ONEWAY_THREADS

public static final int MAX_NUM_ONEWAY_THREADS
Specifies the number of work threads in the pool for executing one way invocations on the client. Value is 10.

See Also:
Constant Field Values (src)

RAW

public static final java.lang.String RAW
See Also:
Constant Field Values (src)
Constructor Detail

Client

public Client(InvokerLocator (src)  locator)
       throws java.lang.Exception

Client

public Client(InvokerLocator (src)  locator,
              java.lang.String subsystem)
       throws java.lang.Exception

Client

public Client(java.lang.ClassLoader cl,
              InvokerLocator (src)  locator,
              java.lang.String subsystem)
       throws java.lang.Exception

Client

public Client(java.lang.ClassLoader cl,
              ClientInvoker (src)  invoker,
              java.lang.String subsystem)
       throws java.lang.Exception
Method Detail

setSessionId

public void setSessionId(java.lang.String sessionId)
This will set the session id used when making invocations on server invokers. There is a default unique id automatically generated for each Client instance, so unless you have a good reason to set this, do not set this.

Parameters:
sessionId -

getSessionId

public java.lang.String getSessionId()

isConnected

public boolean isConnected()

connect

public void connect()
             throws java.lang.Exception
Throws:
java.lang.Exception

disconnect

public void disconnect()

getInvoker

public ClientInvoker (src)  getInvoker()

setInvoker

public void setInvoker(ClientInvoker (src)  invoker)

getSubsystem

public java.lang.String getSubsystem()

setSubsystem

public void setSubsystem(java.lang.String subsystem)

invoke

public java.lang.Object invoke(java.lang.Object param)
                        throws java.lang.Throwable
Invokes the server invoker handler with the payload parameter passed.

Parameters:
param -
Returns:
Throws:
java.lang.Throwable

invoke

public java.lang.Object invoke(java.lang.Object param,
                               java.util.Map metadata)
                        throws java.lang.Throwable
invoke the method remotely

Parameters:
param - - payload for the server invoker handler
metadata - - any extra metadata that may be needed by the transport (i.e. GET or POST if using http invoker) or if need to pass along extra data to the server invoker handler.
Returns:
Throws:
java.lang.Throwable

invokeOneway

public void invokeOneway(java.lang.Object param,
                         java.util.Map sendPayload,
                         boolean clientSide)
                  throws java.lang.Throwable
Will invoke a oneway call to server without a return object. This should be used when not expecting a return value from the server and wish to achieve higher performance, since the client will not wait for a return. This is done one of two ways. The first is to pass true as the clientSide param. This will cause the execution of the remote call to be excuted in a new thread on the client side and will return the calling thread before making call to server side. Although, this is optimal for performance, will not know about any problems contacting server.

The second, is to pass false as the clientSide param. This will allow the current calling thread to make the call to the remote server, at which point, the server side processing of the thread will be executed on the remote server in a new executing thread and the client thread will return. This is a little slower, but will know that the call made it to the server.

Parameters:
param -
sendPayload -
clientSide -
Throws:
java.lang.Throwable

invokeOneway

public void invokeOneway(java.lang.Object param,
                         java.util.Map sendPayload)
                  throws java.lang.Throwable
Same as calling invokeOneway(Object param, Map sendPayload, boolean clientSide) with clientSide param being false. Therefore, client thread will not return till it has made remote call.

Parameters:
param -
sendPayload -
Throws:
java.lang.Throwable

addListener

public void addListener(InvokerCallbackHandler (src)  callbackHandler)
                 throws java.lang.Throwable
Adds the specified handler as a callback listener for pull (sync) callbacks. The invoker server will then collect the callbacks for this specific handler. The callbacks can be retrieved by calling the getCallbacks() method. Note: this will cause the client invoker's client locator to be set to null.

Parameters:
callbackHandler -
Throws:
java.lang.Throwable

addListener

public void addListener(InvokerCallbackHandler (src)  callbackHandler,
                        InvokerLocator (src)  clientLocator)
                 throws java.lang.Throwable
Adds the specified handler as a callback listener for push (async) callbacks. The invoker server will then callback on this handler (via the server invoker specified by the clientLocator) when it gets a callback from the server handler. Note: passing a null clientLocator will cause the client invoker's client locator to be set to null.

Parameters:
callbackHandler -
clientLocator -
Throws:
java.lang.Throwable

addListener

public void addListener(InvokerCallbackHandler (src)  callbackHandler,
                        InvokerLocator (src)  clientLocator,
                        java.lang.Object callbackHandlerObject)
                 throws java.lang.Throwable
Adds the specified handler as a callback listener for push (async) callbacks. The invoker server will then callback on this handler (via the server invoker specified by the clientLocator) when it gets a callback from the server handler. Note: passing a null clientLocator will cause the client invoker's client locator to be set to null.

Parameters:
callbackHandler - interface to call on with callback
clientLocator - locator for callback server to callback on
callbackHandlerObject - will be included in the callback object passed upon callback
Throws:
java.lang.Throwable

removeListener

public void removeListener(InvokerCallbackHandler (src)  callbackHandler)
                    throws java.lang.Throwable
Removes callback handler as a callback listener from the server (and client in the case that it was setup to receive async callbacks). See addListener().

Parameters:
callbackHandler -
Throws:
java.lang.Throwable

getCallbacks

public java.util.List getCallbacks()
                            throws java.lang.Throwable
Throws:
java.lang.Throwable

setMarshaller

public void setMarshaller(Marshaller (src)  marshaller)

setUnMarshaller

public void setUnMarshaller(UnMarshaller (src)  unmarshaller)