| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sourceforge.jemmrpc.shared.RPCHandler
public class RPCHandler
RPCHandler is used to implement the shared logic used by both RPCClient and
 RPCServer. Given a socket RPCHandler basically manages the client and server interfaces,
 the proxies and the actual message passing.
 N.B. A client/server flag is passed to the constructor because ObjectInputStream/ObjectOutputStream
 must be invoked in alternate order on the two sides of the connection or it deadlocks.
| Field Summary | |
|---|---|
| protected  boolean | closing | 
| protected  java.util.concurrent.CountDownLatch | initialisationLatch | 
| protected  java.io.ObjectInputStream | is | 
| protected  RPCHandlerListener | listener | 
| protected  java.io.ObjectOutputStream | os | 
| Constructor Summary | |
|---|---|
| RPCHandler(boolean isClient,
           java.net.Socket socket,
           java.util.Map<java.lang.Class<?>,java.lang.Object> localInterfaces,
           java.util.concurrent.ExecutorService requestExecutor,
           java.lang.Object connectionId)Create an RPCHandler | |
| Method Summary | |
|---|---|
|  void | close()Close the connection to the server. | 
| protected  void | connectionTerminated() | 
| protected  java.lang.Object | createProxyClass(java.lang.Class<?> ifClass) | 
| static java.lang.Object | getConnectionId()Retrieve the connection id object associated with the current processing thread. | 
|  java.lang.Object | getRemoteIF(java.lang.Class<?> ifClass)Returns an local interface for calling the remote interface. | 
| protected  void | makeAsyncCall(java.lang.Class<?> ifClass,
              java.lang.String methodName,
              java.lang.Class<?>[] parameterTypes,
              java.lang.Object[] args)Internal method to make an asynchronous call to a given method. | 
| protected  RPCCallRespMessage | makeSyncCall(java.lang.Class<?> ifClass,
             java.lang.String methodName,
             java.lang.Class<?>[] parameterTypes,
             java.lang.Object[] args)Internal method to make a make a synchronous call to a given method. | 
| protected  void | processCallMessage(RPCCallMessage message)Internal method to handle RPC call method. | 
| protected  void | receiveMessage(Message message) | 
|  void | run() | 
|  Message | sendSyncMessage(Message message)Send a synchronous message to the server. | 
|  void | setHandlerListener(RPCHandlerListener listener)Set the listener for this handler for event notification. | 
|  void | start()Start the RPCHandler. | 
| protected  void | writeMessage(Message message) | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected java.util.concurrent.CountDownLatch initialisationLatch
protected volatile boolean closing
protected java.io.ObjectInputStream is
protected java.io.ObjectOutputStream os
protected RPCHandlerListener listener
| Constructor Detail | 
|---|
public RPCHandler(boolean isClient,
                  java.net.Socket socket,
                  java.util.Map<java.lang.Class<?>,java.lang.Object> localInterfaces,
                  java.util.concurrent.ExecutorService requestExecutor,
                  java.lang.Object connectionId)
isClient - Is this the client side of the connection (false for server)socket - The socket connection.localInterfaces - The interfaces this side offers.requestExecutor - The service to use for running requests.connectionId - The id of the connection.| Method Detail | 
|---|
public void setHandlerListener(RPCHandlerListener listener)
listener - The listener to inform of events.public java.lang.Object getRemoteIF(java.lang.Class<?> ifClass)
ifClass - The interface to get.
java.lang.IllegalArgumentException - If the requested class is not an interface or not supported.protected java.lang.Object createProxyClass(java.lang.Class<?> ifClass)
public void run()
run in interface java.lang.Runnableprotected void receiveMessage(Message message)
protected void processCallMessage(RPCCallMessage message)
message - The message to process.protected void connectionTerminated()
public void close()
protected void writeMessage(Message message)
public Message sendSyncMessage(Message message)
message - The message to send
protected void makeAsyncCall(java.lang.Class<?> ifClass,
                             java.lang.String methodName,
                             java.lang.Class<?>[] parameterTypes,
                             java.lang.Object[] args)
ifClass - The interface class being called.methodName - The method being called.parameterTypes - The parameter types of the methodargs - The actual call arguments (based types wrapped by Proxy.invoke).
protected RPCCallRespMessage makeSyncCall(java.lang.Class<?> ifClass,
                                          java.lang.String methodName,
                                          java.lang.Class<?>[] parameterTypes,
                                          java.lang.Object[] args)
ifClass - The interface class being called.methodName - The method being called.parameterTypes - The parameter types of the methodargs - The actual call arguments (based types wrapped by Proxy.invoke).
public static java.lang.Object getConnectionId()
public void start()
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||