com.retrogui.dualrpc.server
Class DualRpcServerDispatcher

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.retrogui.messageserver.server.AbstractServerApplication
          extended bycom.retrogui.dualrpc.server.DualRpcServerDispatcher
All Implemented Interfaces:
IDualRpcMessageConstants, IRpcMessageDispatcher, java.lang.Runnable

public class DualRpcServerDispatcher
extends AbstractServerApplication
implements IRpcMessageDispatcher, IDualRpcMessageConstants

Dispatcher for incoming client messages. Each new connection gets its own dispatcher.


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface com.retrogui.dualrpc.common.IDualRpcMessageConstants
DEFAULT_RPC_CALL_TIMEOUT, PAYLOAD_TYPE_RPC_CALL, PAYLOAD_TYPE_RPC_FAULT, PAYLOAD_TYPE_RPC_RESULT, RPC_FAULTCODE_EXCEPTION
 
Constructor Summary
DualRpcServerDispatcher(MessageServer messageServer, Session session, java.lang.Object serverHandlerConfigurationObject)
          Creates a new DualRpcServerDispatcher object.
 
Method Summary
 java.lang.Object call(java.lang.String handlerClassName, java.lang.String methodName)
          Call a remote method with no parameters.
 java.lang.Object call(java.lang.String handlerClassName, java.lang.String methodName, java.util.ArrayList parameters)
          Call a remote method with an unlimited number of parameters (passed via an ArrayList).
 java.lang.Object call(java.lang.String handlerClassName, java.lang.String methodName, boolean hasResults, int callTimeoutInSeconds, java.util.ArrayList parameters)
          Primary call method.
 java.lang.Object call(java.lang.String handlerClassName, java.lang.String methodName, int callTimeoutInSeconds, java.util.ArrayList parameters)
          Call a remote method with an unlimited number of parameters (passed via an ArrayList).
 java.lang.Object call(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1)
          Call a remote method with one parameter.
 java.lang.Object call(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1, java.lang.Object p2)
          Call a remote method with two parameters.
 java.lang.Object call(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)
          Call a remote method with three parameters.
 java.lang.Object call(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4)
          Call a remote method with four parameters.
 java.lang.Object call(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5)
          Call a remote method with five parameters.
 void callAsync(java.lang.String handlerClassName, java.lang.String methodName)
          Asynchronously call a remote method with no parameters.
 void callAsync(java.lang.String handlerClassName, java.lang.String methodName, java.util.ArrayList parameters)
          Asynchronously call a remote method with an unlimited number of parameters (passed via an ArrayList).
 void callAsync(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1)
          Asynchronously call a remote method with one parameter.
 void callAsync(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1, java.lang.Object p2)
          Asynchronously call a remote method with two parameters.
 void callAsync(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)
          Asynchronously call a remote method with three parameters.
 void callAsync(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4)
          Asynchronously call a remote method with four parameters.
 void callAsync(java.lang.String handlerClassName, java.lang.String methodName, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5)
          Asynchronously call a remote method with five parameters.
 void disconnect()
          Disconnect the client connection.
 java.util.Hashtable getCallWaitingRegistry()
          Get for call waiting registry.
 DualRpcServer getDualRpcServer()
          Get the DualRpcServer object.
 IRpcHandler getHandler(java.lang.String handlerClassname)
          Get a server handler by its classname.
 IMethodAccessControl getMethodAccessControl()
          Get the method access control object
 java.lang.String getNextMessageId()
          increment and return the next message sequence
 void run()
          Start the dispatcher thread.
 void setCallbackHandler(IServerCallbackHandler callbackHandler)
          Set the callback handler object, optional.
 
Methods inherited from class com.retrogui.messageserver.server.AbstractServerApplication
getConfigurationObject, getMessage, getMessageServer, getSession, sendMessage
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.retrogui.dualrpc.common.IRpcMessageDispatcher
getSession
 

Constructor Detail

DualRpcServerDispatcher

public DualRpcServerDispatcher(MessageServer messageServer,
                               Session session,
                               java.lang.Object serverHandlerConfigurationObject)
                        throws java.lang.InstantiationException,
                               java.lang.IllegalAccessException,
                               java.lang.ClassNotFoundException,
                               java.lang.NoSuchMethodException,
                               java.lang.reflect.InvocationTargetException
Creates a new DualRpcServerDispatcher object.

Parameters:
messageServer -
session -
serverHandlerConfigurationObject -
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
Method Detail

run

public void run()
Start the dispatcher thread.

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class AbstractServerApplication

call

public java.lang.Object call(java.lang.String handlerClassName,
                             java.lang.String methodName)
                      throws CallException
Call a remote method with no parameters. Default timeout is 60 seconds.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Returns:
- the return object. This return object must then be cast to the appropriate payloadType. For example, if the server handler method returns a string then you must cast the return object as a string.
Throws:
CallException

call

public java.lang.Object call(java.lang.String handlerClassName,
                             java.lang.String methodName,
                             java.lang.Object p1)
                      throws CallException
Call a remote method with one parameter. Default timeout is 60 seconds.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Returns:
- the return object. This return object must then be cast to the appropriate payloadType. For example, if the server handler method returns a string then you must cast the return object as a string.
Throws:
CallException

call

public java.lang.Object call(java.lang.String handlerClassName,
                             java.lang.String methodName,
                             java.lang.Object p1,
                             java.lang.Object p2)
                      throws CallException
Call a remote method with two parameters. Default timeout is 60 seconds.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Returns:
- the return object. This return object must then be cast to the appropriate payloadType. For example, if the server handler method returns a string then you must cast the return object as a string.
Throws:
CallException

call

public java.lang.Object call(java.lang.String handlerClassName,
                             java.lang.String methodName,
                             java.lang.Object p1,
                             java.lang.Object p2,
                             java.lang.Object p3)
                      throws CallException
Call a remote method with three parameters. Default timeout is 60 seconds.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Returns:
- the return object. This return object must then be cast to the appropriate payloadType. For example, if the server handler method returns a string then you must cast the return object as a string.
Throws:
CallException

call

public java.lang.Object call(java.lang.String handlerClassName,
                             java.lang.String methodName,
                             java.lang.Object p1,
                             java.lang.Object p2,
                             java.lang.Object p3,
                             java.lang.Object p4)
                      throws CallException
Call a remote method with four parameters. Default timeout is 60 seconds.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Returns:
- the return object. This return object must then be cast to the appropriate payloadType. For example, if the server handler method returns a string then you must cast the return object as a string.
Throws:
CallException

call

public java.lang.Object call(java.lang.String handlerClassName,
                             java.lang.String methodName,
                             java.lang.Object p1,
                             java.lang.Object p2,
                             java.lang.Object p3,
                             java.lang.Object p4,
                             java.lang.Object p5)
                      throws CallException
Call a remote method with five parameters. Default timeout is 60 seconds.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Returns:
- the return object. This return object must then be cast to the appropriate payloadType. For example, if the server handler method returns a string then you must cast the return object as a string.
Throws:
CallException

callAsync

public void callAsync(java.lang.String handlerClassName,
                      java.lang.String methodName)
               throws CallException
Asynchronously call a remote method with no parameters.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Throws:
CallException

callAsync

public void callAsync(java.lang.String handlerClassName,
                      java.lang.String methodName,
                      java.lang.Object p1)
               throws CallException
Asynchronously call a remote method with one parameter.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Throws:
CallException

callAsync

public void callAsync(java.lang.String handlerClassName,
                      java.lang.String methodName,
                      java.lang.Object p1,
                      java.lang.Object p2)
               throws CallException
Asynchronously call a remote method with two parameters.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Throws:
CallException

callAsync

public void callAsync(java.lang.String handlerClassName,
                      java.lang.String methodName,
                      java.lang.Object p1,
                      java.lang.Object p2,
                      java.lang.Object p3)
               throws CallException
Asynchronously call a remote method with three parameters.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Throws:
CallException

callAsync

public void callAsync(java.lang.String handlerClassName,
                      java.lang.String methodName,
                      java.lang.Object p1,
                      java.lang.Object p2,
                      java.lang.Object p3,
                      java.lang.Object p4)
               throws CallException
Asynchronously call a remote method with four parameters.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Throws:
CallException

callAsync

public void callAsync(java.lang.String handlerClassName,
                      java.lang.String methodName,
                      java.lang.Object p1,
                      java.lang.Object p2,
                      java.lang.Object p3,
                      java.lang.Object p4,
                      java.lang.Object p5)
               throws CallException
Asynchronously call a remote method with five parameters.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
Throws:
CallException

callAsync

public void callAsync(java.lang.String handlerClassName,
                      java.lang.String methodName,
                      java.util.ArrayList parameters)
               throws CallException
Asynchronously call a remote method with an unlimited number of parameters (passed via an ArrayList).

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
parameters - - ArrayList of parameters. The array elements must be in the same order as the method parameters. If the calling method does not have any parameters defined then pass an empty ArrayList to the call(). All array list elements MUST BE SERIALIZABLE.
Throws:
CallException

call

public java.lang.Object call(java.lang.String handlerClassName,
                             java.lang.String methodName,
                             java.util.ArrayList parameters)
                      throws CallException
Call a remote method with an unlimited number of parameters (passed via an ArrayList). Default timeout is 60 seconds.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
parameters - - ArrayList of parameters. The array elements must be in the same order as the method parameters. If the calling method does not have any parameters defined then pass an empty ArrayList to the call(). All array list elements MUST BE SERIALIZABLE.
Returns:
- the return object. This return object must then be cast to the appropriate payloadType. For example, if the server handler method returns a string then you must cast the return object as a string.
Throws:
CallException

call

public java.lang.Object call(java.lang.String handlerClassName,
                             java.lang.String methodName,
                             int callTimeoutInSeconds,
                             java.util.ArrayList parameters)
                      throws CallException
Call a remote method with an unlimited number of parameters (passed via an ArrayList). The timeout is specified.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
callTimeoutInSeconds - - time to wait for a return object. Set to 0 to wait forever.
parameters - - ArrayList of parameters. The array elements must be in the same order as the method parameters. If the calling method does not have any parameters defined then pass an empty ArrayList to the call(). All array list elements MUST BE SERIALIZABLE.
Returns:
- the return object. This return object must then be cast to the appropriate payloadType. For example, if the server handler method returns a string then you must cast the return object as a string.
Throws:
CallException

call

public java.lang.Object call(java.lang.String handlerClassName,
                             java.lang.String methodName,
                             boolean hasResults,
                             int callTimeoutInSeconds,
                             java.util.ArrayList parameters)
                      throws CallException
Primary call method. Call a server-side handler method and wait a specified number of seconds for a return object. This method will wait for the specified length of time before throwing a timeout exception.

Parameters:
handlerClassName - - classname of the client-side handler
methodName - - client-side method name to call
hasResults - - flag to wait for a result object.
callTimeoutInSeconds - - time to wait for a return object. Set to 0 to wait forever.
parameters - - ArrayList of parameters. The array elements must be in the same order as the method parameters. If the calling method does not have any parameters defined then pass an empty ArrayList to the call(). All array list elements MUST BE SERIALIZABLE.
Returns:
- the return object. This return object must then be cast to the appropriate payloadType. For example, if the server handler method returns a string then you must cast the return object as a string.
Throws:
CallException

getHandler

public IRpcHandler getHandler(java.lang.String handlerClassname)
Get a server handler by its classname.

Specified by:
getHandler in interface IRpcMessageDispatcher
Parameters:
handlerClassname -
Returns:
a handler

disconnect

public void disconnect()
Disconnect the client connection.


getDualRpcServer

public DualRpcServer getDualRpcServer()
Get the DualRpcServer object. For internal use.

Returns:

getCallWaitingRegistry

public java.util.Hashtable getCallWaitingRegistry()
Get for call waiting registry.

Specified by:
getCallWaitingRegistry in interface IRpcMessageDispatcher
Returns:

setCallbackHandler

public void setCallbackHandler(IServerCallbackHandler callbackHandler)
Set the callback handler object, optional. A callback handler can be set to process an event triggered when the client disconnects.

Parameters:
callbackHandler -

getNextMessageId

public java.lang.String getNextMessageId()
Description copied from interface: IRpcMessageDispatcher
increment and return the next message sequence

Specified by:
getNextMessageId in interface IRpcMessageDispatcher
Returns:

getMethodAccessControl

public IMethodAccessControl getMethodAccessControl()
Get the method access control object

Specified by:
getMethodAccessControl in interface IRpcMessageDispatcher
Returns:
IMethodAccessControl