org.openejb.core.ivm
Class EjbHomeProxyHandler

java.lang.Object
  extended by org.openejb.core.ivm.BaseEjbProxyHandler
      extended by org.openejb.core.ivm.EjbHomeProxyHandler
All Implemented Interfaces:
java.io.Serializable, InvocationHandler
Direct Known Subclasses:
EntityEjbHomeHandler, StatefulEjbHomeHandler, StatelessEjbHomeHandler

public abstract class EjbHomeProxyHandler
extends BaseEjbProxyHandler

This is an InvocationHandler that is used only for handling requests from an EJBHome stub. The EjbHomeProxyHandler handles all in-VM requests from the EJBHome stub. The EjbHomeProxyHandler is different from the EjbObjectProxyHandler in that it does not need to be synchronized. One instance of the EjbHomeProxyHandler can be used by all instances of the EJBObject stub in the same VM as the bean deployment they represent. This InvocationHandler and its proxy are serializable and can be used by HomeHandle, Handle, and MetaData to persist and revive handles to the EJBHome. It maintains its original client identity which allows the container to be more discerning about allowing the revieed proxy to be used. See StatefulContainer manager for more details.

Author:
David Blevins, Richard Monson-Haefel
See Also:
EjbObjectProxyHandler, StatefulContainer, Serialized Form

Field Summary
protected static org.apache.log4j.Category logger
           
 
Fields inherited from class org.openejb.core.ivm.BaseEjbProxyHandler
container, deploymentID, deploymentInfo, doIntraVmCopy, inProxyMap, isInvalidReference, liveHandleRegistry, primaryKey
 
Constructor Summary
EjbHomeProxyHandler(RpcContainer container, java.lang.Object pk, java.lang.Object depID)
          Constructs an EjbHomeProxyHandler to handle invocations from an EJBHome stub/proxy.
 
Method Summary
protected  java.lang.Object _invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Overridden by subclasses and called by BaseEjbProxyHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]).
protected  java.lang.Object _writeReplace(java.lang.Object proxy)
          The writeReplace method is invoked on the proxy when it enters the serialization process.
protected  java.lang.Object create(java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object proxy)
           Creates a new EJBObject and returns it to the caller.
protected  java.lang.Object createProxy(ProxyInfo proxyInfo)
           
protected abstract  java.lang.Object findX(java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object proxy)
           Locates and returns a new EJBObject or a collection of EJBObjects.
protected  java.lang.Object getEJBMetaData(java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object proxy)
           Returns an EJBMetaData implementation that is valid inside this virtual machine.
protected  java.lang.Object getHomeHandle(java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object proxy)
           Returns a HomeHandle implementation that is valid inside this virtual machine.
 ProxyInfo getProxyInfo()
           
 void invalidateReference()
          Invalidates this reference so that it can not be used as a proxy for the bean identity.
protected abstract  EjbObjectProxyHandler newEjbObjectHandler(RpcContainer container, java.lang.Object pk, java.lang.Object depID)
           
protected abstract  java.lang.Object removeByPrimaryKey(java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object proxy)
           Attempts to remove an EJBObject from the container system.
protected  java.lang.Object removeWithHandle(java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object proxy)
           Attempts to remove an EJBObject from the container system.
 
Methods inherited from class org.openejb.core.ivm.BaseEjbProxyHandler
checkAuthorization, copyArgs, copyObj, equals, getThreadSpecificSecurityIdentity, hashCode, invalidateAllHandlers, invoke, isLocal, registerHandler, setIntraVmCopyMode, setLocal, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Category logger
Constructor Detail

EjbHomeProxyHandler

public EjbHomeProxyHandler(RpcContainer container,
                           java.lang.Object pk,
                           java.lang.Object depID)
Constructs an EjbHomeProxyHandler to handle invocations from an EJBHome stub/proxy.

Parameters:
container - The Container that the bean deployment this stub hanlder represents is deployed in.
pk - The primary key of the bean deployment or null if the deployment is a bean type that doesn't require a primary key.
depID - The unique id of the bean deployment that this stub handler will represent.
Method Detail

invalidateReference

public void invalidateReference()
Description copied from class: BaseEjbProxyHandler
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.

Overrides:
invalidateReference in class BaseEjbProxyHandler

createProxy

protected java.lang.Object createProxy(ProxyInfo proxyInfo)

newEjbObjectHandler

protected abstract EjbObjectProxyHandler newEjbObjectHandler(RpcContainer container,
                                                             java.lang.Object pk,
                                                             java.lang.Object depID)

_invoke

protected java.lang.Object _invoke(java.lang.Object proxy,
                                   java.lang.reflect.Method method,
                                   java.lang.Object[] args)
                            throws java.lang.Throwable
Description copied from class: BaseEjbProxyHandler
Overridden by subclasses and called by BaseEjbProxyHandler.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.

Specified by:
_invoke in class BaseEjbProxyHandler
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:
java.lang.Throwable

create

protected java.lang.Object create(java.lang.reflect.Method method,
                                  java.lang.Object[] args,
                                  java.lang.Object proxy)
                           throws java.lang.Throwable

Creates a new EJBObject and returns it to the caller. The EJBObject is a new proxy with a new handler. This implementation should not be sent outside the virtual machine.

This method propogates to the container system.

The create method is required to be defined by the bean's home interface.

Parameters:
method -
args -
proxy -
Returns:
Returns an new EJBObject proxy and handler
Throws:
java.lang.Throwable

findX

protected abstract java.lang.Object findX(java.lang.reflect.Method method,
                                          java.lang.Object[] args,
                                          java.lang.Object proxy)
                                   throws java.lang.Throwable

Locates and returns a new EJBObject or a collection of EJBObjects. The EJBObject(s) is a new proxy with a new handler. This implementation should not be sent outside the virtual machine.

This method propogates to the container system.

The find method is required to be defined by the bean's home interface of Entity beans.

Parameters:
method -
args -
proxy -
Returns:
Returns an new EJBObject proxy and handler
Throws:
java.lang.Throwable

getEJBMetaData

protected java.lang.Object getEJBMetaData(java.lang.reflect.Method method,
                                          java.lang.Object[] args,
                                          java.lang.Object proxy)
                                   throws java.lang.Throwable

Returns an EJBMetaData implementation that is valid inside this virtual machine. This implementation should not be sent outside the virtual machine.

This method does not propogate to the container system.

getMetaData is a method of javax.ejb.EJBHome

Checks if the caller is authorized to invoke the javax.ejb.EJBHome.getMetaData on the EJBHome of the deployment.

Returns:
Returns an IntraVmMetaData
Throws:
java.lang.Throwable
See Also:
IntraVmMetaData, EJBHome, EJBHome.getEJBMetaData()

getHomeHandle

protected java.lang.Object getHomeHandle(java.lang.reflect.Method method,
                                         java.lang.Object[] args,
                                         java.lang.Object proxy)
                                  throws java.lang.Throwable

Returns a HomeHandle implementation that is valid inside this virtual machine. This implementation should not be sent outside the virtual machine.

This method does not propogate to the container system.

getHomeHandle is a method of javax.ejb.EJBHome

Checks if the caller is authorized to invoke the javax.ejb.EJBHome.getHomeHandle on the EJBHome of the deployment.

Parameters:
proxy -
Returns:
Returns an IntraVmHandle
Throws:
java.lang.Throwable
See Also:
IntraVmHandle, EJBHome, EJBHome.getHomeHandle()

getProxyInfo

public ProxyInfo getProxyInfo()
Specified by:
getProxyInfo in class BaseEjbProxyHandler

_writeReplace

protected java.lang.Object _writeReplace(java.lang.Object proxy)
                                  throws java.io.ObjectStreamException
The writeReplace method is invoked on the proxy when it enters the serialization process. The call is passed to the handler, then delegated to this method. If the proxy is being copied between bean instances in a RPC call we use the IntraVmArtifact. This object is immutable and does not need to be dereferenced; therefore, we have no need to actually serialize this object. If the proxy is referenced by a stateful bean that is being passivated by the container we allow this object to be serialized. If the proxy is being serialized in any other context, we know that its destination is outside the core container system. This is the responsibility of the Application Server and one of its proxies is serialized to the stream in place of the IntraVmProxy.

Specified by:
_writeReplace in class BaseEjbProxyHandler
Parameters:
proxy -
Returns:
Object
Throws:
java.io.ObjectStreamException

removeWithHandle

protected java.lang.Object removeWithHandle(java.lang.reflect.Method method,
                                            java.lang.Object[] args,
                                            java.lang.Object proxy)
                                     throws java.lang.Throwable

Attempts to remove an EJBObject from the container system. The EJBObject to be removed is represented by the javax.ejb.Handle object passed into the remove method in the EJBHome.

This method propogates to the container system.

remove(Handle handle) is a method of javax.ejb.EJBHome

Checks if the caller is authorized to invoke the javax.ejb.EJBHome.remove on the EJBHome of the deployment.

TODO: this method relies on the fact that the handle implementation is a subclass of IntraVM handle, which isn't neccessarily the case for arbitrary remote protocols. Also, for all other but IntraVM handles, the stub invalidation doesn't currently work.

Parameters:
method -
args -
Returns:
Returns null
Throws:
java.lang.Throwable
See Also:
EJBHome, EJBHome.remove(javax.ejb.Handle)

removeByPrimaryKey

protected abstract java.lang.Object removeByPrimaryKey(java.lang.reflect.Method method,
                                                       java.lang.Object[] args,
                                                       java.lang.Object proxy)
                                                throws java.lang.Throwable

Attempts to remove an EJBObject from the container system. The EJBObject to be removed is represented by the primaryKey passed into the remove method of the EJBHome.

This method propogates to the container system.

remove(Object primary) is a method of javax.ejb.EJBHome

Checks if the caller is authorized to invoke the javax.ejb.EJBHome.remove on the EJBHome of the deployment.

Parameters:
method -
args -
Returns:
Returns null
Throws:
java.lang.Throwable
See Also:
EJBHome, EJBHome.remove(javax.ejb.Handle)


Copyright © 1999-2011 OpenEJB. All Rights Reserved.