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

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


org.jboss.ejb.plugins.cmp.jdbc
Class JDBCStoreManager

java.lang.Object
  extended byorg.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager
All Implemented Interfaces:
AllowedOperationsFlags, ContainerPlugin, EntityPersistenceStore, JDBCEntityPersistenceStore, org.jboss.system.Service

public final class JDBCStoreManager
extends Object
implements JDBCEntityPersistenceStore

JDBCStoreManager manages storage of persistence data into a table. Other then loading the initial jbosscmp-jdbc.xml file this class does very little. The interesting tasks are performed by the command classes. Life-cycle: Tied to the life-cycle of the entity container. Multiplicity: One per cmp entity bean. This could be less if another implementaion of EntityPersistenceStore is created and thoes beans use the implementation

Version:
$Revision: 1.70 $
Author:
Dain Sundstrom, Alex Loubyansky
See Also:
EntityPersistenceStore

Field Summary
 
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
 
Constructor Summary
JDBCStoreManager()
           
 
Method Summary
 void activateEntity(EntityEnterpriseContext ctx)
          This method is called when an entity shall be activated.
 void create()
          Does almost nothing because other services such as JDBC data sources may not have been started.
 Object createBeanClassInstance()
          Returns a new instance of a class which implemnts the bean class.
 Object createEntity(Method createMethod, Object[] args, EntityEnterpriseContext ctx)
          This method is called whenever an entity is to be created.
 void destroy()
           
 Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory)
          This method is called when collections of entities are to be found.
 Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory)
          This method is called when single entities are to be found.
 Object getApplicationData(Object key)
           
 Map getApplicationDataMap()
           
 Object getApplicationTxData(Object key)
           
 Catalog getCatalog()
           
 JDBCCommandFactory getCommandFactory()
           
 EntityContainer getContainer()
          Gets the container for this entity.
 JDBCAbstractEntityBridge getEntityBridge()
           
 Object getEntityTxData(Object key)
           
 JDBCTypeFactory getJDBCTypeFactory()
           
 JDBCEntityMetaData getMetaData()
           
 JDBCQueryManager getQueryManager()
           
 ReadAheadCache getReadAheadCache()
           
 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)
          Loads entity.
 boolean loadEntity(EntityEnterpriseContext ctx, boolean failIfNotFound)
           
 void loadField(JDBCCMPFieldBridge field, EntityEnterpriseContext ctx)
           
 Collection loadRelation(JDBCCMRFieldBridge cmrField, Object pk)
           
 void passivateEntity(EntityEnterpriseContext ctx)
          This method is called when an entity shall be passivate.
 Object postCreateEntity(Method createMethod, Object[] args, EntityEnterpriseContext ctx)
          This method is called after the createEntity.
 void putApplicationData(Object key, Object value)
           
 void putApplicationTxData(Object key, Object value)
           
 void putEntityTxData(Object key, Object value)
           
 void removeEntity(EntityEnterpriseContext ctx)
          This method is called when an entity shall be removed from the underlying storage.
 void removeEntityTxData(Object key)
           
 void scheduleCascadeDelete(List pks)
          Schedules instances for cascade-delete
 void setContainer(Container container)
          Sets the container for this entity.
 void start()
          Bring the store to a fully initialized state
 void stop()
           
 void storeEntity(EntityEnterpriseContext ctx)
          This method is called whenever an entity shall be stored to the underlying storage.
 boolean unscheduledCascadeDelete(Object pk)
          Unschedules instance cascade delete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCStoreManager

public JDBCStoreManager()
Method Detail

getContainer

public EntityContainer getContainer()
Gets the container for this entity.

Specified by:
getContainer in interface JDBCEntityPersistenceStore
Returns:
the container for this entity; null if container has not been set

setContainer

public void setContainer(Container container)
Sets the container for this entity.

Specified by:
setContainer in interface ContainerPlugin
Parameters:
container - the container for this entity
Throws:
ClassCastException - if the container is not an instance of EntityContainer

getEntityBridge

public JDBCAbstractEntityBridge getEntityBridge()
Specified by:
getEntityBridge in interface JDBCEntityPersistenceStore

getJDBCTypeFactory

public JDBCTypeFactory getJDBCTypeFactory()
Specified by:
getJDBCTypeFactory in interface JDBCEntityPersistenceStore

getMetaData

public JDBCEntityMetaData getMetaData()
Specified by:
getMetaData in interface JDBCEntityPersistenceStore

getQueryManager

public JDBCQueryManager getQueryManager()

getCommandFactory

public JDBCCommandFactory getCommandFactory()

getReadAheadCache

public ReadAheadCache getReadAheadCache()

getApplicationDataMap

public Map getApplicationDataMap()

getApplicationData

public Object getApplicationData(Object key)
Specified by:
getApplicationData in interface JDBCEntityPersistenceStore

putApplicationData

public void putApplicationData(Object key,
                               Object value)
Specified by:
putApplicationData in interface JDBCEntityPersistenceStore

scheduleCascadeDelete

public void scheduleCascadeDelete(List pks)
Schedules instances for cascade-delete


unscheduledCascadeDelete

public boolean unscheduledCascadeDelete(Object pk)
Unschedules instance cascade delete.

Parameters:
pk - instance primary key.
Returns:
true if the instance was scheduled for cascade deleted.

getApplicationTxData

public Object getApplicationTxData(Object key)

putApplicationTxData

public void putApplicationTxData(Object key,
                                 Object value)

getEntityTxData

public Object getEntityTxData(Object key)

putEntityTxData

public void putEntityTxData(Object key,
                            Object value)

removeEntityTxData

public void removeEntityTxData(Object key)

getCatalog

public Catalog getCatalog()
Specified by:
getCatalog in interface JDBCEntityPersistenceStore

create

public void create()
            throws Exception
Does almost nothing because other services such as JDBC data sources may not have been started.

Specified by:
create in interface org.jboss.system.Service
Throws:
Exception

start

public void start()
           throws Exception
Bring the store to a fully initialized state

Specified by:
start in interface org.jboss.system.Service
Throws:
Exception

stop

public void stop()
Specified by:
stop in interface org.jboss.system.Service

destroy

public void destroy()
Specified by:
destroy in interface org.jboss.system.Service

createBeanClassInstance

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

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

initEntity

public void initEntity(EntityEnterpriseContext ctx)
Description copied from interface: EntityPersistenceStore
Initializes the instance context.

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

Specified by:
initEntity in interface EntityPersistenceStore
Parameters:
ctx -

createEntity

public Object createEntity(Method createMethod,
                           Object[] args,
                           EntityEnterpriseContext ctx)
                    throws javax.ejb.CreateException
Description copied from interface: EntityPersistenceStore
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:
createMethod - 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:
javax.ejb.CreateException

postCreateEntity

public Object postCreateEntity(Method createMethod,
                               Object[] args,
                               EntityEnterpriseContext ctx)
Description copied from interface: EntityPersistenceStore
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:
createMethod - 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

findEntity

public Object findEntity(Method finderMethod,
                         Object[] args,
                         EntityEnterpriseContext ctx,
                         GenericEntityObjectFactory factory)
                  throws javax.ejb.FinderException
Description copied from interface: EntityPersistenceStore
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
ctx - the instance to use for the finder call
Returns:
a primary key representing the found entity
Throws:
javax.ejb.FinderException

findEntities

public Collection findEntities(Method finderMethod,
                               Object[] args,
                               EntityEnterpriseContext ctx,
                               GenericEntityObjectFactory factory)
                        throws javax.ejb.FinderException
Description copied from interface: EntityPersistenceStore
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
ctx - the instance to use for the finder call
Returns:
an primary key collection representing the found entities
Throws:
javax.ejb.FinderException

activateEntity

public void activateEntity(EntityEnterpriseContext ctx)
Description copied from interface: EntityPersistenceStore
This method is called when an entity shall be activated.

With the PersistenceManager factorization most EJB calls should not exists However this calls permits us to introduce optimizations in the persistence store. Particularly the context has a "PersistenceContext" that a PersistenceStore can use (JAWS does for smart updates) and this is as good a callback as any other to set it up.

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

loadEntity

public void loadEntity(EntityEnterpriseContext ctx)
Loads entity. If entity not found NoSuchEntityException is thrown.

Specified by:
loadEntity in interface EntityPersistenceStore
Parameters:
ctx - - entity context.

loadEntity

public boolean loadEntity(EntityEnterpriseContext ctx,
                          boolean failIfNotFound)

loadField

public void loadField(JDBCCMPFieldBridge field,
                      EntityEnterpriseContext ctx)

isStoreRequired

public boolean isStoreRequired(EntityEnterpriseContext ctx)
Description copied from interface: EntityPersistenceStore
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

isModified

public boolean isModified(EntityEnterpriseContext ctx)
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:

storeEntity

public void storeEntity(EntityEnterpriseContext ctx)
Description copied from interface: EntityPersistenceStore
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 ctx)
Description copied from interface: EntityPersistenceStore
This method is called when an entity shall be passivate. The persistence manager must call the ejbPassivate method on the instance.

See the activate discussion for the reason for exposing EJB callback calls to the store.

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

removeEntity

public void removeEntity(EntityEnterpriseContext ctx)
                  throws javax.ejb.RemoveException,
                         RemoteException
Description copied from interface: EntityPersistenceStore
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
RemoteException - thrown if some system exception occurs

loadRelation

public Collection loadRelation(JDBCCMRFieldBridge cmrField,
                               Object pk)


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