org.objectweb.easybeans.rpc
Class ClientRPCInvocationHandler

java.lang.Object
  extended by org.objectweb.easybeans.rpc.AbsInvocationHandler
      extended by org.objectweb.easybeans.rpc.ClientRPCInvocationHandler
All Implemented Interfaces:
java.io.Serializable, java.lang.reflect.InvocationHandler

public class ClientRPCInvocationHandler
extends AbsInvocationHandler

This class sends an EJB request to the server and send back to the client the response.

Author:
Florent Benoit
See Also:
Serialized Form

Field Summary
private  java.util.Hashtable<?,?> rmiClientEnvironment
          Environment used by the client when lookup on proxy object has be done.
private static long serialVersionUID
          Id for serializable class.
 
Constructor Summary
ClientRPCInvocationHandler(java.lang.String containerId, java.lang.String factoryName, boolean useID)
          Build a new Invocation handler.
 
Method Summary
private  java.lang.Throwable convertThrowable(java.lang.Throwable throwable)
          Convert the received exception to the correct type for the remote case.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Processes a method invocation on a proxy instance and returns the result.
 void setRMIEnv(java.util.Hashtable<?,?> rmiClientEnvironment)
          Set the RMI environment used by the client when the lookup has been done.
 
Methods inherited from class org.objectweb.easybeans.rpc.AbsInvocationHandler
getBeanId, getContainerId, getFactoryName, getHashedMethods, getInterfaceClassName, handleObjectMethods, handleThrowable, isExtendingRmiRemote, isRemoved, isUsingID, setBeanId, setContainerId, setExtendingRmiRemote, setFactoryName, setHashedMethods, setInterfaceClass, setInterfaceClassName, setRemoved, setUseID, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Id for serializable class.

See Also:
Constant Field Values

rmiClientEnvironment

private java.util.Hashtable<?,?> rmiClientEnvironment
Environment used by the client when lookup on proxy object has be done. This will be set by the Remote Factory.

Constructor Detail

ClientRPCInvocationHandler

public ClientRPCInvocationHandler(java.lang.String containerId,
                                  java.lang.String factoryName,
                                  boolean useID)
Build a new Invocation handler.

Parameters:
containerId - the id of the container that will be called on the remote side.
factoryName - the name of the remote factory.
useID - true if all instance build with this ref are unique (stateful), false if it references the same object (stateless)
Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Exception
Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters:
proxy - the proxy instance that the method was invoked on
method - the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
args - an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
Returns:
the value to return from the method invocation on the proxy instance.
Throws:
java.lang.Exception - the exception to throw from the method invocation on the proxy instance.

convertThrowable

private java.lang.Throwable convertThrowable(java.lang.Throwable throwable)
Convert the received exception to the correct type for the remote case.

Parameters:
throwable - the exception to analyze.
Returns:
the converted exception or the original exception

setRMIEnv

public void setRMIEnv(java.util.Hashtable<?,?> rmiClientEnvironment)
Set the RMI environment used by the client when the lookup has been done.

Parameters:
rmiClientEnvironment - the given environment.