站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 server API Documentation 英文版文档

CMPInMemoryPersistenceManager (JBoss Server API) - JBoss 4.0.1 sp1 server API Documentation 英文版文档


org.jboss.ejb.plugins
Class CMPInMemoryPersistenceManager

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended byorg.jboss.system.ServiceMBeanSupport
          extended byorg.jboss.ejb.plugins.CMPInMemoryPersistenceManager
All Implemented Interfaces:
AllowedOperationsFlags, ContainerPlugin, EntityPersistenceStore, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class CMPInMemoryPersistenceManager
extends org.jboss.system.ServiceMBeanSupport
implements EntityPersistenceStore

EntityPersistenceStore implementation storing values in-memory for very efficient access.

Version:
$Revision: 1.8 $
Author:
Sacha Labourey., Jason Dillon

Revisions:

28.12.2001 - Sacha Labourey:

  • First implementation highly based on CMPFilePersistenceManager

25.05.2002 - Dain Sundstrom:

  • Replaced FinderResults with Collection
See Also:
EntityPersistenceStore, CMPFilePersistenceManager

Field Summary
protected  HashMap beans
           
protected  EntityContainer con
           
protected  Field idField
           
protected  Method isModified
          Optional isModified method used by storeEntity.
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.ejb.AllowedOperationsFlags
IN_AFTER_BEGIN, IN_AFTER_COMPLETION, IN_BEFORE_COMPLETION, IN_BUSINESS_METHOD, IN_EJB_ACTIVATE, IN_EJB_CREATE, IN_EJB_FIND, IN_EJB_HOME, IN_EJB_LOAD, IN_EJB_PASSIVATE, IN_EJB_POST_CREATE, IN_EJB_REMOVE, IN_EJB_STORE, IN_EJB_TIMEOUT, IN_INTERCEPTOR_METHOD, IN_SERVICE_ENDPOINT_METHOD, IN_SET_ENTITY_CONTEXT, IN_SET_MESSAGE_DRIVEN_CONTEXT, IN_SET_SESSION_CONTEXT, IN_UNSET_ENTITY_CONTEXT, NOT_ALLOWED
 
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
CMPInMemoryPersistenceManager()
           
 
Method Summary
 void activateEntity(EntityEnterpriseContext instance)
          Non-operation.
 Object createBeanClassInstance()
          Returns a new instance of the bean class or a subclass of the bean class.
 Object createEntity(Method m, Object[] args, EntityEnterpriseContext ctx)
          This method is called whenever an entity is to be created.
protected  void createService()
          create the service, do expensive operations etc
 Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory)
          This method is called when collections of entities are to be found.
 Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory)
          This method is called when single entities are to be found.
 void initEntity(EntityEnterpriseContext ctx)
          Initializes the instance context.
 boolean isModified(EntityEnterpriseContext ctx)
          This method is used to determined whether the instance was modified.
 boolean isStoreRequired(EntityEnterpriseContext ctx)
          This method is used to determine if an entity should be stored.
 void loadEntity(EntityEnterpriseContext ctx)
          This method is called whenever an entity shall be load from the underlying storage.
 void passivateEntity(EntityEnterpriseContext instance)
          Non-operation.
 Object postCreateEntity(Method m, Object[] args, EntityEnterpriseContext ctx)
          This method is called after the createEntity.
 void removeEntity(EntityEnterpriseContext ctx)
          This method is called when an entity shall be removed from the underlying storage.
 void setContainer(Container con)
          This callback is set by the container so that the plugin may access it
protected  void stopService()
           
 void storeEntity(EntityEnterpriseContext ctx)
          This method is called whenever an entity shall be stored to the underlying storage.
protected  void storeEntity(Object id, Object obj)
           
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, startService, 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.system.Service
create, destroy, start, stop
 

Field Detail

con

protected EntityContainer con

beans

protected HashMap beans

idField

protected Field idField

isModified

protected Method isModified
Optional isModified method used by storeEntity.

Constructor Detail

CMPInMemoryPersistenceManager

public CMPInMemoryPersistenceManager()
Method Detail

setContainer

public void setContainer(Container con)
This callback is set by the container so that the plugin may access it

Specified by:
setContainer in interface ContainerPlugin
Parameters:
con - The container using this plugin.
Throws:
ClassCastException - Container is not a EntityContainer.

createService

protected void createService()
                      throws Exception
create the service, do expensive operations etc

Throws:
Exception

stopService

protected void stopService()
                    throws Exception
Throws:
Exception

createBeanClassInstance

public Object createBeanClassInstance()
                               throws Exception
Returns a new instance of the bean class or a subclass of the bean class.

Specified by:
createBeanClassInstance in interface EntityPersistenceStore
Returns:
the new instance
Throws:
Exception

initEntity

public void initEntity(EntityEnterpriseContext ctx)
Initializes the instance context.

This method is called before createEntity, and should reset the value of all cmpFields to 0 or null.

Specified by:
initEntity in interface EntityPersistenceStore
Parameters:
ctx -

createEntity

public Object createEntity(Method m,
                           Object[] args,
                           EntityEnterpriseContext ctx)
                    throws Exception
This method is called whenever an entity is to be created. The persistence manager is responsible for handling the results properly wrt the persistent store.

Specified by:
createEntity in interface EntityPersistenceStore
Parameters:
m - the create method in the home interface that was called
args - any create parameters
ctx - the instance being used for this create call
Returns:
The primary key computed by CMP PM or null for BMP
Throws:
Exception

postCreateEntity

public Object postCreateEntity(Method m,
                               Object[] args,
                               EntityEnterpriseContext ctx)
                        throws Exception
This method is called after the createEntity. The persistence manager is responsible for handling the results properly wrt the persistent store.

Specified by:
postCreateEntity in interface EntityPersistenceStore
Parameters:
m - the ejbPostCreate method in the bean class that was called
args - any create parameters
ctx - the instance being used for this create call
Returns:
null
Throws:
Exception

findEntity

public Object findEntity(Method finderMethod,
                         Object[] args,
                         EntityEnterpriseContext instance,
                         GenericEntityObjectFactory factory)
                  throws Exception
This method is called when single entities are to be found. The persistence manager must find out whether the wanted instance is available in the persistence store, if so it returns the primary key of the object.

Specified by:
findEntity in interface EntityPersistenceStore
Parameters:
finderMethod - the find method in the home interface that was called
args - any finder parameters
instance - the instance to use for the finder call
Returns:
a primary key representing the found entity
Throws:
Exception - thrown if some heuristic problem occurs

findEntities

public Collection findEntities(Method finderMethod,
                               Object[] args,
                               EntityEnterpriseContext instance,
                               GenericEntityObjectFactory factory)
                        throws Exception
This method is called when collections of entities are to be found. The persistence manager must find out whether the wanted instances are available in the persistence store, and if so it must return a collection of primaryKeys.

Specified by:
findEntities in interface EntityPersistenceStore
Parameters:
finderMethod - the find method in the home interface that was called
args - any finder parameters
instance - the instance to use for the finder call
Returns:
an primary key collection representing the found entities
Throws:
Exception - thrown if some heuristic problem occurs

activateEntity

public void activateEntity(EntityEnterpriseContext instance)
Non-operation.

Specified by:
activateEntity in interface EntityPersistenceStore
Parameters:
instance - the instance to use for the activation

loadEntity

public void loadEntity(EntityEnterpriseContext ctx)
This method is called whenever an entity shall be load from the underlying storage. The persistence manager must load the state from the underlying storage and then call ejbLoad on the supplied instance.

Specified by:
loadEntity in interface EntityPersistenceStore
Parameters:
ctx - the instance to synchronize

isStoreRequired

public boolean isStoreRequired(EntityEnterpriseContext ctx)
                        throws Exception
This method is used to determine if an entity should be stored.

Specified by:
isStoreRequired in interface EntityPersistenceStore
Parameters:
ctx - the instance to check
Returns:
true, if the entity has been modified
Throws:
Exception - thrown if some system exception occurs

isModified

public boolean isModified(EntityEnterpriseContext ctx)
                   throws Exception
Description copied from interface: EntityPersistenceStore
This method is used to determined whether the instance was modified. NOTE, even if the method returns true the isStoreRequired for this same instance might return false, e.g. a CMR field that doesn't have a foreign key was modified.

Specified by:
isModified in interface EntityPersistenceStore
Parameters:
ctx -
Returns:
Throws:
Exception

storeEntity

public void storeEntity(EntityEnterpriseContext ctx)
This method is called whenever an entity shall be stored to the underlying storage. The persistence manager must call ejbStore on the supplied instance and then store the state to the underlying storage.

Specified by:
storeEntity in interface EntityPersistenceStore
Parameters:
ctx - the instance to synchronize

passivateEntity

public void passivateEntity(EntityEnterpriseContext instance)
Non-operation.

Specified by:
passivateEntity in interface EntityPersistenceStore
Parameters:
instance - the instance to passivate

removeEntity

public void removeEntity(EntityEnterpriseContext ctx)
                  throws javax.ejb.RemoveException
This method is called when an entity shall be removed from the underlying storage. The persistence manager must call ejbRemove on the instance and then remove its state from the underlying storage.

Specified by:
removeEntity in interface EntityPersistenceStore
Parameters:
ctx - the instance to remove
Throws:
javax.ejb.RemoveException - thrown if the instance could not be removed

storeEntity

protected void storeEntity(Object id,
                           Object obj)


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