Package com.sun.ejb.containers
Class StatefulSessionContainer
- java.lang.Object
-
- com.sun.ejb.containers.BaseContainer
-
- com.sun.ejb.containers.StatefulSessionContainer
-
- All Implemented Interfaces:
com.sun.appserv.util.cache.CacheListener,Container,SFSBContainerCallback,com.sun.enterprise.container.common.spi.JavaEEContainer,org.glassfish.enterprise.iiop.spi.EjbContainerFacade
public final class StatefulSessionContainer extends BaseContainer implements com.sun.appserv.util.cache.CacheListener, SFSBContainerCallback
This class provides container functionality specific to stateful SessionBeans. At deployment time, one instance of the StatefulSessionContainer is created for each stateful SessionBean type (i.e. deployment descriptor) in a JAR. The 5 states of a Stateful EJB (an EJB can be in only 1 state at a time): 1. PASSIVE : has been passivated 2. READY : ready for invocations, no transaction in progress 3. INVOKING : processing an invocation 4. INCOMPLETE_TX : ready for invocations, transaction in progress 5. DESTROYED : does not exist- Author:
- Mahesh Kannan
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.sun.ejb.containers.BaseContainer
BaseContainer.ContainerInfo, BaseContainer.ContainerType, BaseContainer.PreInvokeException
-
-
Field Summary
Fields Modifier and Type Field Description static intMIN_PASSIVATION_BATCH_COUNT-
Fields inherited from class com.sun.ejb.containers.BaseContainer
cacheProbeListener, cacheProbeNotifier, callFlowInfo, componentId, CONTAINER_INITIALIZING, CONTAINER_ON_HOLD, CONTAINER_STARTED, CONTAINER_STOPPED, CONTAINER_UNDEPLOYED, containerInfo, containerState, containerStateManager, containerTransactionManager, containerType, debugMonitorFlag, ejbActivateMethod, ejbClass, ejbContainerUtilImpl, ejbDescriptor, ejbGeneratedOptionalLocalBusinessIntfClass, ejbHome, ejbHomeImpl, ejbHomeStub, ejbIntfMethodInfo, ejbIntfMethods, ejbLocalBusinessHome, ejbLocalBusinessHomeImpl, ejbLocalHome, ejbLocalHomeImpl, EJBLocalObject_getPrimaryKey, EJBObject_getPrimaryKey, ejbOptionalLocalBusinessHome, ejbOptionalLocalBusinessHomeImpl, ejbOptionalLocalBusinessHomeIntf, ejbPassivateMethod, ejbProbeListener, ejbProbeNotifier, ejbRemoteBusinessHome, ejbRemoteBusinessHomeImpl, ejbRemoteBusinessHomeStub, ejbRemoveMethod, envProps, hasLocalBusinessView, hasLocalHomeView, hasOptionalLocalBusinessView, hasRemoteBusinessView, hasRemoteHomeView, homeIntf, injectionManager, interceptorManager, invocationInfoMap, invocationManager, isBeanManagedTran, isLocal, isMessageDriven, isRemote, isSession, isSingleton, isStatefulSession, isStatelessSession, isWebServiceEndpoint, loader, localBusinessHomeIntf, localBusinessIntfs, localHomeIntf, logParams, metadata, methodMonitorMap, monitorOn, namingManager, NO_PARAMS, optIntfClassLoader, poolProbeListener, remoteBusinessHomeIntf, remoteBusinessIntfInfo, remoteHomeRefFactory, remoteIntf, scheduleIds, securityManager, sfsbSerializedClass, SINGLETON_BEAN_POOL_PROP, timerProbeListener, timerProbeNotifier, transactionManager, webServiceEndpointIntf, webServiceInvocationInfoMap
-
Fields inherited from interface com.sun.ejb.Container
SEC_CHECKED, SEC_EXCLUDED, SEC_NOT_INITIALIZED, SEC_UNCHECKED, secAttrStrings, TX_BEAN_MANAGED, TX_MANDATORY, TX_NEVER, TX_NOT_INITIALIZED, TX_NOT_SUPPORTED, TX_REQUIRED, TX_REQUIRES_NEW, TX_SUPPORTS, txAttrStrings
-
-
Constructor Summary
Constructors Constructor Description StatefulSessionContainer(BaseContainer.ContainerType conType, EjbDescriptor desc, ClassLoader loader, com.sun.enterprise.security.SecurityManager sm)StatefulSessionContainer(EjbDescriptor desc, ClassLoader loader, com.sun.enterprise.security.SecurityManager sm)This constructor is called from the JarManager when a Jar is deployed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected EJBContextImpl_constructEJBContextImpl(Object instance)protected Object_constructEJBInstance()ComponentContext_getContext(EjbInvocation inv)Called from preInvoke which is called from the EJBObject for local and remote invocations.voidactivateEJB(Object sessionKey, StatefulEJBContext sfsbCtx, Object cookie)protected voidafterBegin(EJBContextImpl context)protected voidafterCompletion(EJBContextImpl context, int status)protected voidbeforeCompletion(EJBContextImpl context)booleancanPassivateEJB(ComponentContext context)protected voidcheckExists(EJBLocalRemoteObject ejbObj)Check if the given EJBObject/LocalObject has been removed.protected voidcheckUnfinishedTx(jakarta.transaction.Transaction prevTx, EjbInvocation inv)protected EJBLocalObjectImplcreateEJBLocalObjectImpl()This is called from the generated "HelloEJBLocalHomeImpl" create method via EJBLocalHomeImpl.createEJBObject.protected EJBObjectImplcreateEJBObjectImpl()This is called from the generated "HelloEJBHomeImpl" create method via EJBHomeImpl.createEJBObject.protected EJBObjectImplcreateRemoteBusinessObjectImpl()voiddecrementMethodReadyStat()protected voiddelistExtendedEntityManagers(ComponentContext ctx)ObjectdeserializeData(byte[] data)protected voiddoConcreteContainerShutdown(boolean appBeingUndeployed)protected voidenlistExtendedEntityManagers(ComponentContext ctx)protected voidforceDestroyBean(EJBContextImpl ctx)Force destroy the EJB and rollback any Tx it was associated with Called from removeBean, timeoutBean and BaseContainer.postInvokeTx.org.glassfish.ha.store.api.BackingStore<Serializable,org.glassfish.ha.store.util.SimpleMetadata>getBackingStore()protected EJBLocalObjectImplgetEJBLocalObjectImpl(Object sessionKey)Called from EJBLocalObjectImpl.getLocalObject() while deserializing a local object reference.protected EJBObjectImplgetEJBObjectImpl(byte[] instanceKey)Called when a remote invocation arrives for an EJB.intgetMaxCacheSize()longgetMethodReadyCount()StringgetMonitorAttributeValues()protected EjbMonitoringStatsProvidergetMonitoringStatsProvider(String appName, String modName, String ejbName)intgetPassivationBatchCount()longgetPassiveCount()protected String[]getPre30LifecycleMethodNames()voidincrementMethodReadyStat()protected voidinitializeHome()Called from the ContainerFactory during initialization.voidinvokePeriodically(long delay, long periodicity, Runnable target)booleanisHAEnabled()protected booleanisIdentical(EJBObjectImpl ejbo, jakarta.ejb.EJBObject other)booleanisPassivationCapable()protected voidloadCheckpointInfo()jakarta.persistence.EntityManagerlookupExtendedEntityManager(jakarta.persistence.EntityManagerFactory emf)Containers that allow extended EntityManager will override this method.voidonUndeploy(StatefulEJBContext sfsbCtx)booleanpassivateEJB(ComponentContext context)booleanpassivateEJB(StatefulEJBContext sfsbCtx)protected voidpostInvokeTx(EjbInvocation inv)postInvokeTx is called after every invocation on the EJB instance, including ejbCreate/ejbFind---/ejbRemove.protected voidregisterMonitorableComponents()voidreleaseContext(EjbInvocation inv)Called from preInvoke which is called from the EJBObject for local and remote invocations.protected voidremoveBean(EJBLocalRemoteObject ejbo, Method removeMethod, boolean local)voidremoveExpiredSessions()voidremoveTimedoutBean(EJBContextImpl ctx)protected booleanresumeTransaction(EjbInvocation inv)byte[]serializeContext(StatefulEJBContext ctx)voidsetBackingStore(org.glassfish.ha.store.api.BackingStore<Serializable,org.glassfish.ha.store.util.SimpleMetadata> store)voidsetHAEnabled(boolean isHAEnabled)voidsetPassivationBatchCount(int count)voidsetRemovalGracePeriodInSeconds(int val)voidsetSessionCache(LruSessionCache cache)voidsetSFSBUUIDUtil(SFSBUUIDUtil util)voidsetSFSBVersionManager(SFSBVersionManager sfsbVersionManager)protected booleansuspendTransaction(EjbInvocation inv)voidtrimEvent(Object primaryKey, Object context)voidundeploy(SessionContextImpl ctx)booleanuserTransactionMethodsAllowed(org.glassfish.api.invocation.ComponentInvocation inv)EJB spec makes a distinction between access to the UserTransaction object itself and access to its methods.protected voidvalidateEMForClientTx(EjbInvocation inv, com.sun.enterprise.transaction.api.JavaEETransaction clientJ2EETx)-
Methods inherited from class com.sun.ejb.containers.BaseContainer
addInvocationInfo, addLocalRemoteInvocationInfo, addProxyInterfacesSetClass, adjustHomeTargetMethodInfo, adjustInvocationInfo, assertValidLocalObject, assertValidRemoteObject, authorize, authorizeLocalGetPrimaryKey, authorizeLocalMethod, authorizeRemoteGetPrimaryKey, authorizeRemoteMethod, callEJBTimeout, cancelTimers, checkExceptionClientTx, checkUserTransactionLookup, cleanupInstance, containerStateToString, createCallFlowAgent, createEjbInstanceAndContext, createEjbInstanceForInterceptors, createEjbInvocation, createEjbInvocation, createMonitoringRegistry, createRemoteReferenceWithId, doAfterBegin, doEJBHomeRemove, doFlush, doTimerInvocationInit, externalPostInvoke, externalPreInvoke, findFlushEnabledAttr, getApplicationId, getClassLoader, getComponentId, getContainerClassLoader, getContainerId, getContainerType, getContext, getDebugMonitorFlag, getDescriptor, getEJBClass, getEjbDescriptor, getEJBHome, getEJBHomeInvocationHandler, getEJBHomeStub, getEJBLocalBusinessHome, getEJBLocalHome, getEJBLocalHomeInvocationHandler, getEJBLocalObjectForPrimaryKey, getEJBLocalObjectForPrimaryKey, getEJBMetaData, getEJBObjectForPrimaryKey, getInvocationKey, getJaccEjb, getJavaGlobalJndiNamePrefix, getMonitoringMethodsArray, getMonitoringMethodsArray, getPassByReference, getProtocolManager, getSecurityManager, getTargetObject, getTimeoutMethod, getTxAttr, getTxAttr, getTxAttrForLifecycleCallback, getUserTransaction, getUseThreadPoolId, incrementCreatedTimedObject, incrementDeliveredTimedObject, incrementRemovedTimedObject, initializeProtocolManager, injectEjbInstance, instantiateEJBLocalBusinessObjectImpl, instantiateEJBLocalObjectImpl, instantiateEJBLocalObjectImpl, instantiateEJBObjectImpl, instantiateEJBObjectImpl, instantiateOptionalEJBLocalBusinessObjectImpl, instantiateRemoteBusinessObjectImpl, intercept, intercept, invokeBeanMethod, invokeFindByPrimaryKey, invokeTargetBeanMethod, isApplicationException, isCreateHomeFinder, isEjbTimeoutMethod, isLocalInterfaceSupported, isLocalObject, isRemoteInterfaceSupported, isRemoteObject, isStopped, isSystemUncheckedException, isTimedObject, isUndeployed, onEnteringContainer, onLeavingContainer, onReady, onShutdown, onTermination, postCreate, postEjbTimeout, postFind, postInvoke, postInvoke, postInvokeNoTx, postProcessInvocationInfo, preInitialize, preInvoke, preInvokeNoTx, preInvokeTx, prepareEjbTimeoutParams, preSelect, registerTimerMonitorableComponent, releaseTargetObject, removeBeanUnchecked, removeBeanUnchecked, scanForEjbCreateMethod, setDebugMonitorFlag, setEJBMetaData, setStartedState, setStoppedState, setUndeployedState, startApplication, toString, undeploy, useClientTx, validateTxAttr, webServicePostInvoke
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.sun.ejb.spi.container.SFSBContainerCallback
getClassLoader
-
-
-
-
Field Detail
-
MIN_PASSIVATION_BATCH_COUNT
public static final int MIN_PASSIVATION_BATCH_COUNT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StatefulSessionContainer
public StatefulSessionContainer(EjbDescriptor desc, ClassLoader loader, com.sun.enterprise.security.SecurityManager sm) throws Exception
This constructor is called from the JarManager when a Jar is deployed.- Throws:
Exception- on error
-
StatefulSessionContainer
public StatefulSessionContainer(BaseContainer.ContainerType conType, EjbDescriptor desc, ClassLoader loader, com.sun.enterprise.security.SecurityManager sm) throws Exception
- Throws:
Exception
-
-
Method Detail
-
isPassivationCapable
public boolean isPassivationCapable()
- Specified by:
isPassivationCapablein interfaceSFSBContainerCallback
-
initializeHome
protected void initializeHome() throws ExceptionDescription copied from class:BaseContainerCalled from the ContainerFactory during initialization.- Overrides:
initializeHomein classBaseContainer- Throws:
Exception
-
checkUnfinishedTx
protected void checkUnfinishedTx(jakarta.transaction.Transaction prevTx, EjbInvocation inv)- Overrides:
checkUnfinishedTxin classBaseContainer
-
loadCheckpointInfo
protected void loadCheckpointInfo()
-
registerMonitorableComponents
protected void registerMonitorableComponents()
- Overrides:
registerMonitorableComponentsin classBaseContainer
-
getMonitorAttributeValues
public String getMonitorAttributeValues()
-
getMonitoringStatsProvider
protected EjbMonitoringStatsProvider getMonitoringStatsProvider(String appName, String modName, String ejbName)
- Specified by:
getMonitoringStatsProviderin classBaseContainer
-
isIdentical
protected boolean isIdentical(EJBObjectImpl ejbo, jakarta.ejb.EJBObject other) throws RemoteException
- Overrides:
isIdenticalin classBaseContainer- Throws:
RemoteException
-
createEJBObjectImpl
protected EJBObjectImpl createEJBObjectImpl() throws jakarta.ejb.CreateException, RemoteException
This is called from the generated "HelloEJBHomeImpl" create method via EJBHomeImpl.createEJBObject. Note: for stateful beans, the HelloEJBHomeImpl.create calls ejbCreate on the new bean after createEJBObject() returns. Return the EJBObject for the bean.- Specified by:
createEJBObjectImplin classBaseContainer- Throws:
jakarta.ejb.CreateExceptionRemoteException
-
createRemoteBusinessObjectImpl
protected EJBObjectImpl createRemoteBusinessObjectImpl() throws jakarta.ejb.CreateException, RemoteException
- Throws:
jakarta.ejb.CreateExceptionRemoteException
-
createEJBLocalObjectImpl
protected EJBLocalObjectImpl createEJBLocalObjectImpl() throws jakarta.ejb.CreateException
This is called from the generated "HelloEJBLocalHomeImpl" create method via EJBLocalHomeImpl.createEJBObject. Note: for stateful beans, the HelloEJBLocalHomeImpl.create calls ejbCreate on the new bean after createEJBLocalObjectImpl() returns. Return the EJBLocalObject for the bean.- Overrides:
createEJBLocalObjectImplin classBaseContainer- Throws:
jakarta.ejb.CreateException
-
_constructEJBContextImpl
protected EJBContextImpl _constructEJBContextImpl(Object instance)
- Overrides:
_constructEJBContextImplin classBaseContainer
-
_constructEJBInstance
protected Object _constructEJBInstance() throws Exception
- Overrides:
_constructEJBInstancein classBaseContainer- Throws:
Exception
-
suspendTransaction
protected boolean suspendTransaction(EjbInvocation inv) throws Exception
- Overrides:
suspendTransactionin classBaseContainer- Throws:
Exception
-
resumeTransaction
protected boolean resumeTransaction(EjbInvocation inv) throws Exception
- Overrides:
resumeTransactionin classBaseContainer- Throws:
Exception
-
lookupExtendedEntityManager
public jakarta.persistence.EntityManager lookupExtendedEntityManager(jakarta.persistence.EntityManagerFactory emf)
Description copied from class:BaseContainerContainers that allow extended EntityManager will override this method.- Specified by:
lookupExtendedEntityManagerin interfacecom.sun.enterprise.container.common.spi.JavaEEContainer- Overrides:
lookupExtendedEntityManagerin classBaseContainer
-
removeBean
protected void removeBean(EJBLocalRemoteObject ejbo, Method removeMethod, boolean local) throws jakarta.ejb.RemoveException, jakarta.ejb.EJBException
- Specified by:
removeBeanin classBaseContainer- Throws:
jakarta.ejb.RemoveExceptionjakarta.ejb.EJBException
-
forceDestroyBean
protected void forceDestroyBean(EJBContextImpl ctx)
Force destroy the EJB and rollback any Tx it was associated with Called from removeBean, timeoutBean and BaseContainer.postInvokeTx. Note: EJB2.0 section 18.3.1 says that discarding an EJB means that no methods other than finalize() should be invoked on it.- Specified by:
forceDestroyBeanin classBaseContainer
-
userTransactionMethodsAllowed
public boolean userTransactionMethodsAllowed(org.glassfish.api.invocation.ComponentInvocation inv)
Description copied from class:BaseContainerEJB spec makes a distinction between access to the UserTransaction object itself and access to its methods. getUserTransaction covers the first check and this method covers the second. It is called by the UserTransaction implementation to verify access.- Specified by:
userTransactionMethodsAllowedin interfaceContainer- Overrides:
userTransactionMethodsAllowedin classBaseContainer
-
removeTimedoutBean
public void removeTimedoutBean(EJBContextImpl ctx)
-
getEJBObjectImpl
protected EJBObjectImpl getEJBObjectImpl(byte[] instanceKey)
Description copied from class:BaseContainerCalled when a remote invocation arrives for an EJB. Implemented in subclasses.- Specified by:
getEJBObjectImplin classBaseContainer
-
getEJBLocalObjectImpl
protected EJBLocalObjectImpl getEJBLocalObjectImpl(Object sessionKey)
Called from EJBLocalObjectImpl.getLocalObject() while deserializing a local object reference.- Overrides:
getEJBLocalObjectImplin classBaseContainer
-
checkExists
protected void checkExists(EJBLocalRemoteObject ejbObj)
Check if the given EJBObject/LocalObject has been removed.- Overrides:
checkExistsin classBaseContainer- Throws:
jakarta.ejb.NoSuchObjectLocalException- if the object has been removed.
-
_getContext
public ComponentContext _getContext(EjbInvocation inv)
Called from preInvoke which is called from the EJBObject for local and remote invocations.- Specified by:
_getContextin classBaseContainer
-
isHAEnabled
public boolean isHAEnabled()
- Overrides:
isHAEnabledin classBaseContainer
-
postInvokeTx
protected void postInvokeTx(EjbInvocation inv) throws Exception
Description copied from class:BaseContainerpostInvokeTx is called after every invocation on the EJB instance, including ejbCreate/ejbFind---/ejbRemove. NOTE: postInvokeTx is called even if the EJB was not invoked because of an exception thrown from preInvokeTx.- Overrides:
postInvokeTxin classBaseContainer- Throws:
Exception
-
releaseContext
public void releaseContext(EjbInvocation inv)
Called from preInvoke which is called from the EJBObject for local and remote invocations.- Specified by:
releaseContextin classBaseContainer
-
afterBegin
protected void afterBegin(EJBContextImpl context)
- Specified by:
afterBeginin classBaseContainer
-
beforeCompletion
protected void beforeCompletion(EJBContextImpl context)
- Specified by:
beforeCompletionin classBaseContainer
-
afterCompletion
protected void afterCompletion(EJBContextImpl context, int status)
- Specified by:
afterCompletionin classBaseContainer
-
canPassivateEJB
public final boolean canPassivateEJB(ComponentContext context)
-
passivateEJB
public final boolean passivateEJB(ComponentContext context)
- Specified by:
passivateEJBin classBaseContainer
-
getPassivationBatchCount
public final int getPassivationBatchCount()
- Specified by:
getPassivationBatchCountin interfaceSFSBContainerCallback
-
setPassivationBatchCount
public final void setPassivationBatchCount(int count)
-
passivateEJB
public final boolean passivateEJB(StatefulEJBContext sfsbCtx)
- Specified by:
passivateEJBin interfaceSFSBContainerCallback
-
getMethodReadyCount
public long getMethodReadyCount()
-
getPassiveCount
public long getPassiveCount()
-
activateEJB
public void activateEJB(Object sessionKey, StatefulEJBContext sfsbCtx, Object cookie)
- Specified by:
activateEJBin interfaceSFSBContainerCallback
-
serializeContext
public byte[] serializeContext(StatefulEJBContext ctx) throws IOException
- Specified by:
serializeContextin interfaceSFSBContainerCallback- Throws:
IOException
-
deserializeData
public Object deserializeData(byte[] data) throws Exception
- Specified by:
deserializeDatain interfaceSFSBContainerCallback- Throws:
Exception
-
validateEMForClientTx
protected void validateEMForClientTx(EjbInvocation inv, com.sun.enterprise.transaction.api.JavaEETransaction clientJ2EETx) throws jakarta.ejb.EJBException
- Overrides:
validateEMForClientTxin classBaseContainer- Throws:
jakarta.ejb.EJBException
-
enlistExtendedEntityManagers
protected void enlistExtendedEntityManagers(ComponentContext ctx)
- Overrides:
enlistExtendedEntityManagersin classBaseContainer
-
delistExtendedEntityManagers
protected void delistExtendedEntityManagers(ComponentContext ctx)
- Overrides:
delistExtendedEntityManagersin classBaseContainer
-
invokePeriodically
public void invokePeriodically(long delay, long periodicity, Runnable target)- Specified by:
invokePeriodicallyin interfaceSFSBContainerCallback
-
onUndeploy
public void onUndeploy(StatefulEJBContext sfsbCtx)
-
getPre30LifecycleMethodNames
protected String[] getPre30LifecycleMethodNames()
- Overrides:
getPre30LifecycleMethodNamesin classBaseContainer
-
doConcreteContainerShutdown
protected void doConcreteContainerShutdown(boolean appBeingUndeployed)
- Specified by:
doConcreteContainerShutdownin classBaseContainer
-
undeploy
public void undeploy(SessionContextImpl ctx)
-
trimEvent
public void trimEvent(Object primaryKey, Object context)
- Specified by:
trimEventin interfacecom.sun.appserv.util.cache.CacheListener
-
setSFSBUUIDUtil
public void setSFSBUUIDUtil(SFSBUUIDUtil util)
-
setHAEnabled
public void setHAEnabled(boolean isHAEnabled)
-
setSessionCache
public void setSessionCache(LruSessionCache cache)
-
setRemovalGracePeriodInSeconds
public void setRemovalGracePeriodInSeconds(int val)
-
removeExpiredSessions
public void removeExpiredSessions()
-
setSFSBVersionManager
public void setSFSBVersionManager(SFSBVersionManager sfsbVersionManager)
-
getMaxCacheSize
public int getMaxCacheSize()
-
getBackingStore
public org.glassfish.ha.store.api.BackingStore<Serializable,org.glassfish.ha.store.util.SimpleMetadata> getBackingStore()
-
setBackingStore
public void setBackingStore(org.glassfish.ha.store.api.BackingStore<Serializable,org.glassfish.ha.store.util.SimpleMetadata> store)
-
incrementMethodReadyStat
public void incrementMethodReadyStat()
-
decrementMethodReadyStat
public void decrementMethodReadyStat()
-
-