|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.ejb.containers.BaseContainer
com.sun.ejb.containers.EntityContainer
public class EntityContainer
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):
| Nested Class Summary | |
|---|---|
protected class |
EntityContainer.CacheProperties
|
protected class |
EntityContainer.EJBObjectCacheVictimHandler
|
protected class |
EntityContainer.LocalEJBObjectCacheVictimHandler
|
| Nested classes/interfaces inherited from class com.sun.ejb.containers.BaseContainer |
|---|
BaseContainer.ContainerType |
| Field Summary | |
|---|---|
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 com.sun.ejb.containers.EntityContainer.IdleBeansPassivator |
idleEJBObjectPassivator
|
protected com.sun.ejb.containers.EntityContainer.IdleBeansPassivator |
idleLocalEJBObjectPassivator
|
protected boolean |
isContainerManagedPers
|
protected boolean |
isReentrant
|
protected static LocalStringManagerImpl |
localStrings
|
protected java.util.Stack |
passivationCandidates
|
protected Cache |
readyStore
|
protected int |
totalPassivationErrors
|
protected int |
totalPassivations
|
| 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 | |
|---|---|
protected |
EntityContainer(BaseContainer.ContainerType containerType,
EjbDescriptor desc,
java.lang.ClassLoader loader)
|
protected |
EntityContainer(EjbDescriptor desc,
java.lang.ClassLoader loader)
This constructor is called from the JarManager when a Jar is deployed. |
| Method Summary | |
|---|---|
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(java.lang.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 |
addReadyEJB(EntityContextImpl context)
|
protected void |
afterNewlyActivated(EntityContextImpl context)
|
protected void |
callEJBLoad(EntityBean ejb,
EntityContextImpl context,
boolean activeTx)
|
protected void |
callEJBRemove(EntityBean ejb,
EntityContextImpl context)
|
protected void |
callEJBStore(EntityBean ejb,
EntityContextImpl context)
|
void |
cancelTimerTasks()
cancel a timer task to trim timed out entries in the cache. |
protected void |
checkUnfinishedTx(Transaction prevTx,
EjbInvocation inv)
|
protected void |
createEJBObjectStores(int cacheSize,
int numberOfVictimsToSelect,
long idleTimeout)
|
protected EntityContextImpl |
createEntityContextInstance(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(java.lang.Object primaryKey,
java.lang.reflect.Method removeMethod,
boolean local)
|
protected void |
doFlush(EjbInvocation inv)
|
EJBLocalObject |
getEJBLocalObjectForPrimaryKey(java.lang.Object pkey)
Called only from the Persistence Manager for EJB2.0 CMP EntityBeans. |
EJBLocalObject |
getEJBLocalObjectForPrimaryKey(java.lang.Object pkey,
EJBContext ctx)
Called only from the Persistence Manager for EJB2.0 CMP EntityBeans. |
EJBObject |
getEJBObjectForPrimaryKey(java.lang.Object pkey)
Called only from the Persistence Manager for EJB2.0 CMP EntityBeans. |
int |
getMaxCacheSize()
|
int |
getMaxPoolSize()
|
protected EjbMonitoringStatsProvider |
getMonitoringStatsProvider(java.lang.String appName,
java.lang.String modName,
java.lang.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(java.lang.Object primaryKey)
The following are private methods for implementing internal logic for lifecyle and state management, in a reusable way. |
protected EJBLocalObjectImpl |
internalGetEJBLocalObjectImpl(java.lang.Object primaryKey,
boolean incrementRefCount)
|
protected EJBLocalObjectImpl |
internalGetEJBLocalObjectImpl(java.lang.Object primaryKey,
boolean incrementRefCount,
boolean cacheEJBO)
|
protected EJBObjectImpl |
internalGetEJBObjectImpl(java.lang.Object primaryKey,
byte[] streamKey)
|
protected EJBObjectImpl |
internalGetEJBObjectImpl(java.lang.Object primaryKey,
byte[] streamKey,
boolean incrementRefCount)
|
protected EJBObjectImpl |
internalGetEJBObjectImpl(java.lang.Object primaryKey,
byte[] streamKey,
boolean incrementRefCount,
boolean cacheEJBO)
|
protected java.lang.Object |
invokeFindByPrimaryKey(java.lang.reflect.Method method,
EjbInvocation inv,
java.lang.Object[] args)
|
void |
onReady()
Called when server instance is Ready |
protected void |
passivateAndPoolEJB(EntityContextImpl context)
|
void |
postCreate(EjbInvocation inv,
java.lang.Object primaryKey)
This is called from the generated "HelloEJBHomeImpl" create* method, after ejb.ejbCreate() has been called and before ejb.ejbPostCreate() is called. |
java.lang.Object |
postFind(EjbInvocation inv,
java.lang.Object primaryKeys,
java.lang.Object[] findParams)
Convert a collection of primary keys to a collection of EJBObjects. |
protected InvocationInfo |
postProcessInvocationInfo(InvocationInfo invInfo)
|
protected void |
preCreate(EjbInvocation inv,
EntityContextImpl context)
Called from getContext before the ejb.ejbCreate is called |
protected void |
preFind(EjbInvocation inv,
EntityContextImpl context)
Called from getContext before the ejb.ejbFind* is called |
protected void |
preInitialize(EjbDescriptor desc,
java.lang.ClassLoader loader)
|
void |
preSelect()
Called from CMP PersistentManager |
protected void |
registerMonitorableComponents()
|
void |
releaseContext(EjbInvocation inv)
This is called from BaseContainer.postInvoke after EntityContainer.preInvokeTx has been called. |
protected void |
removeBean(EjbInvocation inv)
container.preInvoke() must already be done. |
protected void |
removeBean(EJBLocalRemoteObject ejbo,
java.lang.reflect.Method removeMethod,
boolean local)
|
void |
removeBeanUnchecked(EJBLocalObject localObj)
Remove a bean. |
void |
removeBeanUnchecked(java.lang.Object primaryKey)
Remove a bean. |
protected void |
removeContextFromReadyStore(java.lang.Object primaryKey,
EntityContextImpl context)
|
protected void |
removeIncompleteTxEJB(EntityContextImpl context,
boolean updateTxBeanTable)
Called from releaseContext if ejb is removed, from afterCompletion, and from passivateEJB. |
com.sun.ejb.containers.EntityContainer.IdleBeansPassivator |
setupIdleBeansPassivator(Cache cache)
setup a timer task to trim timed out entries in the cache. |
void |
trimEvent(java.lang.Object primaryKey,
java.lang.Object context)
|
protected boolean |
willInvokeWithClientTx(EjbInvocation inv)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final LocalStringManagerImpl localStrings
protected static final int HIGH_WATER_MARK
protected EJBObjectCache ejbObjectStore
protected EJBObjectCache ejbLocalObjectStore
protected java.util.Stack passivationCandidates
protected Cache readyStore
protected AbstractPool entityCtxPool
protected boolean isReentrant
protected boolean isContainerManagedPers
protected final float DEFAULT_LOAD_FACTOR
protected final int DEFAULT_CACHE_SIZE
protected int _maxBuckets
protected IASEjbExtraDescriptors iased
protected BeanCacheDescriptor beanCacheDes
protected BeanPoolDescriptor beanPoolDes
protected EjbContainer ejbContainer
protected com.sun.ejb.containers.EntityContainer.IdleBeansPassivator idleEJBObjectPassivator
protected com.sun.ejb.containers.EntityContainer.IdleBeansPassivator idleLocalEJBObjectPassivator
protected boolean defaultCacheEJBO
protected int ejboRemoved
protected int totalPassivations
protected int totalPassivationErrors
| Constructor Detail |
|---|
protected EntityContainer(EjbDescriptor desc,
java.lang.ClassLoader loader)
throws java.lang.Exception
java.lang.Exception - on error
protected EntityContainer(BaseContainer.ContainerType containerType,
EjbDescriptor desc,
java.lang.ClassLoader loader)
throws java.lang.Exception
java.lang.Exception| Method Detail |
|---|
protected void preInitialize(EjbDescriptor desc,
java.lang.ClassLoader loader)
preInitialize in class BaseContainer
public com.sun.ejb.containers.EntityContainer.IdleBeansPassivator setupIdleBeansPassivator(Cache cache)
throws java.lang.Exception
cache - cache which is used to setup the timer task
java.lang.Exceptionpublic void cancelTimerTasks()
protected InvocationInfo postProcessInvocationInfo(InvocationInfo invInfo)
postProcessInvocationInfo in class BaseContainer
protected void initializeHome()
throws java.lang.Exception
java.lang.Exceptionprotected void registerMonitorableComponents()
registerMonitorableComponents in class BaseContainer
protected EjbMonitoringStatsProvider getMonitoringStatsProvider(java.lang.String appName,
java.lang.String modName,
java.lang.String ejbName)
getMonitoringStatsProvider in class BaseContainerpublic void onReady()
BaseContainer
onReady in interface ContaineronReady in class BaseContainerpublic int getMaxCacheSize()
public int getSteadyPoolSize()
public int getMaxPoolSize()
public long getPooledCount()
public long getReadyCount()
protected ComponentContext _getContext(EjbInvocation inv)
_getContext in class BaseContainerprotected boolean willInvokeWithClientTx(EjbInvocation inv)
public void releaseContext(EjbInvocation inv)
releaseContext in class BaseContainer
protected void preCreate(EjbInvocation inv,
EntityContextImpl context)
public void postCreate(EjbInvocation inv,
java.lang.Object primaryKey)
throws CreateException
postCreate in interface ContainerpostCreate in class BaseContainerprimaryKey - the value returned from ejbCreate.
CreateException
protected java.lang.Object invokeFindByPrimaryKey(java.lang.reflect.Method method,
EjbInvocation inv,
java.lang.Object[] args)
throws java.lang.Throwable
java.lang.Throwable
protected void preFind(EjbInvocation inv,
EntityContextImpl context)
public void preSelect()
throws EJBException
preSelect in interface ContainerpreSelect in class BaseContainerEJBException - 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.
public java.lang.Object postFind(EjbInvocation inv,
java.lang.Object primaryKeys,
java.lang.Object[] findParams)
throws FinderException
postFind in interface ContainerpostFind in class BaseContainerprimaryKeys - the primaryKey or collection of primaryKeys
(Collection/Enumeration) returned from ejbFind.findParams - the parameters to the ejbFind method.
FinderExceptionpublic EJBObject getEJBObjectForPrimaryKey(java.lang.Object pkey)
getEJBObjectForPrimaryKey in interface ContainergetEJBObjectForPrimaryKey in class BaseContainer
public EJBLocalObject getEJBLocalObjectForPrimaryKey(java.lang.Object pkey,
EJBContext ctx)
getEJBLocalObjectForPrimaryKey in interface ContainergetEJBLocalObjectForPrimaryKey in class BaseContainerpkey - The primary key for which the EJBLocalObject is requiredctx - The context associated with the bean from which the accessor method is invoked
public EJBLocalObject getEJBLocalObjectForPrimaryKey(java.lang.Object pkey)
getEJBLocalObjectForPrimaryKey in interface ContainergetEJBLocalObjectForPrimaryKey in class BaseContainer
protected void doEJBHomeRemove(java.lang.Object primaryKey,
java.lang.reflect.Method removeMethod,
boolean local)
throws RemoveException,
EJBException,
java.rmi.RemoteException
doEJBHomeRemove in class BaseContainerRemoveException
EJBException
java.rmi.RemoteException
protected void removeBean(EJBLocalRemoteObject ejbo,
java.lang.reflect.Method removeMethod,
boolean local)
throws RemoveException,
EJBException,
java.rmi.RemoteException
RemoveException
EJBException
java.rmi.RemoteException
protected void removeBean(EjbInvocation inv)
throws RemoveException
RemoveException - if an error occurs while removing the beanpublic void removeBeanUnchecked(EJBLocalObject localObj)
removeBeanUnchecked in interface ContainerremoveBeanUnchecked in class BaseContainerpublic void removeBeanUnchecked(java.lang.Object primaryKey)
removeBeanUnchecked in interface ContainerremoveBeanUnchecked in class BaseContainer
protected void checkUnfinishedTx(Transaction prevTx,
EjbInvocation inv)
checkUnfinishedTx in class BaseContainer
public void trimEvent(java.lang.Object primaryKey,
java.lang.Object context)
trimEvent in interface CacheListenerprotected EJBLocalObjectImpl internalGetEJBLocalObjectImpl(java.lang.Object primaryKey)
protected EJBLocalObjectImpl internalGetEJBLocalObjectImpl(java.lang.Object primaryKey,
boolean incrementRefCount)
protected EJBLocalObjectImpl internalGetEJBLocalObjectImpl(java.lang.Object primaryKey,
boolean incrementRefCount,
boolean cacheEJBO)
protected EJBObjectImpl internalGetEJBObjectImpl(java.lang.Object primaryKey,
byte[] streamKey)
protected EJBObjectImpl internalGetEJBObjectImpl(java.lang.Object primaryKey,
byte[] streamKey,
boolean incrementRefCount)
protected EJBObjectImpl internalGetEJBObjectImpl(java.lang.Object primaryKey,
byte[] streamKey,
boolean incrementRefCount,
boolean cacheEJBO)
protected EntityContextImpl getPooledEJB()
protected void addPooledEJB(EntityContextImpl context)
protected void passivateAndPoolEJB(EntityContextImpl context)
protected EntityContextImpl activateEJBFromPool(java.lang.Object primaryKey,
EjbInvocation inv)
protected void removeIncompleteTxEJB(EntityContextImpl context,
boolean updateTxBeanTable)
protected void callEJBLoad(EntityBean ejb,
EntityContextImpl context,
boolean activeTx)
throws java.lang.Exception
java.lang.Exception
protected void callEJBStore(EntityBean ejb,
EntityContextImpl context)
throws java.lang.Exception
java.lang.Exception
protected void callEJBRemove(EntityBean ejb,
EntityContextImpl context)
throws java.lang.Exception
java.lang.Exceptionprotected void doConcreteContainerShutdown(boolean appBeingUndeployed)
doConcreteContainerShutdown in class BaseContainerprotected void afterNewlyActivated(EntityContextImpl context)
protected EntityContextImpl createEntityContextInstance(EntityBean ejb,
EntityContainer entityContainer)
protected void createReadyStore(int cacheSize,
int numberOfVictimsToSelect,
float loadFactor,
long idleTimeout)
throws java.lang.Exception
java.lang.Exception
protected void createEJBObjectStores(int cacheSize,
int numberOfVictimsToSelect,
long idleTimeout)
throws java.lang.Exception
java.lang.Exceptionprotected EntityContextImpl getReadyEJB(EjbInvocation inv)
protected void addReadyEJB(EntityContextImpl context)
protected void destroyReadyStoreOnUndeploy()
protected void removeContextFromReadyStore(java.lang.Object primaryKey,
EntityContextImpl context)
protected void doFlush(EjbInvocation inv)
doFlush in class BaseContainer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||