Class EntityContainer
- java.lang.Object
-
- com.sun.ejb.containers.BaseContainer
-
- org.glassfish.persistence.ejb.entitybean.container.EntityContainer
-
- All Implemented Interfaces:
CacheListener
,Container
,JavaEEContainer
,EjbContainerFacade
- Direct Known Subclasses:
CommitCEntityContainer
,ReadOnlyBeanContainer
public class EntityContainer extends BaseContainer implements CacheListener
This class implements the Container interface for EntityBeans. It is responsible for instance & lifecycle management for BMP & CMP EntityBeans. The EntityContainer implements option B of the commit-time options described in the EJB2.0 spec section 10.5.9 It also implements optimistic concurrency (i.e. multiple non-exclusive bean instances per primary key) when there are multiple concurrent transactions on a EntityBean.The following sequence of actions happens for the EntityContainer, for each EJB lifecycle stage (note: getEJBObject, getContext, releaseContext, preInvokeTx, postInvokeTx are called from BaseContainer). 1. EJB Creation homeImpl.create, container.getContext, container.preInvokeTx, ejb.ejbCreate, container.postCreate, ejb.ejbPostCreate, container.postInvokeTx, container.releaseContext 2. EJB Finding homeImpl.find---, container.getContext, container.preInvokeTx, ejb.ejbFind---, container.postFind, container.postInvokeTx, container.releaseContext 3. EJB Invocation container.getEJBObject, ejbObject.someMethod, container.getContext, container.preInvokeTx, ejb.someMethod, container.postInvokeTx, container.releaseContext
State Management: The EntityContainer manages collections of EJBs in different states. The 5 states of an EntityBean (an EJB can be in only 1 state at a time):
- POOLED : does not have identity. EJBs in the POOLED state are all identical, hence are maintained in a java.util.Vector, whose size is maintained below a HIGH_WATER_MARK (currently 100).
- READY : ready for invocations, no transaction in progress. EJBs in the READY state are associated with a primary key. To enhance reuse of EJB instances, only one READY EJB per primary key is stored. READY EJBs are managed by the ejbstore/EntityStore class. READY EJBs are looked up using a key consisting of the primary key and a null transaction context.
- INVOKING : processing an invocation. EJBs in the INVOKING state are not stored anywhere. Before transitioning from READY or INCOMPLETE_TX to INVOKING, the EJB is removed from the EntityStore.
- INCOMPLETE_TX : ready for invocations, transaction in progress. EJBs in the INCOMPLETE_TX state are associated with a primary key. INCOMPLETE_TX EJBs are managed by the ejbstore/EntityStore class. INCOMPLETE_TX EJBs are looked up using a composite key consisting of the primary key and the transaction context.
- DESTROYED : does not exist.
- Author:
- Mahesh Kannan, Shanker N, Pramod Gopinath
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
EntityContainer.CacheProperties
protected class
EntityContainer.EJBObjectCacheVictimHandler
protected class
EntityContainer.LocalEJBObjectCacheVictimHandler
-
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 protected int
_maxBuckets
protected BeanCacheDescriptor
beanCacheDes
protected BeanPoolDescriptor
beanPoolDes
protected int
DEFAULT_CACHE_SIZE
protected float
DEFAULT_LOAD_FACTOR
protected boolean
defaultCacheEJBO
protected EjbContainer
ejbContainer
protected EJBObjectCache
ejbLocalObjectStore
protected EJBObjectCache
ejbObjectStore
protected int
ejboRemoved
protected AbstractPool
entityCtxPool
protected static int
HIGH_WATER_MARK
protected IASEjbExtraDescriptors
iased
protected org.glassfish.persistence.ejb.entitybean.container.EntityContainer.IdleBeansPassivator
idleEJBObjectPassivator
protected org.glassfish.persistence.ejb.entitybean.container.EntityContainer.IdleBeansPassivator
idleLocalEJBObjectPassivator
protected boolean
isContainerManagedPers
protected boolean
isReentrant
protected Stack
passivationCandidates
protected Cache
readyStore
protected int
totalPassivationErrors
protected int
totalPassivations
-
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, executorProbeListener, hasLocalBusinessView, hasLocalHomeView, hasOptionalLocalBusinessView, hasRemoteBusinessView, hasRemoteHomeView, homeIntf, injectionManager, interceptorManager, invocationInfoMap, invocationManager, isBeanManagedTran, isLocal, isMessageDriven, isRemote, isSession, isSingleton, isStatefulSession, isStatelessSession, isWebServiceEndpoint, jcdiService, loader, localBusinessHomeIntf, localBusinessIntfs, localHomeIntf, logParams, metadata, 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 Modifier Constructor Description protected
EntityContainer(BaseContainer.ContainerType containerType, EjbDescriptor desc, ClassLoader loader, SecurityManager sm)
protected
EntityContainer(EjbDescriptor desc, ClassLoader loader, 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 ComponentContext
_getContext(EjbInvocation inv)
Called from BaseContainer.preInvoke which is called from the EJBObject for local and remote invocations, and from the EJBHome for create/find.protected EntityContextImpl
activateEJBFromPool(Object primaryKey, EjbInvocation inv)
Called from getContext and getEJBWithIncompleteTx Get an EJB in the ready state (i.e.protected void
addPooledEJB(EntityContextImpl context)
protected void
addProxyInterfacesSetClass(Set proxyInterfacesSet, boolean local)
protected void
addReadyEJB(EntityContextImpl context)
protected void
adjustHomeTargetMethodInfo(InvocationInfo invInfo, String methodName, Class[] paramTypes)
protected void
adjustInvocationInfo(InvocationInfo invInfo, Method method, int txAttr, boolean flushEnabled, String methodIntf, Class originalIntf)
protected void
afterBegin(EJBContextImpl ctx)
protected void
afterCompletion(EJBContextImpl ctx, int status)
protected void
afterNewlyActivated(EntityContextImpl context)
protected void
authorizeLocalGetPrimaryKey(EJBLocalRemoteObject ejbObj)
protected void
authorizeRemoteGetPrimaryKey(EJBLocalRemoteObject ejbObj)
protected void
beforeCompletion(EJBContextImpl ctx)
protected void
callEJBLoad(jakarta.ejb.EntityBean ejb, EntityContextImpl context, boolean activeTx)
protected void
callEJBRemove(jakarta.ejb.EntityBean ejb, EntityContextImpl context)
protected void
callEJBStore(jakarta.ejb.EntityBean ejb, EntityContextImpl context)
void
cancelTimerTasks()
cancel a timer task to trim timed out entries in the cache.protected void
checkExists(EJBLocalRemoteObject ejbObj)
Check if the given EJBObject/LocalObject has been removed.protected void
checkUnfinishedTx(jakarta.transaction.Transaction prevTx, EjbInvocation inv)
protected EJBLocalObjectImpl
createEJBLocalObjectImpl()
protected EJBObjectImpl
createEJBObjectImpl()
Implementation of BaseContainer method.protected void
createEJBObjectStores(int cacheSize, int numberOfVictimsToSelect, long idleTimeout)
protected EntityContextImpl
createEntityContextInstance(jakarta.ejb.EntityBean ejb, EntityContainer entityContainer)
protected void
createReadyStore(int cacheSize, int numberOfVictimsToSelect, float loadFactor, long idleTimeout)
protected void
destroyReadyStoreOnUndeploy()
protected void
doConcreteContainerShutdown(boolean appBeingUndeployed)
protected void
doEJBHomeRemove(Object primaryKey, Method removeMethod, boolean local)
protected void
doFlush(EjbInvocation inv)
protected void
doTimerInvocationInit(EjbInvocation inv, Object primaryKey)
This is implemented by concrete containers that support TimedObjects.protected void
forceDestroyBean(EJBContextImpl ctx)
Discard the bean instance.protected EJBHomeInvocationHandler
getEJBHomeInvocationHandler(Class homeIntfClass)
protected EJBLocalHomeInvocationHandler
getEJBLocalHomeInvocationHandler(Class homeIntfClass)
jakarta.ejb.EJBLocalObject
getEJBLocalObjectForPrimaryKey(Object pkey)
Called only from the Persistence Manager for EJB2.0 CMP EntityBeans.jakarta.ejb.EJBLocalObject
getEJBLocalObjectForPrimaryKey(Object pkey, jakarta.ejb.EJBContext ctx)
Called only from the Persistence Manager for EJB2.0 CMP EntityBeans.protected EJBLocalObjectImpl
getEJBLocalObjectImpl(Object key)
Called from EJBLocalObjectImpl.getLocalObject() while deserializing a local object reference.jakarta.ejb.EJBObject
getEJBObjectForPrimaryKey(Object pkey)
Called only from the Persistence Manager for EJB2.0 CMP EntityBeans.protected EJBObjectImpl
getEJBObjectImpl(byte[] streamKey)
Called when a remote EjbInvocation arrives for an EJB.int
getMaxCacheSize()
int
getMaxPoolSize()
protected EjbMonitoringStatsProvider
getMonitoringStatsProvider(String appName, String modName, String ejbName)
long
getPooledCount()
protected EntityContextImpl
getPooledEJB()
long
getReadyCount()
protected EntityContextImpl
getReadyEJB(EjbInvocation inv)
int
getSteadyPoolSize()
protected void
initializeHome()
Called from the ContainerFactory during initialization.protected EJBLocalObjectImpl
internalGetEJBLocalObjectImpl(Object primaryKey)
The following are private methods for implementing internal logic for lifecyle and state management, in a reusable way.protected EJBLocalObjectImpl
internalGetEJBLocalObjectImpl(Object primaryKey, boolean incrementRefCount)
protected EJBLocalObjectImpl
internalGetEJBLocalObjectImpl(Object primaryKey, boolean incrementRefCount, boolean cacheEJBO)
protected Object
invokeFindByPrimaryKey(Method method, EjbInvocation inv, Object[] args)
protected boolean
isIdentical(EJBObjectImpl ejbObjImpl, jakarta.ejb.EJBObject other)
void
onReady()
Called when server instance is Readyprotected void
passivateAndPoolEJB(EntityContextImpl context)
protected boolean
passivateEJB(ComponentContext ctx)
void
postCreate(EjbInvocation inv, Object primaryKey)
This is called from the generated "HelloEJBHomeImpl" create* method, after ejb.ejbCreate() has been called and before ejb.ejbPostCreate() is called.Object
postFind(EjbInvocation inv, Object primaryKeys, Object[] findParams)
Convert a collection of primary keys to a collection of EJBObjects.protected void
postInvokeNoTx(EjbInvocation inv)
protected InvocationInfo
postProcessInvocationInfo(InvocationInfo invInfo)
protected void
preCreate(EjbInvocation inv, EntityContextImpl context)
Called from getContext before the ejb.ejbCreate is calledprotected void
preFind(EjbInvocation inv, EntityContextImpl context)
Called from getContext before the ejb.ejbFind* is calledprotected void
preInitialize(EjbDescriptor desc, ClassLoader loader)
protected void
preInvokeNoTx(EjbInvocation inv)
void
preSelect()
Called from CMP PersistentManagerprotected void
registerMonitorableComponents()
void
releaseContext(EjbInvocation inv)
This is called from BaseContainer.postInvoke after EntityContainer.preInvokeTx has been called.protected void
removeBean(EJBLocalRemoteObject ejbo, Method removeMethod, boolean local)
protected void
removeBean(EjbInvocation inv)
container.preInvoke() must already be done.void
removeBeanUnchecked(jakarta.ejb.EJBLocalObject localObj)
Remove a bean.void
removeBeanUnchecked(Object primaryKey)
Remove a bean.protected void
removeContextFromReadyStore(Object primaryKey, EntityContextImpl context)
protected void
removeIncompleteTxEJB(EntityContextImpl context, boolean updateTxBeanTable)
Called from releaseContext if ejb is removed, from afterCompletion, and from passivateEJB.protected void
setEJBMetaData()
org.glassfish.persistence.ejb.entitybean.container.EntityContainer.IdleBeansPassivator
setupIdleBeansPassivator(Cache cache)
setup a timer task to trim timed out entries in the cache.void
trimEvent(Object primaryKey, Object context)
an cached value is trimmed (to prevent cache overflow)protected void
validateTxAttr(MethodDescriptor md, int txAttr)
Validate transaction attribute value.protected boolean
willInvokeWithClientTx(EjbInvocation inv)
-
Methods inherited from class com.sun.ejb.containers.BaseContainer
_constructEJBContextImpl, _constructEJBInstance, _createJCDIInjectionContext, _createJCDIInjectionContext, addInvocationInfo, addLocalRemoteInvocationInfo, assertValidLocalObject, assertValidRemoteObject, authorize, authorizeLocalMethod, authorizeRemoteMethod, callEJBTimeout, cancelTimers, checkExceptionClientTx, checkUserTransactionLookup, cleanupInstance, containerStateToString, createCallFlowAgent, createEjbInstanceAndContext, createEjbInstanceForInterceptors, createEjbInvocation, createEjbInvocation, createEmptyContextAndInterceptors, createMonitoringRegistry, createRemoteReferenceWithId, delistExtendedEntityManagers, doAfterBegin, enlistExtendedEntityManagers, externalPostInvoke, externalPreInvoke, findFlushEnabledAttr, getApplicationId, getClassLoader, getComponentId, getContainerClassLoader, getContainerId, getContainerType, getContext, getDebugMonitorFlag, getDescriptor, getEJBClass, getEjbDescriptor, getEJBHome, getEJBHomeStub, getEJBLocalBusinessHome, getEJBLocalHome, getEJBMetaData, getInvocationKey, getJaccEjb, getJavaGlobalJndiNamePrefix, getMonitoringMethodsArray, getMonitoringMethodsArray, getPassByReference, getPre30LifecycleMethodNames, getProtocolManager, getSecurityManager, getTargetObject, getTimeoutMethod, getTxAttr, getTxAttr, getTxAttrForLifecycleCallback, getUserTransaction, getUseThreadPoolId, incrementCreatedTimedObject, incrementDeliveredTimedObject, incrementRemovedTimedObject, initialize, initializeProtocolManager, injectEjbInstance, instantiateEJBLocalBusinessObjectImpl, instantiateEJBLocalObjectImpl, instantiateEJBLocalObjectImpl, instantiateEJBObjectImpl, instantiateEJBObjectImpl, instantiateOptionalEJBLocalBusinessObjectImpl, instantiateRemoteBusinessObjectImpl, intercept, intercept, invokeBeanMethod, invokeTargetBeanMethod, isApplicationException, isCreateHomeFinder, isEjbTimeoutMethod, isHAEnabled, isJCDIEnabled, isLocalInterfaceSupported, isLocalObject, isRemoteInterfaceSupported, isRemoteObject, isStopped, isSystemUncheckedException, isTimedObject, isUndeployed, lookupExtendedEntityManager, onEnteringContainer, onLeavingContainer, onShutdown, onTermination, postEjbTimeout, postInvoke, postInvoke, postInvokeTx, preInvoke, preInvokeTx, prepareEjbTimeoutParams, registerTimerMonitorableComponent, releaseTargetObject, resumeTransaction, scanForEjbCreateMethod, setDebugMonitorFlag, setStartedState, setStoppedState, setUndeployedState, startApplication, suspendTransaction, toString, undeploy, useClientTx, userTransactionMethodsAllowed, validateEMForClientTx, webServicePostInvoke
-
-
-
-
Field Detail
-
HIGH_WATER_MARK
protected static final int HIGH_WATER_MARK
- See Also:
- Constant Field Values
-
ejbObjectStore
protected EJBObjectCache ejbObjectStore
-
ejbLocalObjectStore
protected EJBObjectCache ejbLocalObjectStore
-
passivationCandidates
protected Stack passivationCandidates
-
readyStore
protected Cache readyStore
-
entityCtxPool
protected AbstractPool entityCtxPool
-
isReentrant
protected boolean isReentrant
-
isContainerManagedPers
protected boolean isContainerManagedPers
-
DEFAULT_LOAD_FACTOR
protected final float DEFAULT_LOAD_FACTOR
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_SIZE
protected final int DEFAULT_CACHE_SIZE
- See Also:
- Constant Field Values
-
_maxBuckets
protected int _maxBuckets
-
iased
protected IASEjbExtraDescriptors iased
-
beanCacheDes
protected BeanCacheDescriptor beanCacheDes
-
beanPoolDes
protected BeanPoolDescriptor beanPoolDes
-
ejbContainer
protected EjbContainer ejbContainer
-
idleEJBObjectPassivator
protected org.glassfish.persistence.ejb.entitybean.container.EntityContainer.IdleBeansPassivator idleEJBObjectPassivator
-
idleLocalEJBObjectPassivator
protected org.glassfish.persistence.ejb.entitybean.container.EntityContainer.IdleBeansPassivator idleLocalEJBObjectPassivator
-
defaultCacheEJBO
protected boolean defaultCacheEJBO
-
ejboRemoved
protected int ejboRemoved
-
totalPassivations
protected int totalPassivations
-
totalPassivationErrors
protected int totalPassivationErrors
-
-
Constructor Detail
-
EntityContainer
protected EntityContainer(EjbDescriptor desc, ClassLoader loader, SecurityManager sm) throws Exception
This constructor is called from the JarManager when a Jar is deployed.- Throws:
Exception
- on error
-
EntityContainer
protected EntityContainer(BaseContainer.ContainerType containerType, EjbDescriptor desc, ClassLoader loader, SecurityManager sm) throws Exception
- Throws:
Exception
-
-
Method Detail
-
preInitialize
protected void preInitialize(EjbDescriptor desc, ClassLoader loader)
- Overrides:
preInitialize
in classBaseContainer
-
setEJBMetaData
protected void setEJBMetaData() throws Exception
- Overrides:
setEJBMetaData
in classBaseContainer
- Throws:
Exception
-
validateTxAttr
protected void validateTxAttr(MethodDescriptor md, int txAttr) throws jakarta.ejb.EJBException
Description copied from class:BaseContainer
Validate transaction attribute value. Allow subclasses to add their own validation.- Overrides:
validateTxAttr
in classBaseContainer
- Throws:
jakarta.ejb.EJBException
-
adjustHomeTargetMethodInfo
protected void adjustHomeTargetMethodInfo(InvocationInfo invInfo, String methodName, Class[] paramTypes) throws NoSuchMethodException
- Overrides:
adjustHomeTargetMethodInfo
in classBaseContainer
- Throws:
NoSuchMethodException
-
getEJBHomeInvocationHandler
protected EJBHomeInvocationHandler getEJBHomeInvocationHandler(Class homeIntfClass) throws Exception
- Overrides:
getEJBHomeInvocationHandler
in classBaseContainer
- Throws:
Exception
-
getEJBLocalHomeInvocationHandler
protected EJBLocalHomeInvocationHandler getEJBLocalHomeInvocationHandler(Class homeIntfClass) throws Exception
- Overrides:
getEJBLocalHomeInvocationHandler
in classBaseContainer
- Throws:
Exception
-
setupIdleBeansPassivator
public org.glassfish.persistence.ejb.entitybean.container.EntityContainer.IdleBeansPassivator setupIdleBeansPassivator(Cache cache) throws Exception
setup a timer task to trim timed out entries in the cache.- Parameters:
cache
- cache which is used to setup the timer task- Returns:
- the passivator object
- Throws:
Exception
-
cancelTimerTasks
public void cancelTimerTasks()
cancel a timer task to trim timed out entries in the cache.
-
postProcessInvocationInfo
protected InvocationInfo postProcessInvocationInfo(InvocationInfo invInfo)
- Overrides:
postProcessInvocationInfo
in classBaseContainer
-
initializeHome
protected void initializeHome() throws Exception
Called from the ContainerFactory during initialization.- Overrides:
initializeHome
in classBaseContainer
- Throws:
Exception
-
registerMonitorableComponents
protected void registerMonitorableComponents()
- Overrides:
registerMonitorableComponents
in classBaseContainer
-
getMonitoringStatsProvider
protected EjbMonitoringStatsProvider getMonitoringStatsProvider(String appName, String modName, String ejbName)
- Specified by:
getMonitoringStatsProvider
in classBaseContainer
-
onReady
public void onReady()
Description copied from class:BaseContainer
Called when server instance is Ready- Specified by:
onReady
in interfaceContainer
- Overrides:
onReady
in classBaseContainer
-
getMaxCacheSize
public int getMaxCacheSize()
-
getSteadyPoolSize
public int getSteadyPoolSize()
-
getMaxPoolSize
public int getMaxPoolSize()
-
getPooledCount
public long getPooledCount()
-
getReadyCount
public long getReadyCount()
-
createEJBObjectImpl
protected EJBObjectImpl createEJBObjectImpl() throws jakarta.ejb.CreateException, RemoteException
Implementation of BaseContainer method. This is never called.- Specified by:
createEJBObjectImpl
in classBaseContainer
- Throws:
jakarta.ejb.CreateException
RemoteException
-
createEJBLocalObjectImpl
protected EJBLocalObjectImpl createEJBLocalObjectImpl() throws jakarta.ejb.CreateException
- Overrides:
createEJBLocalObjectImpl
in classBaseContainer
- Throws:
jakarta.ejb.CreateException
-
getEJBObjectImpl
protected EJBObjectImpl getEJBObjectImpl(byte[] streamKey)
Called when a remote EjbInvocation arrives for an EJB.- Specified by:
getEJBObjectImpl
in classBaseContainer
-
getEJBLocalObjectImpl
protected EJBLocalObjectImpl getEJBLocalObjectImpl(Object key)
Called from EJBLocalObjectImpl.getLocalObject() while deserializing a local object reference.- Overrides:
getEJBLocalObjectImpl
in classBaseContainer
-
_getContext
protected ComponentContext _getContext(EjbInvocation inv)
Called from BaseContainer.preInvoke which is called from the EJBObject for local and remote invocations, and from the EJBHome for create/find.- Specified by:
_getContext
in classBaseContainer
-
willInvokeWithClientTx
protected boolean willInvokeWithClientTx(EjbInvocation inv)
-
releaseContext
public void releaseContext(EjbInvocation inv)
This is called from BaseContainer.postInvoke after EntityContainer.preInvokeTx has been called.- Specified by:
releaseContext
in classBaseContainer
-
preCreate
protected void preCreate(EjbInvocation inv, EntityContextImpl context)
Called from getContext before the ejb.ejbCreate is called
-
postCreate
public void postCreate(EjbInvocation inv, Object primaryKey) throws jakarta.ejb.CreateException
This is called from the generated "HelloEJBHomeImpl" create* method, after ejb.ejbCreate() has been called and before ejb.ejbPostCreate() is called. Note: postCreate will not be called if ejbCreate throws an exception- Specified by:
postCreate
in interfaceContainer
- Overrides:
postCreate
in classBaseContainer
primaryKey
- the value returned from ejbCreate.- Throws:
jakarta.ejb.CreateException
-
invokeFindByPrimaryKey
protected Object invokeFindByPrimaryKey(Method method, EjbInvocation inv, Object[] args) throws Throwable
- Overrides:
invokeFindByPrimaryKey
in classBaseContainer
- Throws:
Throwable
-
authorizeLocalGetPrimaryKey
protected void authorizeLocalGetPrimaryKey(EJBLocalRemoteObject ejbObj) throws jakarta.ejb.EJBException
- Overrides:
authorizeLocalGetPrimaryKey
in classBaseContainer
- Throws:
jakarta.ejb.EJBException
-
authorizeRemoteGetPrimaryKey
protected void authorizeRemoteGetPrimaryKey(EJBLocalRemoteObject ejbObj) throws RemoteException
- Overrides:
authorizeRemoteGetPrimaryKey
in classBaseContainer
- Throws:
RemoteException
-
preFind
protected void preFind(EjbInvocation inv, EntityContextImpl context)
Called from getContext before the ejb.ejbFind* is called
-
preSelect
public void preSelect() throws jakarta.ejb.EJBException
Called from CMP PersistentManager- Specified by:
preSelect
in interfaceContainer
- Overrides:
preSelect
in classBaseContainer
- Throws:
jakarta.ejb.EJBException
- Thrown if an error occurs during the preSelect actions performed by the container. If thrown, the remaining select query steps should be aborted and an EJBException should be propagated back to the application code.
-
postFind
public Object postFind(EjbInvocation inv, Object primaryKeys, Object[] findParams) throws jakarta.ejb.FinderException
Convert a collection of primary keys to a collection of EJBObjects. (special case: single primary key). Note: the order of input & output collections must be maintained. Null values are preserved in both the single primary key return and collection-valued return cases. This is called from the generated "HelloEJBHomeImpl" find* method, after ejb.ejbFind**() has been called. Note: postFind will not be called if ejbFindXXX throws an exception- Specified by:
postFind
in interfaceContainer
- Overrides:
postFind
in classBaseContainer
primaryKeys
- the primaryKey or collection of primaryKeys (Collection/Enumeration) returned from ejbFind.findParams
- the parameters to the ejbFind method.- Returns:
- an EJBObject reference or Collection/Enumeration of EJBObjects.
- Throws:
jakarta.ejb.FinderException
-
getEJBObjectForPrimaryKey
public jakarta.ejb.EJBObject getEJBObjectForPrimaryKey(Object pkey)
Called only from the Persistence Manager for EJB2.0 CMP EntityBeans. This is a private API between the PM and Container because there is no standard API defined in EJB2.0 for the PM to get an EJBObject for a primary key (home.findByPrimaryKey cant be used because it may not run in the same tx).- Specified by:
getEJBObjectForPrimaryKey
in interfaceContainer
- Overrides:
getEJBObjectForPrimaryKey
in classBaseContainer
-
getEJBLocalObjectForPrimaryKey
public jakarta.ejb.EJBLocalObject getEJBLocalObjectForPrimaryKey(Object pkey, jakarta.ejb.EJBContext ctx)
Called only from the Persistence Manager for EJB2.0 CMP EntityBeans. Called only during cascade delete...... This is a private API between the PM and Container because there is no standard API defined in EJB2.0 for the PM to get an EJBLocalObject for a primary key (findByPrimaryKey cant be used because it may not run in the same tx). Example 1: A cascadeDeletes B and B calls getA() (expected return value: null) In the above case, getA() eventualy calls getEJBLocalObjectForPrimaryKey(PK_of_A, Ctx_of_B) We first check if B is in the process of being cascade deleted by checking the cascadeDeleteBeforeEJBRemove flag. If this flag is true, only then we bother to check if the Context associated with the PK_of_A in this transaction is marked for cascade delete which can be figured out by checking isCascadeDeleteAfterSuperEJBRemove() in A's context. If A is marked for cascade delete then we return null else the EJBLocalObject associated with A. Example 2: C cascadeDeletes B and B calls getA() (expected return value: EJBLocalObject for PK_of_A) In the above case, getA() eventualy calls getEJBLocalObjectForPrimaryKey(PK_of_A, Ctx_of_B) We first check if B is in the process of being cascade deleted by checking the cascadeDeleteBeforeEJBRemove flag. This flag will be true, and hence we check if the Context associated with the PK_of_A in this transaction is marked for cascade delete which can be figured out by checking isCascadeDeleteAfterSuperEJBRemove() in A's context. In this case this flag will be false and hcen we return the ejbLocalObject Example 2: B is *NOT* cascade deleted and B calls getA() (expected return value: EJBLocalObject for PK_of_A) In the above case, getA() eventualy calls getEJBLocalObjectForPrimaryKey(PK_of_A, Ctx_of_B) We first check if B is in the process of being cascade deleted by checking the cascadeDeleteBeforeEJBRemove flag. This flag will be FALSE, and hence we do not make any further check and return the EJBLocalObject associated with A- Specified by:
getEJBLocalObjectForPrimaryKey
in interfaceContainer
- Overrides:
getEJBLocalObjectForPrimaryKey
in classBaseContainer
- Parameters:
pkey
- The primary key for which the EJBLocalObject is requiredctx
- The context associated with the bean from which the accessor method is invoked- Returns:
- The EJBLocalObject associated with the PK or null if it is cascade deleted.
-
getEJBLocalObjectForPrimaryKey
public jakarta.ejb.EJBLocalObject getEJBLocalObjectForPrimaryKey(Object pkey)
Called only from the Persistence Manager for EJB2.0 CMP EntityBeans. This is a private API between the PM and Container because there is no standard API defined in EJB2.0 for the PM to get an EJBLocalObject for a primary key (findByPrimaryKey cant be used because it may not run in the same tx).- Specified by:
getEJBLocalObjectForPrimaryKey
in interfaceContainer
- Overrides:
getEJBLocalObjectForPrimaryKey
in classBaseContainer
-
doEJBHomeRemove
protected void doEJBHomeRemove(Object primaryKey, Method removeMethod, boolean local) throws jakarta.ejb.RemoveException, jakarta.ejb.EJBException, RemoteException
- Overrides:
doEJBHomeRemove
in classBaseContainer
- Throws:
jakarta.ejb.RemoveException
jakarta.ejb.EJBException
RemoteException
-
removeBean
protected void removeBean(EJBLocalRemoteObject ejbo, Method removeMethod, boolean local) throws jakarta.ejb.RemoveException, jakarta.ejb.EJBException, RemoteException
- Specified by:
removeBean
in classBaseContainer
- Throws:
jakarta.ejb.RemoveException
jakarta.ejb.EJBException
RemoteException
-
removeBean
protected void removeBean(EjbInvocation inv) throws jakarta.ejb.RemoveException
container.preInvoke() must already be done. So this will be called with the proper Tx context.- Throws:
jakarta.ejb.RemoveException
- if an error occurs while removing the bean
-
removeBeanUnchecked
public void removeBeanUnchecked(jakarta.ejb.EJBLocalObject localObj)
Remove a bean. Used by the PersistenceManager. This is needed because the PM's remove must bypass tx/security checks.- Specified by:
removeBeanUnchecked
in interfaceContainer
- Overrides:
removeBeanUnchecked
in classBaseContainer
-
removeBeanUnchecked
public void removeBeanUnchecked(Object primaryKey)
Remove a bean. Used by the PersistenceManager. This is needed because the PM's remove must bypass tx/security checks.- Specified by:
removeBeanUnchecked
in interfaceContainer
- Overrides:
removeBeanUnchecked
in classBaseContainer
-
forceDestroyBean
protected void forceDestroyBean(EJBContextImpl ctx)
Discard the bean instance. The bean's persistent state is not removed. This is usually called when the bean instance throws a system exception, from BaseContainer.postInvokeTx, getReadyEJB, afterBegin, beforeCompletion, passivateEJB.- Specified by:
forceDestroyBean
in classBaseContainer
-
checkUnfinishedTx
protected void checkUnfinishedTx(jakarta.transaction.Transaction prevTx, EjbInvocation inv)
- Overrides:
checkUnfinishedTx
in classBaseContainer
-
checkExists
protected void checkExists(EJBLocalRemoteObject ejbObj)
Check if the given EJBObject/LocalObject has been removed. Called before executing non-business methods of EJBLocalObject.- Overrides:
checkExists
in classBaseContainer
- Throws:
jakarta.ejb.NoSuchObjectLocalException
- if the object has been removed.
-
afterBegin
protected void afterBegin(EJBContextImpl ctx)
- Specified by:
afterBegin
in classBaseContainer
-
beforeCompletion
protected void beforeCompletion(EJBContextImpl ctx)
- Specified by:
beforeCompletion
in classBaseContainer
-
afterCompletion
protected void afterCompletion(EJBContextImpl ctx, int status)
- Specified by:
afterCompletion
in classBaseContainer
-
preInvokeNoTx
protected void preInvokeNoTx(EjbInvocation inv)
- Overrides:
preInvokeNoTx
in classBaseContainer
-
postInvokeNoTx
protected void postInvokeNoTx(EjbInvocation inv)
- Overrides:
postInvokeNoTx
in classBaseContainer
-
adjustInvocationInfo
protected void adjustInvocationInfo(InvocationInfo invInfo, Method method, int txAttr, boolean flushEnabled, String methodIntf, Class originalIntf) throws jakarta.ejb.EJBException
- Overrides:
adjustInvocationInfo
in classBaseContainer
- Throws:
jakarta.ejb.EJBException
-
trimEvent
public void trimEvent(Object primaryKey, Object context)
Description copied from interface:CacheListener
an cached value is trimmed (to prevent cache overflow)- Specified by:
trimEvent
in interfaceCacheListener
- Parameters:
primaryKey
- lookup keycontext
- value of the cached entity
-
passivateEJB
protected boolean passivateEJB(ComponentContext ctx)
- Specified by:
passivateEJB
in classBaseContainer
-
internalGetEJBLocalObjectImpl
protected EJBLocalObjectImpl internalGetEJBLocalObjectImpl(Object primaryKey)
The following are private methods for implementing internal logic for lifecyle and state management, in a reusable way.
-
internalGetEJBLocalObjectImpl
protected EJBLocalObjectImpl internalGetEJBLocalObjectImpl(Object primaryKey, boolean incrementRefCount)
-
internalGetEJBLocalObjectImpl
protected EJBLocalObjectImpl internalGetEJBLocalObjectImpl(Object primaryKey, boolean incrementRefCount, boolean cacheEJBO)
-
getPooledEJB
protected EntityContextImpl getPooledEJB()
-
addPooledEJB
protected void addPooledEJB(EntityContextImpl context)
-
passivateAndPoolEJB
protected void passivateAndPoolEJB(EntityContextImpl context)
-
activateEJBFromPool
protected EntityContextImpl activateEJBFromPool(Object primaryKey, EjbInvocation inv)
Called from getContext and getEJBWithIncompleteTx Get an EJB in the ready state (i.e. which is not doing any invocations and doesnt have any incomplete Tx), for the ejbObject provided in the EjbInvocation. Concurrent invocations should get *different* instances.
-
removeIncompleteTxEJB
protected void removeIncompleteTxEJB(EntityContextImpl context, boolean updateTxBeanTable)
Called from releaseContext if ejb is removed, from afterCompletion, and from passivateEJB.
-
isIdentical
protected boolean isIdentical(EJBObjectImpl ejbObjImpl, jakarta.ejb.EJBObject other) throws RemoteException
- Overrides:
isIdentical
in classBaseContainer
- Throws:
RemoteException
-
callEJBLoad
protected void callEJBLoad(jakarta.ejb.EntityBean ejb, EntityContextImpl context, boolean activeTx) throws Exception
- Throws:
Exception
-
callEJBStore
protected void callEJBStore(jakarta.ejb.EntityBean ejb, EntityContextImpl context) throws Exception
- Throws:
Exception
-
callEJBRemove
protected void callEJBRemove(jakarta.ejb.EntityBean ejb, EntityContextImpl context) throws Exception
- Throws:
Exception
-
doTimerInvocationInit
protected void doTimerInvocationInit(EjbInvocation inv, Object primaryKey) throws Exception
Description copied from class:BaseContainer
This is implemented by concrete containers that support TimedObjects.- Overrides:
doTimerInvocationInit
in classBaseContainer
- Throws:
Exception
-
doConcreteContainerShutdown
protected void doConcreteContainerShutdown(boolean appBeingUndeployed)
- Specified by:
doConcreteContainerShutdown
in classBaseContainer
-
afterNewlyActivated
protected void afterNewlyActivated(EntityContextImpl context)
-
createEntityContextInstance
protected EntityContextImpl createEntityContextInstance(jakarta.ejb.EntityBean ejb, EntityContainer entityContainer)
-
createReadyStore
protected void createReadyStore(int cacheSize, int numberOfVictimsToSelect, float loadFactor, long idleTimeout) throws Exception
- Throws:
Exception
-
createEJBObjectStores
protected void createEJBObjectStores(int cacheSize, int numberOfVictimsToSelect, long idleTimeout) throws Exception
- Throws:
Exception
-
getReadyEJB
protected EntityContextImpl getReadyEJB(EjbInvocation inv)
-
addReadyEJB
protected void addReadyEJB(EntityContextImpl context)
-
destroyReadyStoreOnUndeploy
protected void destroyReadyStoreOnUndeploy()
-
removeContextFromReadyStore
protected void removeContextFromReadyStore(Object primaryKey, EntityContextImpl context)
-
addProxyInterfacesSetClass
protected void addProxyInterfacesSetClass(Set proxyInterfacesSet, boolean local)
- Overrides:
addProxyInterfacesSetClass
in classBaseContainer
-
doFlush
protected void doFlush(EjbInvocation inv)
- Overrides:
doFlush
in classBaseContainer
-
-