FileDocCategorySizeDatePackage
EJBLocalObjectImpl.javaAPI DocGlassfish v2 API9768Fri May 04 22:32:58 BST 2007com.sun.ejb.containers

EJBLocalObjectImpl

public abstract class EJBLocalObjectImpl extends EJBLocalRemoteObject implements com.sun.ejb.spi.io.IndirectlySerializable, EJBLocalObject
Implementation of the EJBLocalObject interface. This is NOT serializable to prevent local references from leaving the JVM. It is extended by the generated concrete type-specific EJBLocalObject implementation (e.g. Hello_EJBLocalObject).
author
Mahesh Kannan

Fields Summary
private static final Logger
_logger
private static com.sun.enterprise.util.LocalStringManagerImpl
localStrings
private static Class[]
NO_PARAMS
private static Method
REMOVE_METHOD
private boolean
isLocalHomeView
private HashMap
clientObjectMap
Constructors Summary
Methods Summary
protected java.lang.ObjectgetClientObject()
Get the client object corresponding to an EJBLocalObjectImpl. Users of this class cannot assume they can cast an EJBLocalObjectImpl to the object that the client uses, and vice-versa. This is overridden in the InvocationHandler. Only applicable for local home view.

                                                      
       
        return this;
    
java.lang.ObjectgetClientObject(java.lang.String intfClassName)

        return clientObjectMap.get(intfClassName);
    
public EJBLocalHomegetEJBLocalHome()

        container.authorizeLocalMethod(
            BaseContainer.EJBLocalObject_getEJBLocalHome);
        container.checkExists(this);
        
        return container.getEJBLocalHome();
    
public java.lang.ObjectgetPrimaryKey()

        if ( container instanceof EntityContainer ) {
            container.authorizeLocalMethod(
                BaseContainer.EJBLocalObject_getPrimaryKey);
            container.checkExists(this);
            
            return primaryKey;
        }
        else {
            throw new EJBException(localStrings.getLocalString(
            "containers.invalid_operation",
            "Invalid operation for Session EJBs."));
        }
    
public com.sun.ejb.spi.io.SerializableObjectFactorygetSerializableObjectFactory()
Called from EJBUtils.EJBObjectOutputStream.replaceObject

        // Note: for stateful SessionBeans, the EJBLocalObjectImpl contains
        // a pointer to the EJBContext. We should not serialize it here.
        
        return new SerializableLocalObject
            (container.getEjbDescriptor().getUniqueId(), isLocalHomeView,
             primaryKey, getSfsbClientVersion());
    
public booleanisIdentical(EJBLocalObject other)

        container.authorizeLocalMethod(
            BaseContainer.EJBLocalObject_isIdentical);
        container.checkExists(this);
        
        // For all types of beans (entity, stful/stless session),
        // there is exactly one EJBLocalObject instance per bean identity.
        if ( this == other )
            return true;
        else
            return false;
    
booleanisLocalHomeView()

        return isLocalHomeView;
    
voidmapClientObject(java.lang.String intfClassName, java.lang.Object obj)

        clientObjectMap.put(intfClassName, obj);
    
public voidremove()


        // authorization is performed within container
        
        try {
            container.removeBean(this, REMOVE_METHOD, true);
        }  catch(java.rmi.RemoteException re) {
            // This should never be thrown for local invocations, but it's
            // part of the removeBean signature.  If for some strange
            // reason it happens, convert to EJBException
            EJBException ejbEx =new EJBException("unexpected RemoteException");
            ejbEx.initCause(re);
            throw ejbEx;
        }
    
voidsetIsLocalHomeView(boolean flag)

        isLocalHomeView = flag;
    
static com.sun.ejb.containers.EJBLocalObjectImpltoEJBLocalObjectImpl(EJBLocalObject localObj)
Since EJBLocalObject might be a dynamic proxy, the container can't assume it can cast from EJBLocalObject to EJBLocalObjectImpl. This convenience method is used to hide the logic behind the translation from an client-side EJBLocalObject to the corresponding EJBLocalObjectImpl. In the case of a proxy, the invocation handler is the EJBLocalObjectImpl. Otherwise, the argument is returned as is. NOTE : To translate in the other direction, use EJBLocalObjectImpl.getEJBLocalObject()

        EJBLocalObjectImpl localObjectImpl;

        if( localObj instanceof EJBLocalObjectImpl ) {
            localObjectImpl = (EJBLocalObjectImpl) localObj;
        } else {
            localObjectImpl = (EJBLocalObjectImpl) 
                Proxy.getInvocationHandler(localObj);
        } 

        return localObjectImpl;