com.retrogui.dualrpc.common
Class RpcWorker

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.retrogui.dualrpc.common.RpcWorker
All Implemented Interfaces:
IDualRpcMessageConstants, java.lang.Runnable

public class RpcWorker
extends java.lang.Thread
implements IDualRpcMessageConstants

This is Lipe's enhanced worker that executes a remote procedure call. Results are returned via a result object. The worker uses reflection to locate and execute the approprate method. Lipe's enhancement adds flexibility because it permits a handler method to be called if the incoming parameter values are assignable subtypes of the method parameters.


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
RpcWorker(IRpcMessageDispatcher dispatcher, Message message)
          Creates a new RpcWorker object.
 
Method Summary
 java.lang.String buildFaultErrorMessage(long sessionId, java.lang.Throwable t)
          Construct the fault error message that is returned to the caller
 java.lang.reflect.Method findMethod(java.lang.Class klass, java.lang.String methodName, java.lang.Class[] parameterClasses)
          Find a matching method.
 IRpcMessageDispatcher getDispatcher()
          getter
 Message getMessage()
          getter
 void processRpcCallMessage(Message message)
          Do the rpc call.
 void processRpcResultMessage(Message message, java.lang.String payloadType)
          Process a result message.
 void run()
          Locate and execute the handler method, then exit.
 void sendFaultMessage(java.lang.String originatingRpcCallMessageId, java.lang.String errorMessage)
          Create and send a fault message
 void setDispatcher(IRpcMessageDispatcher dispatcher)
          setter
 void setMessage(Message message)
          setter
 
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
 

Constructor Detail

RpcWorker

public RpcWorker(IRpcMessageDispatcher dispatcher,
                 Message message)
Creates a new RpcWorker object.

Parameters:
dispatcher -
message -
Method Detail

run

public void run()
Locate and execute the handler method, then exit.

Specified by:
run in interface java.lang.Runnable

processRpcCallMessage

public void processRpcCallMessage(Message message)
                           throws SessionException
Do the rpc call. Uses reflection to get and call the specified handler method. Note that if an exception occurs and a fault message is returned to the caller some error information is embedded in the returning message. The caller can parse the exception string. See buildFaultErrorMessage() for the error message XML format.

Parameters:
message -
Throws:
SessionException

buildFaultErrorMessage

public java.lang.String buildFaultErrorMessage(long sessionId,
                                               java.lang.Throwable t)
Construct the fault error message that is returned to the caller

Parameters:
sessionId -
t -
Returns:

processRpcResultMessage

public void processRpcResultMessage(Message message,
                                    java.lang.String payloadType)
                             throws RpcException
Process a result message. The message is either a result or a fault. Put the result message in the container that matches the origininating (outbound) rpc message id.

Parameters:
message -
payloadType -
Throws:
RpcException

getDispatcher

public IRpcMessageDispatcher getDispatcher()
getter

Returns:

setDispatcher

public void setDispatcher(IRpcMessageDispatcher dispatcher)
setter

Parameters:
dispatcher -

getMessage

public Message getMessage()
getter

Returns:

setMessage

public void setMessage(Message message)
setter

Parameters:
message -

sendFaultMessage

public void sendFaultMessage(java.lang.String originatingRpcCallMessageId,
                             java.lang.String errorMessage)
                      throws SessionException
Create and send a fault message

Parameters:
originatingRpcCallMessageId -
errorMessage -
Throws:
SessionException

findMethod

public java.lang.reflect.Method findMethod(java.lang.Class klass,
                                           java.lang.String methodName,
                                           java.lang.Class[] parameterClasses)
Find a matching method. If an exact parameter match is not found the compare the parameter values to determine if they are assignable subtypes.

Parameters:
klass -
methodName -
parameterClasses -
Returns: