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

JAWSPersistenceManager (JBoss Server API) - JBoss 3.2.7 server API Documentation 英文版文档


org.jboss.ejb.plugins.jaws
Class JAWSPersistenceManager

java.lang.Object
  extended byorg.jboss.ejb.plugins.jaws.JAWSPersistenceManager
All Implemented Interfaces:
ContainerPlugin, EntityPersistenceStore, org.jboss.system.Service

public class JAWSPersistenceManager
extends Object
implements EntityPersistenceStore

Just Another Web Store - an O/R mapper

Version:
$Revision: 1.41.2.6 $

Revisions:

20010812 vincent.harcq@hubmethods.com:

  • Get Rid of debug flag, use log4j instead

20011201 Dain Sundstrom:

  • Added createBeanInstance and initEntity methods

20020525 Dain Sundstrom:

  • Replaced FinderResults with Collection
  • Removed unused loadEntities method
Author:
Dan Christopherson, Rickard 脰berg, Marc Fleury, Joe Shevland, Justin Forder
See Also:
EntityPersistenceStore

Nested Class Summary
static class JAWSPersistenceManager.PersistenceContext
           
 
Constructor Summary
JAWSPersistenceManager()
           
 
Method Summary
 void activateEntity(EntityEnterpriseContext ctx)
          This method is called when an entity shall be activated.
 void create()
           
 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.
 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.
 void initEntity(EntityEnterpriseContext ctx)
          Reset all attributes to default value The EJB 1.1 specification is not entirely clear about this, the EJB 2.0 spec is, see page 169.
 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 ctx)
          This method is called when an entity shall be passivate.
 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 c)
          This callback is set by the container so that the plugin may access it
 void start()
           
 void stop()
           
 void storeEntity(EntityEnterpriseContext ctx)
          This method is called whenever an entity shall be stored to the underlying storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAWSPersistenceManager

public JAWSPersistenceManager()
Method Detail

setContainer

public void setContainer(Container c)
Description copied from interface: ContainerPlugin
This callback is set by the container so that the plugin may access it

Specified by:
setContainer in interface ContainerPlugin
Parameters:
c - The container using this plugin. This may be null if the plugin is being disassociated from a container.

create

public void create()
            throws Exception
Specified by:
create in interface org.jboss.system.Service
Throws:
Exception

start

public void start()
           throws Exception
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
Description copied from interface: EntityPersistenceStore
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)
Reset all attributes to default value The EJB 1.1 specification is not entirely clear about this, the EJB 2.0 spec is, see page 169. Robustness is more important than raw speed for most server applications, and not resetting atrribute values result in *very* weird errors (old states re-appear in different instances and the developer thinks he's on drugs).

Specified by:
initEntity in interface EntityPersistenceStore
Parameters:
ctx -

createEntity

public Object createEntity(Method m,
                           Object[] args,
                           EntityEnterpriseContext ctx)
                    throws RemoteException,
                           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:
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:
RemoteException
javax.ejb.CreateException

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 ctx,
                         GenericEntityObjectFactory factory)
                  throws Exception
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:
Exception

findEntities

public Collection findEntities(Method finderMethod,
                               Object[] args,
                               EntityEnterpriseContext ctx,
                               GenericEntityObjectFactory factory)
                        throws Exception
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:
Exception

activateEntity

public void activateEntity(EntityEnterpriseContext ctx)
                    throws RemoteException
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
Throws:
RemoteException - thrown if some system exception occurs

loadEntity

public void loadEntity(EntityEnterpriseContext ctx)
                throws RemoteException
Description copied from interface: EntityPersistenceStore
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
Throws:
RemoteException - thrown if some system exception occurs

isStoreRequired

public boolean isStoreRequired(EntityEnterpriseContext ctx)
                        throws Exception
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
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)
                 throws RemoteException
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
Throws:
RemoteException - thrown if some system exception occurs

passivateEntity

public void passivateEntity(EntityEnterpriseContext ctx)
                     throws RemoteException
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
Throws:
RemoteException - thrown if some system exception occurs

removeEntity

public void removeEntity(EntityEnterpriseContext ctx)
                  throws RemoteException,
                         javax.ejb.RemoveException
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


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