org.jboss.ejb
Class EntityContainer

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended byorg.jboss.system.ServiceMBeanSupport
          extended byorg.jboss.ejb.Container
              extended byorg.jboss.ejb.EntityContainer
All Implemented Interfaces:
ContainerMBean, EJBProxyFactoryContainer, EntityContainerMBean, InstancePoolContainer, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class EntityContainer
extends Container
implements EJBProxyFactoryContainer, InstancePoolContainer, EntityContainerMBean

This is a Container for EntityBeans (both BMP and CMP).

Version:
$Revision: 1.80.2.25 $
Author:
Rickard Öberg, Marc Fleury, Sebastien Alborini, Daniel OConnor, Bill Burke, Andreas Schaefer, Dain Sundstrom
See Also:
Container, EntityEnterpriseContext

Nested Class Summary
 
Nested classes inherited from class org.jboss.ejb.Container
Container.AbstractContainerInterceptor
 
Field Summary
protected  Map beanMapping
          These are the mappings between the remote/local interface methods and the bean methods.
protected static GlobalTxEntityMap globalTxEntityMap
          This provides a way to find the entities that are part of a given transaction EntitySynchronizationInterceptor and InstanceSynchronization manage this instance.
protected  Map homeMapping
          These are the mappings between the home interface methods and the container methods.
protected  InstanceCache instanceCache
          This is the instance cache for this container
protected  InstancePool instancePool
          This is the instancepool that is to be used
protected  Interceptor interceptor
          This is the first interceptor in the chain.
protected  EntityPersistenceManager persistenceManager
          This is the persistence manager for this container
protected  boolean readOnly
          readOnly determines if state can be written to resource manager.
 
Fields inherited from class org.jboss.ejb.Container
BASE_EJB_CONTAINER_NAME, beanClass, classLoader, createCount, EJB_CONTAINER_QUERY_NAME, ejbModule, homeInterface, invokeStats, localClassLoader, localHomeInterface, localInterface, localProxyFactory, lockManager, marshalledInvocationMapping, metaData, proxyFactories, proxyFactoryTL, remoteInterface, removeCount, rm, securityProxy, sm, tm, webClassLoader
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
EntityContainer()
           
 
Method Summary
 void addInterceptor(Interceptor in)
           
protected  void checkCoherency()
           
 Object createBeanClassInstance()
          Returns a new instance of the bean class or a subclass of the bean class.
 javax.ejb.EJBObject createHome(Invocation mi)
          This method takes care of the wiring of the "EJBObject" trio (target, context, proxy).
 javax.ejb.EJBLocalObject createLocalHome(Invocation mi)
          Local home interface implementation
protected  void createService()
          The EJBDeployer calls this method.
protected  void destroyService()
          A default implementation of destroying the container service (no-op).
 Object find(Invocation mi)
          This methods finds the target instances by delegating to the persistence manager It then manufactures EJBObject for all the involved instances found.
 Object findLocal(Invocation mi)
           
 void flushCache()
          Flush the cache
 long getCacheSize()
           
 javax.ejb.EJBHome getEJBHome(Invocation mi)
           
 javax.ejb.EJBLocalHome getEJBLocalHome(Invocation mi)
          MF FIXME these are implemented on the client
 javax.ejb.EJBMetaData getEJBMetaDataHome(Invocation mi)
           
 javax.ejb.EJBObject getEJBObject(Invocation mi)
          A method for the getEJBObject from the handle
static GlobalTxEntityMap getGlobalTxEntityMap()
           
 javax.ejb.Handle getHandle(Invocation mi)
           
 Class getHomeClass()
          ???
 javax.ejb.HomeHandle getHomeHandleHome(Invocation mi)
           
 InstanceCache getInstanceCache()
           
 InstancePool getInstancePool()
          Get the instance pool for the container.
 Interceptor getInterceptor()
           
 LocalProxyFactory getLocalProxyFactory()
          ???
 EntityPersistenceManager getPersistenceManager()
           
 Object getPrimaryKey(Invocation mi)
           
 Class getRemoteClass()
          ???
 Object internalInvoke(Invocation mi)
          This method is called when a method call comes in on an EJBObject.
 Object internalInvokeHome(Invocation mi)
          This method is called when a method call comes in on the Home object.
 void invokeEjbStore(EntityEnterpriseContext ctx)
          Invokes ejbStore method on the instance
 boolean isIdentical(Invocation mi)
           
 boolean isReadOnly()
           
 void postCreateHome(Invocation mi)
          Delegates to the persistence manager postCreateEntityMethod.
 void postCreateLocalHome(Invocation mi)
          Delegates to the persistence manager postCreateEntityMethod.
 void remove(Invocation mi)
           
 void removeHome(Invocation mi)
           
 void removeLocalHome(Invocation mi)
           
 void resetStatistic()
           
 Map retrieveStatistic()
           
 void setInstanceCache(InstanceCache ic)
           
 void setInstancePool(InstancePool ip)
           
 void setPersistenceManager(EntityPersistenceManager pm)
           
protected  void setupBeanMapping()
           
protected  void setupHomeMapping()
           
protected  void setupMarshalledInvocationMapping()
           
protected  void startService()
          A default implementation of starting the container service.
protected  void stopService()
          A default implementation of stopping the container service (no-op).
 void storeEntity(EntityEnterpriseContext ctx)
          For CMP actually stores the instance
static void synchronizeEntitiesWithinTransaction(Transaction tx)
          Stores all of the entities associated with the specified transaction.
 
Methods inherited from class org.jboss.ejb.Container
addProxyFactory, getBeanClass, getBeanMetaData, getClassLoader, getCreateCount, getDeploymentInfo, getEjbModule, getInvokeStats, getJmxName, getLocalClass, getLocalClassLoader, getLocalHomeClass, getLockManager, getMethodPermissions, getProxyFactory, getRealmMapping, getRemoveCount, getSecurityManager, getSecurityProxy, getTransactionManager, getWebClassLoader, invoke, isCallByValue, lookupProxyFactory, setBeanMetaData, setClassLoader, setDeploymentInfo, setEjbModule, setLocalClassLoader, setLockManager, setProxyFactory, setRealmMapping, setSecurityManager, setSecurityProxy, setTransactionManager, setWebClassLoader
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.ejb.EJBProxyFactoryContainer
getLocalClass, getLocalHomeClass, getProxyFactory
 
Methods inherited from interface org.jboss.ejb.ContainerMBean
getBeanMetaData, getCreateCount, getEjbModule, getInvokeStats, getRemoveCount, invoke
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

homeMapping

protected Map homeMapping
These are the mappings between the home interface methods and the container methods.


beanMapping

protected Map beanMapping
These are the mappings between the remote/local interface methods and the bean methods.


persistenceManager

protected EntityPersistenceManager persistenceManager
This is the persistence manager for this container


instanceCache

protected InstanceCache instanceCache
This is the instance cache for this container


instancePool

protected InstancePool instancePool
This is the instancepool that is to be used


interceptor

protected Interceptor interceptor
This is the first interceptor in the chain. The last interceptor must be provided by the container itself.


readOnly

protected boolean readOnly
readOnly determines if state can be written to resource manager.


globalTxEntityMap

protected static GlobalTxEntityMap globalTxEntityMap
This provides a way to find the entities that are part of a given transaction EntitySynchronizationInterceptor and InstanceSynchronization manage this instance.

Constructor Detail

EntityContainer

public EntityContainer()
Method Detail

getGlobalTxEntityMap

public static GlobalTxEntityMap getGlobalTxEntityMap()

synchronizeEntitiesWithinTransaction

public static void synchronizeEntitiesWithinTransaction(Transaction tx)
Stores all of the entities associated with the specified transaction. As per the spec 9.6.4, entities must be synchronized with the datastore when an ejbFind is called. Also, all entities within entire transaction should be synchronized before a remove, otherwise there may be problems with 'cascade delete'.

Parameters:
tx - the transaction that associated entites will be stored

isReadOnly

public boolean isReadOnly()

getLocalProxyFactory

public LocalProxyFactory getLocalProxyFactory()
Description copied from interface: EJBProxyFactoryContainer
???

Specified by:
getLocalProxyFactory in interface EJBProxyFactoryContainer
Returns:
???

setInstancePool

public void setInstancePool(InstancePool ip)

getInstancePool

public InstancePool getInstancePool()
Description copied from interface: InstancePoolContainer
Get the instance pool for the container.

Specified by:
getInstancePool in interface InstancePoolContainer
Returns:
The instance pool for the container.

setInstanceCache

public void setInstanceCache(InstanceCache ic)

getInstanceCache

public InstanceCache getInstanceCache()

getPersistenceManager

public EntityPersistenceManager getPersistenceManager()

setPersistenceManager

public void setPersistenceManager(EntityPersistenceManager pm)

addInterceptor

public void addInterceptor(Interceptor in)
Specified by:
addInterceptor in class Container

getInterceptor

public Interceptor getInterceptor()

getHomeClass

public Class getHomeClass()
Description copied from interface: EJBProxyFactoryContainer
???

Specified by:
getHomeClass in interface EJBProxyFactoryContainer
Returns:
???

getRemoteClass

public Class getRemoteClass()
Description copied from interface: EJBProxyFactoryContainer
???

Specified by:
getRemoteClass in interface EJBProxyFactoryContainer
Returns:
???

createBeanClassInstance

public Object createBeanClassInstance()
                               throws Exception
Returns a new instance of the bean class or a subclass of the bean class. If this is 1.x cmp, simply return a new instance of the bean class. If this is 2.x cmp, return a subclass that provides an implementation of the abstract accessors.

Overrides:
createBeanClassInstance in class Container
Returns:
The new instance.
Throws:
Exception
See Also:
Class.newInstance()

createService

protected void createService()
                      throws Exception
Description copied from class: Container
The EJBDeployer calls this method. The EJBDeployer has set all the plugins and interceptors that this bean requires and now proceeds to initialize the chain. The method looks for the standard classes in the URL, sets up the naming environment of the bean. The concrete container classes should override this method to introduce implementation specific initialization behaviour.

Overrides:
createService in class Container
Throws:
Exception - if loading the bean class failed (ClassNotFoundException) or setting up "java:" naming environment failed (DeploymentException)

startService

protected void startService()
                     throws Exception
Description copied from class: Container
A default implementation of starting the container service. The container registers it's dynamic MBean interface in the JMX base. The concrete container classes should override this method to introduce implementation specific start behaviour.

Overrides:
startService in class Container
Throws:
Exception - An exception that occured during start

stopService

protected void stopService()
                    throws Exception
Description copied from class: Container
A default implementation of stopping the container service (no-op). The concrete container classes should override this method to introduce implementation specific stop behaviour.

Overrides:
stopService in class Container
Throws:
Exception

destroyService

protected void destroyService()
                       throws Exception
Description copied from class: Container
A default implementation of destroying the container service (no-op). The concrete container classes should override this method to introduce implementation specific destroy behaviour.

Overrides:
destroyService in class Container
Throws:
Exception

internalInvokeHome

public Object internalInvokeHome(Invocation mi)
                          throws Exception
Description copied from class: Container
This method is called when a method call comes in on the Home object. The Container forwards this call to the interceptor chain for further processing.

Specified by:
internalInvokeHome in class Container
Parameters:
mi - the object holding all info about this invocation
Returns:
the result of the home invocation
Throws:
Exception

internalInvoke

public Object internalInvoke(Invocation mi)
                      throws Exception
Description copied from class: Container
This method is called when a method call comes in on an EJBObject. The Container forwards this call to the interceptor chain for further processing.

Specified by:
internalInvoke in class Container
Parameters:
mi - - the method invocation representation
Returns:
the result of the invocation
Throws:
Exception

remove

public void remove(Invocation mi)
            throws RemoteException,
                   javax.ejb.RemoveException
Throws:
RemoteException
javax.ejb.RemoveException

getHandle

public javax.ejb.Handle getHandle(Invocation mi)
                           throws RemoteException
Throws:
Error - Not yet implemented.
RemoteException

getPrimaryKey

public Object getPrimaryKey(Invocation mi)
                     throws RemoteException
Throws:
RemoteException

getEJBHome

public javax.ejb.EJBHome getEJBHome(Invocation mi)
                             throws RemoteException
Throws:
IllegalStateException - If container invoker is null.
RemoteException

isIdentical

public boolean isIdentical(Invocation mi)
                    throws RemoteException
Throws:
RemoteException

getEJBLocalHome

public javax.ejb.EJBLocalHome getEJBLocalHome(Invocation mi)
MF FIXME these are implemented on the client


removeLocalHome

public void removeLocalHome(Invocation mi)
                     throws RemoteException,
                            javax.ejb.RemoveException
Throws:
Error - Not yet implemented.
RemoteException
javax.ejb.RemoveException

createLocalHome

public javax.ejb.EJBLocalObject createLocalHome(Invocation mi)
                                         throws Exception
Local home interface implementation

Throws:
Exception

postCreateLocalHome

public void postCreateLocalHome(Invocation mi)
                         throws Exception
Delegates to the persistence manager postCreateEntityMethod.

Throws:
Exception

findLocal

public Object findLocal(Invocation mi)
                 throws Exception
Throws:
Exception

find

public Object find(Invocation mi)
            throws Exception
This methods finds the target instances by delegating to the persistence manager It then manufactures EJBObject for all the involved instances found.

Throws:
Exception

storeEntity

public void storeEntity(EntityEnterpriseContext ctx)
                 throws Exception
For CMP actually stores the instance

Throws:
Exception

invokeEjbStore

public void invokeEjbStore(EntityEnterpriseContext ctx)
                    throws Exception
Invokes ejbStore method on the instance

Parameters:
ctx - the instance to invoke ejbStore on
Throws:
Exception

postCreateHome

public void postCreateHome(Invocation mi)
                    throws Exception
Delegates to the persistence manager postCreateEntityMethod.

Throws:
Exception

createHome

public javax.ejb.EJBObject createHome(Invocation mi)
                               throws Exception
This method takes care of the wiring of the "EJBObject" trio (target, context, proxy). It delegates to the persistence manager.

Throws:
Exception

getEJBObject

public javax.ejb.EJBObject getEJBObject(Invocation mi)
                                 throws RemoteException
A method for the getEJBObject from the handle

Throws:
RemoteException

removeHome

public void removeHome(Invocation mi)
                throws RemoteException,
                       javax.ejb.RemoveException
Throws:
Error - Not yet implemented.
RemoteException
javax.ejb.RemoveException

getEJBMetaDataHome

public javax.ejb.EJBMetaData getEJBMetaDataHome(Invocation mi)
                                         throws RemoteException
Throws:
RemoteException

getHomeHandleHome

public javax.ejb.HomeHandle getHomeHandleHome(Invocation mi)
                                       throws RemoteException
Throws:
Error - Not yet implemented.
RemoteException

getCacheSize

public long getCacheSize()
Specified by:
getCacheSize in interface EntityContainerMBean
Returns:
the current cache size

flushCache

public void flushCache()
Flush the cache

Specified by:
flushCache in interface EntityContainerMBean

retrieveStatistic

public Map retrieveStatistic()

resetStatistic

public void resetStatistic()

setupHomeMapping

protected void setupHomeMapping()
                         throws Exception
Throws:
Exception

setupBeanMapping

protected void setupBeanMapping()
                         throws Exception
Throws:
Exception

setupMarshalledInvocationMapping

protected void setupMarshalledInvocationMapping()
                                         throws Exception
Throws:
Exception

checkCoherency

protected void checkCoherency()
                       throws Exception
Throws:
Exception


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.