org.openejb.client
Class EJBInvocationHandler

java.lang.Object
  extended byorg.openejb.client.EJBInvocationHandler
All Implemented Interfaces:
net.sf.cglib.proxy.Callback, InvocationHandler, net.sf.cglib.proxy.MethodInterceptor, RequestMethods, ResponseCodes, Serializable
Direct Known Subclasses:
EJBHomeHandler, EJBObjectHandler

public abstract class EJBInvocationHandler
extends Object
implements net.sf.cglib.proxy.MethodInterceptor, InvocationHandler, Serializable, ResponseCodes, RequestMethods

TODO: Add comments

See Also:
Serialized Form

Field Summary
protected  EJBMetaDataImpl ejb
          The EJBMetaDataImpl object of the bean deployment that this invocation handler represents.
protected static Method EQUALS
           
protected static Method HASHCODE
           
protected  boolean inProxyMap
          TODO: Add comments
protected  boolean isInvalidReference
          TODO: Add comments
protected static Hashtable liveHandleRegistry
          Keeps track of live EJBInvocationHandler in this VM.
protected  Object primaryKey
          The primary key of the bean deployment or null if the deployment is a bean type that doesn't require a primary key
protected  EJBRequest request
          TODO: Add comments
protected  ServerMetaData server
          The ServerMetaData object containing the information needed to send invokations to the EJB Server.
protected static Method TOSTRING
           
 
Fields inherited from interface org.openejb.client.ResponseCodes
AUTH_DENIED, AUTH_GRANTED, AUTH_REDIRECT, EJB_APP_EXCEPTION, EJB_ERROR, EJB_OK, EJB_OK_CREATE, EJB_OK_FOUND, EJB_OK_FOUND_COLLECTION, EJB_OK_FOUND_ENUMERATION, EJB_OK_NOT_FOUND, EJB_SYS_EXCEPTION, JNDI_CONTEXT, JNDI_EJBHOME, JNDI_ENUMERATION, JNDI_ERROR, JNDI_NAMING_EXCEPTION, JNDI_NOT_FOUND, JNDI_OK, JNDI_RUNTIME_EXCEPTION
 
Fields inherited from interface org.openejb.client.RequestMethods
AUTH_REQUEST, EJB_HOME_CREATE, EJB_HOME_FIND, EJB_HOME_GET_EJB_META_DATA, EJB_HOME_GET_HOME_HANDLE, EJB_HOME_REMOVE_BY_HANDLE, EJB_HOME_REMOVE_BY_PKEY, EJB_OBJECT_BUSINESS_METHOD, EJB_OBJECT_GET_EJB_HOME, EJB_OBJECT_GET_HANDLE, EJB_OBJECT_GET_PRIMARY_KEY, EJB_OBJECT_IS_IDENTICAL, EJB_OBJECT_REMOVE, EJB_REQUEST, JNDI_LIST, JNDI_LIST_BINDINGS, JNDI_LOOKUP, JNDI_REQUEST, STOP_REQUEST_quit, STOP_REQUEST_Quit, STOP_REQUEST_stop, STOP_REQUEST_Stop
 
Constructor Summary
EJBInvocationHandler()
          TODO: Add comments
EJBInvocationHandler(EJBMetaDataImpl ejb, ServerMetaData server)
           
EJBInvocationHandler(EJBMetaDataImpl ejb, ServerMetaData server, Object primaryKey)
           
 
Method Summary
protected abstract  Object _invoke(Object proxy, Method method, Object[] args)
          Overridden by subclasses and called by invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]).
protected static Method getMethod(Class c, String method, Class[] params)
           
 Object intercept(Object proxy, Method method, Object[] args, net.sf.cglib.proxy.MethodProxy mProxy)
           
protected static void invalidateAllHandlers(Object key)
          TODO: Add comments
protected  void invalidateReference()
          Invalidates this reference so that it can not be used as a proxy for the bean identity.
 Object invoke(Object proxy, Method method, Object[] args)
          TODO: Add comments
static void print(String s)
           
static void println(String s)
           
protected static void registerHandler(Object key, EJBInvocationHandler handler)
          TODO: Add comments
protected  EJBResponse request(EJBRequest req)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUALS

protected static final Method EQUALS

HASHCODE

protected static final Method HASHCODE

TOSTRING

protected static final Method TOSTRING

liveHandleRegistry

protected static Hashtable liveHandleRegistry
Keeps track of live EJBInvocationHandler in this VM. So that related handlers can be removed if necessary. Currently this registry is only used to track live EJBInvocationHandlers. The EJBObjectHandlers are tracked to allow remove() operations and invalidate exceptions to be propagated to the proper handler instances. There are several scenarios where this is useful:

inProxyMap

protected transient boolean inProxyMap
TODO: Add comments


isInvalidReference

protected transient boolean isInvalidReference
TODO: Add comments


request

protected transient EJBRequest request
TODO: Add comments


ejb

protected transient EJBMetaDataImpl ejb
The EJBMetaDataImpl object of the bean deployment that this invocation handler represents.


server

protected transient ServerMetaData server
The ServerMetaData object containing the information needed to send invokations to the EJB Server.


primaryKey

protected transient Object primaryKey
The primary key of the bean deployment or null if the deployment is a bean type that doesn't require a primary key

Constructor Detail

EJBInvocationHandler

public EJBInvocationHandler()
TODO: Add comments


EJBInvocationHandler

public EJBInvocationHandler(EJBMetaDataImpl ejb,
                            ServerMetaData server)

EJBInvocationHandler

public EJBInvocationHandler(EJBMetaDataImpl ejb,
                            ServerMetaData server,
                            Object primaryKey)
Method Detail

getMethod

protected static Method getMethod(Class c,
                                  String method,
                                  Class[] params)

intercept

public Object intercept(Object proxy,
                        Method method,
                        Object[] args,
                        net.sf.cglib.proxy.MethodProxy mProxy)
                 throws Throwable
Specified by:
intercept in interface net.sf.cglib.proxy.MethodInterceptor
Throws:
Throwable

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
TODO: Add comments

Specified by:
invoke in interface InvocationHandler
Parameters:
proxy - The Proxy object that represents this bean deployment's EJBObject or EJBHome.
method - The EJBHome or EJBObject method the caller is invoking.
args - The parameters to the mehtod being invoked
Returns:
The result of invoking the appropriate method on the bean instance.
Throws:
Throwable

_invoke

protected abstract Object _invoke(Object proxy,
                                  Method method,
                                  Object[] args)
                           throws Throwable
Overridden by subclasses and called by invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]). Subclasses implement the main behavior of calling invoke on the Container that the bean deployment lives in.

Parameters:
proxy - The Proxy subclass that is the bean's EJBObject or EJBHome.
method - The bean method that the caller is attempting to invoke.
args - The arguments to the method being invoked.
Returns:
The result of invoking the appropriate method on the bean instance.
Throws:
Throwable

print

public static void print(String s)

println

public static void println(String s)

request

protected EJBResponse request(EJBRequest req)
                       throws Exception
Throws:
Exception

invalidateReference

protected void invalidateReference()
Invalidates this reference so that it can not be used as a proxy for the bean identity. This method may be called when an InvalidateReferenceException is thrown by the container or when the bean identity associated with this proxy is explicitly removed, by calling one of the remove( ) methods.


invalidateAllHandlers

protected static void invalidateAllHandlers(Object key)
TODO: Add comments

Parameters:
key -

registerHandler

protected static void registerHandler(Object key,
                                      EJBInvocationHandler handler)
TODO: Add comments

Parameters:
key -
handler -


Copyright © 1999-2005 OpenEJB. All Rights Reserved.