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

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

public final class JDBCStoreManager
extends java.lang.Object
implements JDBCEntityPersistenceStore (src)

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

See Also:
EntityPersistenceStore (src)

Field Summary
 
Fields inherited from interface org.jboss.ejb.AllowedOperationsFlags (src)
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 (src)  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.
 java.lang.Object createBeanClassInstance()
          Returns a new instance of a class which implemnts the bean class.
 java.lang.Object createEntity(java.lang.reflect.Method createMethod, java.lang.Object[] args, EntityEnterpriseContext (src)  ctx)
          This method is called whenever an entity is to be created.
 void destroy()
          destroy the service, tear down
 java.util.Collection findEntities(java.lang.reflect.Method finderMethod, java.lang.Object[] args, EntityEnterpriseContext (src)  ctx, GenericEntityObjectFactory (src)  factory)
          This method is called when collections of entities are to be found.
 java.lang.Object findEntity(java.lang.reflect.Method finderMethod, java.lang.Object[] args, EntityEnterpriseContext (src)  ctx, GenericEntityObjectFactory (src)  factory)
          This method is called when single entities are to be found.
 java.lang.Object getApplicationData(java.lang.Object key)
           
 java.util.Map getApplicationDataMap()
           
 java.lang.Object getApplicationTxData(java.lang.Object key)
           
 Catalog (src) getCatalog()
           
 JDBCCommandFactory (src) getCommandFactory()
           
 EntityContainer (src) getContainer()
          Gets the container for this entity.
 JDBCAbstractEntityBridge (src) getEntityBridge()
           
 java.lang.Object getEntityTxData(java.lang.Object key)
           
 JDBCTypeFactory (src) getJDBCTypeFactory()
           
 JDBCEntityMetaData (src) getMetaData()
           
 JDBCQueryManager (src) getQueryManager()
           
 ReadAheadCache (src) getReadAheadCache()
           
 void initEntity(EntityEnterpriseContext (src)  ctx)
          Initializes the instance context.
 boolean isModified(EntityEnterpriseContext (src)  ctx)
          This method is used to determined whether the instance was modified.
 boolean isStoreRequired(EntityEnterpriseContext (src)  ctx)
          This method is used to determine if an entity should be stored.
 void loadEntity(EntityEnterpriseContext (src)  ctx)
          Loads entity.
 boolean loadEntity(EntityEnterpriseContext (src)  ctx, boolean failIfNotFound)
           
 void loadField(JDBCCMPFieldBridge (src)  field, EntityEnterpriseContext (src)  ctx)
           
 java.util.Collection loadRelation(JDBCCMRFieldBridge (src)  cmrField, java.lang.Object pk)
           
 void passivateEntity(EntityEnterpriseContext (src)  ctx)
          This method is called when an entity shall be passivate.
 java.lang.Object postCreateEntity(java.lang.reflect.Method createMethod, java.lang.Object[] args, EntityEnterpriseContext (src)  ctx)
          This method is called after the createEntity.
 void putApplicationData(java.lang.Object key, java.lang.Object value)
           
 void putApplicationTxData(java.lang.Object key, java.lang.Object value)
           
 void putEntityTxData(java.lang.Object key, java.lang.Object value)
           
 void removeEntity(EntityEnterpriseContext (src)  ctx)
          This method is called when an entity shall be removed from the underlying storage.
 void removeEntityTxData(java.lang.Object key)
           
 void scheduleCascadeDelete(java.util.List pks)
          Schedules instances for cascade-delete
 void setContainer(Container (src)  container)
          Sets the container for this entity.
 void start()
          Bring the store to a fully initialized state
 void stop()
          stop the service
 void storeEntity(EntityEnterpriseContext (src)  ctx)
          This method is called whenever an entity shall be stored to the underlying storage.
 boolean unscheduledCascadeDelete(java.lang.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 (src)  getContainer()
Gets the container for this entity.

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

setContainer

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

Specified by:
setContainer in interface ContainerPlugin (src)
Parameters:
container - the container for this entity
Throws:
java.lang.ClassCastException - if the container is not an instance of EntityContainer

getEntityBridge

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

getJDBCTypeFactory

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

getMetaData

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

getQueryManager

public JDBCQueryManager (src)  getQueryManager()

getCommandFactory

public JDBCCommandFactory (src)  getCommandFactory()

getReadAheadCache

public ReadAheadCache (src)  getReadAheadCache()

getApplicationDataMap

public java.util.Map getApplicationDataMap()

getApplicationData

public java.lang.Object getApplicationData(java.lang.Object key)
Specified by:
getApplicationData in interface JDBCEntityPersistenceStore (src)

putApplicationData

public void putApplicationData(java.lang.Object key,
                               java.lang.Object value)
Specified by:
putApplicationData in interface JDBCEntityPersistenceStore (src)

scheduleCascadeDelete

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


unscheduledCascadeDelete

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

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

getApplicationTxData

public java.lang.Object getApplicationTxData(java.lang.Object key)

putApplicationTxData

public void putApplicationTxData(java.lang.Object key,
                                 java.lang.Object value)

getEntityTxData

public java.lang.Object getEntityTxData(java.lang.Object key)

putEntityTxData

public void putEntityTxData(java.lang.Object key,
                            java.lang.Object value)

removeEntityTxData

public void removeEntityTxData(java.lang.Object key)

getCatalog

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

create

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

Specified by:
create in interface Service (src)
Throws:
java.lang.Exception

start

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

Specified by:
start in interface Service (src)
Throws:
java.lang.Exception

stop

public void stop()
Description copied from interface: Service (src)
stop the service

Specified by:
stop in interface Service (src)

destroy

public void destroy()
Description copied from interface: Service (src)
destroy the service, tear down

Specified by:
destroy in interface Service (src)

createBeanClassInstance

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

Specified by:
createBeanClassInstance in interface EntityPersistenceStore (src)
Returns:
the new instance
Throws:
java.lang.Exception

initEntity

public void initEntity(EntityEnterpriseContext (src)  ctx)
Description copied from interface: EntityPersistenceStore (src)
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 (src)
Parameters:
ctx -

createEntity

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

postCreateEntity

public java.lang.Object postCreateEntity(java.lang.reflect.Method createMethod,
                                         java.lang.Object[] args,
                                         EntityEnterpriseContext (src)  ctx)
Description copied from interface: EntityPersistenceStore (src)
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 (src)
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 java.lang.Object findEntity(java.lang.reflect.Method finderMethod,
                                   java.lang.Object[] args,
                                   EntityEnterpriseContext (src)  ctx,
                                   GenericEntityObjectFactory (src)  factory)
                            throws FinderException (src) 
Description copied from interface: EntityPersistenceStore (src)
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 (src)
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:
FinderException (src)

findEntities

public java.util.Collection findEntities(java.lang.reflect.Method finderMethod,
                                         java.lang.Object[] args,
                                         EntityEnterpriseContext (src)  ctx,
                                         GenericEntityObjectFactory (src)  factory)
                                  throws FinderException (src) 
Description copied from interface: EntityPersistenceStore (src)
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 (src)
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:
FinderException (src)

activateEntity

public void activateEntity(EntityEnterpriseContext (src)  ctx)
Description copied from interface: EntityPersistenceStore (src)
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 (src)
Parameters:
ctx - the instance to use for the activation

loadEntity

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

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

loadEntity

public boolean loadEntity(EntityEnterpriseContext (src)  ctx,
                          boolean failIfNotFound)

loadField

public void loadField(JDBCCMPFieldBridge (src)  field,
                      EntityEnterpriseContext (src)  ctx)

isStoreRequired

public boolean isStoreRequired(EntityEnterpriseContext (src)  ctx)
Description copied from interface: EntityPersistenceStore (src)
This method is used to determine if an entity should be stored.

Specified by:
isStoreRequired in interface EntityPersistenceStore (src)
Parameters:
ctx - the instance to check
Returns:
true, if the entity has been modified

isModified

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

storeEntity

public void storeEntity(EntityEnterpriseContext (src)  ctx)
Description copied from interface: EntityPersistenceStore (src)
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 (src)
Parameters:
ctx - the instance to synchronize

passivateEntity

public void passivateEntity(EntityEnterpriseContext (src)  ctx)
Description copied from interface: EntityPersistenceStore (src)
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 (src)
Parameters:
ctx - the instance to passivate

removeEntity

public void removeEntity(EntityEnterpriseContext (src)  ctx)
                  throws RemoveException (src) ,
                         java.rmi.RemoteException
Description copied from interface: EntityPersistenceStore (src)
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 (src)
Parameters:
ctx - the instance to remove
Throws:
java.rmi.RemoteException - thrown if some system exception occurs
RemoveException (src) - thrown if the instance could not be removed

loadRelation

public java.util.Collection loadRelation(JDBCCMRFieldBridge (src)  cmrField,
                                         java.lang.Object pk)