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
FieldsFields 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, 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, metadata, methodMonitorMap, monitorOn, namingManager, NO_PARAMS, optIntfClassLoader, poolProbeListener, remoteBusinessHomeIntf, remoteBusinessIntfInfo, remoteHomeRefFactory, remoteIntf, scheduleIds, securityManager, sfsbSerializedClass, SINGLETON_BEAN_POOL_PROP, timerProbeListener, timerProbeNotifier, transactionManager, webServiceEndpointIntf, webServiceInvocationInfoMapFields 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
ConstructorsConstructorDescriptionStatefulSessionContainer(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
Modifier and TypeMethodDescriptionprotected EJBContextImpl_constructEJBContextImpl(Object instance) protected Object_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 EJBLocalObjectImplThis is called from the generated "HelloEJBLocalHomeImpl" create method via EJBLocalHomeImpl.createEJBObject.protected EJBObjectImplThis is called from the generated "HelloEJBHomeImpl" create method via EJBHomeImpl.createEJBObject.protected EJBObjectImplvoidprotected voiddeserializeData(byte[] data) protected voiddoConcreteContainerShutdown(boolean appBeingUndeployed) protected voidprotected voidForce 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> 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.intlongprotected EjbMonitoringStatsProvidergetMonitoringStatsProvider(String appName, String modName, String ejbName) intlongprotected String[]voidprotected voidCalled from the ContainerFactory during initialization.voidinvokePeriodically(long delay, long periodicity, Runnable target) booleanprotected booleanisIdentical(EJBObjectImpl ejbo, jakarta.ejb.EJBObject other) booleanprotected voidjakarta.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 is called after every invocation on the EJB instance, including ejbCreate/ejbFind---/ejbRemove.protected voidvoidCalled from preInvoke which is called from the EJBObject for local and remote invocations.protected voidremoveBean(EJBLocalRemoteObject ejbo, Method removeMethod, boolean local) voidvoidprotected booleanbyte[]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 booleanvoidvoidbooleanuserTransactionMethodsAllowed(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, getContainerInfo, 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, registerSystemInterceptor, registerTimerMonitorableComponent, releaseTargetObject, removeBeanUnchecked, removeBeanUnchecked, scanForEjbCreateMethod, setDebugMonitorFlag, setEJBMetaData, setStartedState, setStoppedState, setUndeployedState, startApplication, toString, undeploy, useClientTx, validateTxAttr, webServicePostInvokeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.sun.ejb.spi.container.SFSBContainerCallback
getClassLoader
-
Field Details
-
MIN_PASSIVATION_BATCH_COUNT
public static final int MIN_PASSIVATION_BATCH_COUNT- See Also:
-
-
Constructor Details
-
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 Details
-
isPassivationCapable
public boolean isPassivationCapable()- Specified by:
isPassivationCapablein interfaceSFSBContainerCallback
-
initializeHome
Description copied from class:BaseContainerCalled from the ContainerFactory during initialization.- Overrides:
initializeHomein classBaseContainer- Throws:
Exception
-
checkUnfinishedTx
- Overrides:
checkUnfinishedTxin classBaseContainer
-
loadCheckpointInfo
protected void loadCheckpointInfo() -
registerMonitorableComponents
protected void registerMonitorableComponents()- Overrides:
registerMonitorableComponentsin classBaseContainer
-
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
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
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
- Overrides:
_constructEJBContextImplin classBaseContainer
-
_constructEJBInstance
- Overrides:
_constructEJBInstancein classBaseContainer- Throws:
Exception
-
suspendTransaction
- Overrides:
suspendTransactionin classBaseContainer- Throws:
Exception
-
resumeTransaction
- 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
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
-
getEJBObjectImpl
Description copied from class:BaseContainerCalled when a remote invocation arrives for an EJB. Implemented in subclasses.- Specified by:
getEJBObjectImplin classBaseContainer
-
getEJBLocalObjectImpl
Called from EJBLocalObjectImpl.getLocalObject() while deserializing a local object reference.- Overrides:
getEJBLocalObjectImplin classBaseContainer
-
checkExists
Check if the given EJBObject/LocalObject has been removed.- Overrides:
checkExistsin classBaseContainer- Throws:
jakarta.ejb.NoSuchObjectLocalException- if the object has been removed.
-
_getContext
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
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
Called from preInvoke which is called from the EJBObject for local and remote invocations.- Specified by:
releaseContextin classBaseContainer
-
afterBegin
- Specified by:
afterBeginin classBaseContainer
-
beforeCompletion
- Specified by:
beforeCompletionin classBaseContainer
-
afterCompletion
- Specified by:
afterCompletionin classBaseContainer
-
canPassivateEJB
-
passivateEJB
- Specified by:
passivateEJBin classBaseContainer
-
getPassivationBatchCount
public int getPassivationBatchCount()- Specified by:
getPassivationBatchCountin interfaceSFSBContainerCallback
-
setPassivationBatchCount
public void setPassivationBatchCount(int count) -
passivateEJB
- Specified by:
passivateEJBin interfaceSFSBContainerCallback
-
getMethodReadyCount
public long getMethodReadyCount() -
getPassiveCount
public long getPassiveCount() -
activateEJB
- Specified by:
activateEJBin interfaceSFSBContainerCallback
-
serializeContext
- Specified by:
serializeContextin interfaceSFSBContainerCallback- Throws:
IOException
-
deserializeData
- 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
- Overrides:
enlistExtendedEntityManagersin classBaseContainer
-
delistExtendedEntityManagers
- Overrides:
delistExtendedEntityManagersin classBaseContainer
-
invokePeriodically
- Specified by:
invokePeriodicallyin interfaceSFSBContainerCallback
-
onUndeploy
-
getPre30LifecycleMethodNames
- Overrides:
getPre30LifecycleMethodNamesin classBaseContainer
-
doConcreteContainerShutdown
protected void doConcreteContainerShutdown(boolean appBeingUndeployed) - Specified by:
doConcreteContainerShutdownin classBaseContainer
-
undeploy
-
trimEvent
- Specified by:
trimEventin interfacecom.sun.appserv.util.cache.CacheListener
-
setSFSBUUIDUtil
-
setHAEnabled
public void setHAEnabled(boolean isHAEnabled) -
setSessionCache
-
setRemovalGracePeriodInSeconds
public void setRemovalGracePeriodInSeconds(int val) -
removeExpiredSessions
public void removeExpiredSessions() -
setSFSBVersionManager
-
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()
-