org.jboss.remoting
Class Client

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

public class Client
extends Object

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

Version:
$Revision: 1.18 $
Author:
Jeff Haynie, Tom Elrod

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 String RAW
           
 
Constructor Summary
Client(ClassLoader cl, ClientInvoker invoker, String subsystem)
           
Client(ClassLoader cl, InvokerLocator locator, String subsystem)
           
Client(InvokerLocator locator)
           
Client(InvokerLocator locator, String subsystem)
           
 
Method Summary
 void addListener(InvokerCallbackHandler callbackHandler)
          Adds the specified handler as a callback listener for pull (sync) callbacks.
 void addListener(InvokerCallbackHandler callbackHandler, InvokerLocator clientLocator)
          Adds the specified handler as a callback listener for push (async) callbacks.
 void addListener(InvokerCallbackHandler callbackHandler, InvokerLocator clientLocator, Object callbackHandlerObject)
          Adds the specified handler as a callback listener for push (async) callbacks.
 void connect()
           
 void disconnect()
           
 List getCallbacks()
           
 ClientInvoker getInvoker()
           
 String getSessionId()
           
 String getSubsystem()
           
 Object invoke(Object param)
          Invokes the server invoker handler with the payload parameter passed.
 Object invoke(Object param, Map metadata)
          invoke the method remotely
 void invokeOneway(Object param, Map sendPayload)
          Same as calling invokeOneway(Object param, Map sendPayload, boolean clientSide) with clientSide param being false.
 void invokeOneway(Object param, Map sendPayload, boolean clientSide)
          Will invoke a oneway call to server without a return object.
 boolean isConnected()
           
 void removeListener(InvokerCallbackHandler 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 invoker)
           
 void setMarshaller(Marshaller marshaller)
           
 void setSessionId(String sessionId)
          This will set the session id used when making invocations on server invokers.
 void setSubsystem(String subsystem)
           
 void setUnMarshaller(UnMarshaller 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

RAW

public static final String RAW
See Also:
Constant Field Values
Constructor Detail

Client

public Client(InvokerLocator locator)
       throws Exception

Client

public Client(InvokerLocator locator,
              String subsystem)
       throws Exception

Client

public Client(ClassLoader cl,
              InvokerLocator locator,
              String subsystem)
       throws Exception

Client

public Client(ClassLoader cl,
              ClientInvoker invoker,
              String subsystem)
       throws Exception
Method Detail

setSessionId

public void setSessionId(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 String getSessionId()

isConnected

public boolean isConnected()

connect

public void connect()
             throws Exception
Throws:
Exception

disconnect

public void disconnect()

getInvoker

public ClientInvoker getInvoker()

setInvoker

public void setInvoker(ClientInvoker invoker)

getSubsystem

public String getSubsystem()

setSubsystem

public void setSubsystem(String subsystem)

invoke

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

Parameters:
param -
Returns:
Throws:
Throwable

invoke

public Object invoke(Object param,
                     Map metadata)
              throws 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:
Throwable

invokeOneway

public void invokeOneway(Object param,
                         Map sendPayload,
                         boolean clientSide)
                  throws 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:
Throwable

invokeOneway

public void invokeOneway(Object param,
                         Map sendPayload)
                  throws 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:
Throwable

addListener

public void addListener(InvokerCallbackHandler callbackHandler)
                 throws 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:
Throwable

addListener

public void addListener(InvokerCallbackHandler callbackHandler,
                        InvokerLocator clientLocator)
                 throws 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:
Throwable

addListener

public void addListener(InvokerCallbackHandler callbackHandler,
                        InvokerLocator clientLocator,
                        Object callbackHandlerObject)
                 throws 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:
Throwable

removeListener

public void removeListener(InvokerCallbackHandler callbackHandler)
                    throws 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:
Throwable

getCallbacks

public List getCallbacks()
                  throws Throwable
Throws:
Throwable

setMarshaller

public void setMarshaller(Marshaller marshaller)

setUnMarshaller

public void setUnMarshaller(UnMarshaller unmarshaller)


Copyright © 2004 JBoss Inc. All Rights Reserved.