org.objectweb.easybeans.rpc
Class LocalCallInvocationHandler

java.lang.Object
  extended by org.objectweb.easybeans.rpc.AbsInvocationHandler
      extended by org.objectweb.easybeans.rpc.LocalCallInvocationHandler
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.reflect.InvocationHandler
Direct Known Subclasses:
EJBLocalHomeInvocationHandler

public class LocalCallInvocationHandler
extends AbsInvocationHandler
implements java.io.Externalizable

Object acting as the proxy for local interfaces calls.

Author:
Florent Benoit
See Also:
Serialized Form

Field Summary
private  java.lang.Integer embeddedID
          Embedded server ID.
private  Factory factory
          Factory for sending requests (build in constructor or when serialization occurs).
private  boolean isExtendingEJBLocalObject
          Boolean used to know if this class extends javax.ejb.EJBLocalObject class.
private static long serialVersionUID
          UID for serialization.
 
Constructor Summary
LocalCallInvocationHandler()
          Default constructor (used for serialization).
LocalCallInvocationHandler(java.lang.Integer embeddedID, java.lang.String containerId, java.lang.String factoryName, boolean useID)
          Build a new Invocation handler.
 
Method Summary
protected  java.lang.Throwable convertThrowable(java.lang.Throwable throwable)
          Convert the received exception to the correct type for the remote case.
protected  java.lang.Integer getEmbeddedID()
          Gets the embedded ID.
private  void initFactory()
          Initialize the factory object with the given infos.
 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 readExternal(java.io.ObjectInput in)
          Build our content.
 void setInterfaceClass(java.lang.Class clz)
          Sets the interface that represents this handler.
 void writeExternal(java.io.ObjectOutput out)
          Save our content.
 
Methods inherited from class org.objectweb.easybeans.rpc.AbsInvocationHandler
getBeanId, getContainerId, getFactoryName, getHashedMethods, getInterfaceClassName, handleObjectMethods, handleThrowable, isExtendingRmiRemote, isRemoved, isUsingID, setBeanId, setContainerId, setExtendingRmiRemote, setFactoryName, setHashedMethods, 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
UID for serialization.

See Also:
Constant Field Values

embeddedID

private java.lang.Integer embeddedID
Embedded server ID.


factory

private transient Factory factory
Factory for sending requests (build in constructor or when serialization occurs).


isExtendingEJBLocalObject

private boolean isExtendingEJBLocalObject
Boolean used to know if this class extends javax.ejb.EJBLocalObject class.

Constructor Detail

LocalCallInvocationHandler

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

Parameters:
embeddedID - the Embedded server ID.
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)

LocalCallInvocationHandler

public LocalCallInvocationHandler()
Default constructor (used for serialization).

Method Detail

initFactory

private void initFactory()
Initialize the factory object with the given infos.


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.

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
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.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Save our content.

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - the stream to write the object to
Throws:
java.io.IOException - Includes any I/O exceptions that may occur

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Build our content.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - the stream to read data from in order to restore the object
Throws:
java.io.IOException - if I/O errors occur
java.lang.ClassNotFoundException - If the class for an object being restored cannot be found.

getEmbeddedID

protected java.lang.Integer getEmbeddedID()
Gets the embedded ID.

Returns:
the embedded ID.

setInterfaceClass

public void setInterfaceClass(java.lang.Class clz)
Sets the interface that represents this handler.

Overrides:
setInterfaceClass in class AbsInvocationHandler
Parameters:
clz - the instance of the interface.

convertThrowable

protected 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