org.objectweb.speedo.runtime
Class SpeedoPersistenceManager

org.objectweb.speedo.runtime.SpeedoPersistenceManager
All Implemented Interfaces:
ProxyManager

public class SpeedoPersistenceManager
implements ProxyManager

Author:
S.Chassande-Barrioz

Field Summary
static java.lang.String CACHE_BINDING
           
static java.lang.String COMPONENT_IDENTITY_BINDING
           
static java.lang.String CONTAINER_NAMING_MANGER_BINDING
           
static java.lang.String JORM_FACTORY_BINDING
           
static java.lang.String LOGGER_FACTORY_BINDING
           
static java.lang.String LOGGER_NAME
           
static java.lang.String MAPPER_BINDING
           
static java.lang.String PERSISTENCE_MANAGER_FACTORY_BINDING
           
static java.lang.String PM_POOL_BINDING
           
static java.lang.String PROXY_MANAGER_SWITCH_BINDING
           
static java.lang.String QUERIES_POOL_BINDING
           
static java.lang.String QUERY_MANAGER_BINDING
           
static java.lang.String REPLACEMENT_BINDING
           
static java.lang.String TRANSACTION_BINDING
           
static java.lang.String TRANSACTIONAL_PERSISTENCE_MANAGER_BINDING
           
static java.lang.String USER_NAMING_MANGER_BINDING
           
 
Constructor Summary
SpeedoPersistenceManager()
           
 
Method Summary
 void addFcBinding(java.lang.String s, java.lang.Object o)
           
 void close()
          This method closes the PersistenceManager.
 org.objectweb.jorm.naming.api.PName createFieldOfProxy(SpeedoProxy sp, SpeedoProxy father, java.lang.String name)
          Sets the reference between two JDO instances
 org.objectweb.perseus.pool.api.PoolResource createResource(java.lang.Object hints)
           
 javax.jdo.Transaction currentTransaction()
          Return the Transaction instance associated with a PersistenceManager.
 void deletePersistent(java.lang.Object o)
          Delete the persistent instance from the data store.
 void deletePersistentAll(java.util.Collection pcs)
          Delete a Set of instances from the data store.
 void deletePersistentAll(java.lang.Object[] pcs)
          Delete an array of instances from the data store.
 void destroy()
          destroy is called when this resource is removed from a Pool.
 void evict(java.lang.Object o)
          Mark an instance as no longer needed in the cache.
 void evictAll()
          Mark all persistent-nontransactional instances as no longer needed in the cache.
 void evictAll(java.util.Collection pcs)
          Mark a Set of instances as no longer needed in the cache.
 void evictAll(java.lang.Object[] pcs)
          Mark an array of instances as no longer needed in the cache.
 java.lang.Object getConnectionSpec()
           
 javax.jdo.Extent getExtent(java.lang.Class persistenceCapableClass, boolean subclasses)
          Not implemented.
 java.lang.Object getFcBindings(java.lang.String s)
           
 boolean getIgnoreCache()
          Get the ignoreCache setting for queries.
 boolean getMultithreaded()
          Get the current Multithreaded flag for this PersistenceManager.
 java.lang.Object getObjectById(java.lang.Object oid, boolean validate)
          This method locates a persistent instance in the cache of instances managed by this PersistenceManager.
 java.lang.Object getObjectId(java.lang.Object pc)
          The ObjectId returned by this method represents the JDO identity of the instance.
 java.lang.Class getObjectIdClass(java.lang.Class cls)
           
 javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()
           
 java.lang.Object getTransactionalObjectId(java.lang.Object o)
          Not implemented.
 org.objectweb.perseus.persistence.api.TransactionalPersistenceManager getTransactionalPersistenceManager()
          Removes the proxy infrastructure of a JDO instance
 java.lang.Object getUserObject()
          The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.
 boolean isClosed()
          A PersistenceManager instance can be used until it is closed.
 void makeNontransactional(java.lang.Object o)
           
 void makeNontransactionalAll(java.util.Collection pcs)
           
 void makeNontransactionalAll(java.lang.Object[] pcs)
           
 void makePersistent(java.lang.Object o)
          Make the transient instance persistent in this PersistenceManager.
 void makePersistentAll(java.util.Collection pcs)
          Make a Set of instances persistent.
 void makePersistentAll(java.lang.Object[] pcs)
          Make an array of instances persistent.
 void makeTransactional(java.lang.Object o)
          Make an instance subject to transactional boundaries.
 void makeTransactionalAll(java.util.Collection pcs)
          Make a Set of instances subject to transactional boundaries.
 void makeTransactionalAll(java.lang.Object[] pcs)
          Make an array of instances subject to transactional boundaries.
 void makeTransient(java.lang.Object o)
          Make an instance transient, removing it from management by this PersistenceManager.
 void makeTransientAll(java.util.Collection pcs)
          Make a Set of instances transient, removing them from management by this PersistenceManager.
 void makeTransientAll(java.lang.Object[] pcs)
          Make an array of instances transient, removing them from management by this PersistenceManager.
 boolean matchResource(org.objectweb.perseus.pool.api.PoolResource pr, java.lang.Object hints)
           
 java.lang.Object newObjectIdInstance(java.lang.Class aClass, java.lang.String s)
           
 javax.jdo.Query newQuery()
          Create a new Query with no elements.
 javax.jdo.Query newQuery(java.lang.Class cls)
          Create a new Query specifying the Class of the candidate instances.
 javax.jdo.Query newQuery(java.lang.Class cls, java.util.Collection cln)
          Create a new Query with the Class of the candidate instances and candidate Set.
 javax.jdo.Query newQuery(java.lang.Class cls, java.util.Collection cln, java.lang.String filter)
          Create a new Query with the Class of the candidate instances, candidate Set, and filter.
 javax.jdo.Query newQuery(java.lang.Class cls, java.lang.String filter)
          Create a new Query with the Class of the candidate instances and filter.
 javax.jdo.Query newQuery(javax.jdo.Extent extent)
           
 javax.jdo.Query newQuery(javax.jdo.Extent extent, java.lang.String s)
           
 javax.jdo.Query newQuery(java.lang.Object compiled)
          Create a new Query using elements from another Query.
 javax.jdo.Query newQuery(java.lang.String language, java.lang.Object query)
          Create a new Query using the specified language.
 void open(java.lang.Object connectionspec)
          Opens the persistent manager.
 void refresh(java.lang.Object o)
          Refresh the state of the instance from the data store.
 void refreshAll()
          Refresh the state of all applicable instances from the data store.
 void refreshAll(java.util.Collection pcs)
          Refresh the state of a Set of instances from the data store.
 void refreshAll(java.lang.Object[] pcs)
          Refresh the state of an array of instances from the data store.
 void removeFcBinding(java.lang.String s, java.lang.Object serverItf)
           
 void retrieve(java.lang.Object o)
           
 void retrieveAll(java.util.Collection pcs)
           
 void retrieveAll(java.lang.Object[] pcs)
           
 void setIgnoreCache(boolean flag)
          Set the ignoreCache parameter for queries.
 void setMultithreaded(boolean flag)
          Set the Multithreaded flag for this PersistenceManager.
 void setUserObject(java.lang.Object o)
           
 

Field Detail

PERSISTENCE_MANAGER_FACTORY_BINDING

public static final java.lang.String PERSISTENCE_MANAGER_FACTORY_BINDING

TRANSACTIONAL_PERSISTENCE_MANAGER_BINDING

public static final java.lang.String TRANSACTIONAL_PERSISTENCE_MANAGER_BINDING

QUERY_MANAGER_BINDING

public static final java.lang.String QUERY_MANAGER_BINDING

CACHE_BINDING

public static final java.lang.String CACHE_BINDING

REPLACEMENT_BINDING

public static final java.lang.String REPLACEMENT_BINDING

CONTAINER_NAMING_MANGER_BINDING

public static final java.lang.String CONTAINER_NAMING_MANGER_BINDING

USER_NAMING_MANGER_BINDING

public static final java.lang.String USER_NAMING_MANGER_BINDING

TRANSACTION_BINDING

public static final java.lang.String TRANSACTION_BINDING

PROXY_MANAGER_SWITCH_BINDING

public static final java.lang.String PROXY_MANAGER_SWITCH_BINDING

MAPPER_BINDING

public static final java.lang.String MAPPER_BINDING

QUERIES_POOL_BINDING

public static final java.lang.String QUERIES_POOL_BINDING

PM_POOL_BINDING

public static final java.lang.String PM_POOL_BINDING

JORM_FACTORY_BINDING

public static final java.lang.String JORM_FACTORY_BINDING

COMPONENT_IDENTITY_BINDING

public static final java.lang.String COMPONENT_IDENTITY_BINDING

LOGGER_FACTORY_BINDING

public static final java.lang.String LOGGER_FACTORY_BINDING

LOGGER_NAME

public static final java.lang.String LOGGER_NAME
Constructor Detail

SpeedoPersistenceManager

public SpeedoPersistenceManager()
Method Detail

getFcBindings

public java.lang.Object getFcBindings(java.lang.String s)

addFcBinding

public void addFcBinding(java.lang.String s,
                         java.lang.Object o)

removeFcBinding

public void removeFcBinding(java.lang.String s,
                            java.lang.Object serverItf)

destroy

public void destroy()
             throws java.lang.Exception
destroy is called when this resource is removed from a Pool.

createResource

public org.objectweb.perseus.pool.api.PoolResource createResource(java.lang.Object hints)
                                                           throws java.lang.Exception

matchResource

public boolean matchResource(org.objectweb.perseus.pool.api.PoolResource pr,
                             java.lang.Object hints)

getObjectIdClass

public java.lang.Class getObjectIdClass(java.lang.Class cls)

isClosed

public boolean isClosed()
A PersistenceManager instance can be used until it is closed.
Returns:
true if this PersistenceManager has been closed
See Also:
close()

close

public void close()
This method closes the PersistenceManager.
Throws:
javax.jdo.JDOUserException - if the transaction associated to the persistence manager is active.
javax.jdo.JDOFatalDataStoreException - if there is a problem while releasing the persistence manager.

currentTransaction

public javax.jdo.Transaction currentTransaction()
Return the Transaction instance associated with a PersistenceManager.
Returns:
the Transaction associated with this PersistenceManager.

evict

public void evict(java.lang.Object o)
Mark an instance as no longer needed in the cache.
Parameters:
o - the instance to evict from the cache.

evictAll

public void evictAll(java.lang.Object[] pcs)
Mark an array of instances as no longer needed in the cache.
Parameters:
pcs - the array of instances to evict from the cache.
Throws:
JDOUserException - if some instances cannot be removed.
See Also:
evict(Object pc)

evictAll

public void evictAll(java.util.Collection pcs)
Mark a Set of instances as no longer needed in the cache.
Parameters:
pcs - the Set of instance to evict from the cache.
See Also:
evict(Object pc)

evictAll

public void evictAll()
Mark all persistent-nontransactional instances as no longer needed in the cache. It transitions all persistent-nontransactional instances to hollow. Transactional instances are subject to eviction based on the RetainValues setting.
See Also:
evict(Object pc)

refresh

public void refresh(java.lang.Object o)
Refresh the state of the instance from the data store.

In an optimistic transaction, the state of instances in the cache might not match the state in the data store. This method is used to reload the state of the instance from the data store so that a subsequent commit is more likely to succeed.

Outside a transaction, this method will refresh nontransactional state.

Parameters:
o - the instance to refresh.

refreshAll

public void refreshAll(java.lang.Object[] pcs)
Refresh the state of an array of instances from the data store.
Parameters:
pcs - the array of instances to refresh. object.
See Also:
refresh(Object pc)

refreshAll

public void refreshAll(java.util.Collection pcs)
Refresh the state of a Set of instances from the data store.
Parameters:
pcs - the Set of instances to refresh.
See Also:
refresh(Object pc)

refreshAll

public void refreshAll()
Refresh the state of all applicable instances from the data store.

If called with an active transaction, all transactional instances will be refreshed. If called outside an active transaction, all nontransactional instances will be refreshed.

See Also:
refresh(Object pc)

newQuery

public javax.jdo.Query newQuery()
Create a new Query with no elements.
Returns:
the new Query.

newQuery

public javax.jdo.Query newQuery(java.lang.Object compiled)
Create a new Query using elements from another Query. The other Query must have been created by the same JDO implementation. It might be active in a different PersistenceManager or might have been serialized and restored.

All of the settings of the other Query are copied to this Query, except for the candidate Set or Extent.

Parameters:
compiled - another Query from the same JDO implementation
Returns:
the new Query

newQuery

public javax.jdo.Query newQuery(java.lang.String language,
                                java.lang.Object query)
Create a new Query using the specified language.
Parameters:
language - the language of the query parameter
query - the query, which is of a form determined by the language
Returns:
the new Query

newQuery

public javax.jdo.Query newQuery(java.lang.Class cls)
Create a new Query specifying the Class of the candidate instances.
Parameters:
cls - the Class of the candidate instances
Returns:
the new Query

newQuery

public javax.jdo.Query newQuery(javax.jdo.Extent extent)

newQuery

public javax.jdo.Query newQuery(javax.jdo.Extent extent,
                                java.lang.String s)

newQuery

public javax.jdo.Query newQuery(java.lang.Class cls,
                                java.util.Collection cln)
Create a new Query with the Class of the candidate instances and candidate Set.
Parameters:
cls - the Class of results
cln - the Set of candidate instances
Returns:
the new Query

newQuery

public javax.jdo.Query newQuery(java.lang.Class cls,
                                java.lang.String filter)
Create a new Query with the Class of the candidate instances and filter.
Parameters:
cls - the Class of results
filter - the filter for candidate instances
Returns:
the new Query

newQuery

public javax.jdo.Query newQuery(java.lang.Class cls,
                                java.util.Collection cln,
                                java.lang.String filter)
Create a new Query with the Class of the candidate instances, candidate Set, and filter.
Parameters:
cls - the Class of candidate instances
cln - the Set of candidate instances
filter - the filter for candidate instances
Returns:
the new Query

getExtent

public javax.jdo.Extent getExtent(java.lang.Class persistenceCapableClass,
                                  boolean subclasses)
Not implemented. The PersistenceManager manages a collection of instances in the data store based on the class of the instances. This method returns a Extent of instances in the data store that might be iterated or given to a Query. The Extent itself might not reference any instances, but only hold the class name and an indicator whether subclasses are included in the Extent.
Parameters:
persistenceCapableClass - Class of instances
subclasses - whether to include instances of subclasses
Returns:
an Extent of the specified Class

getObjectById

public java.lang.Object getObjectById(java.lang.Object oid,
                                      boolean validate)
This method locates a persistent instance in the cache of instances managed by this PersistenceManager. The getObjectById method attempts to find an instance in the cache with the specified JDO identity. The oid parameter object might have been returned by an earlier call to getObjectId or getTransactionalObjectId, or might have been constructed by the application.
Parameters:
oid - an ObjectId
validate - if the existence of the instance is to be validated. The flag is ignored in this implementation.
Returns:
the PersistenceCapable instance with the specified ObjectId
See Also:
getObjectId(Object pc), getTransactionalObjectId(Object pc)

getObjectId

public java.lang.Object getObjectId(java.lang.Object pc)
The ObjectId returned by this method represents the JDO identity of the instance. The ObjectId is a copy (clone) of the internal state of the instance, and changing it does not affect the JDO identity of the instance.
Parameters:
pc - the PersistenceCapable instance
Returns:
the ObjectId of the instance
See Also:
getTransactionalObjectId(Object pc), getObjectById(Object oid, boolean validate)

getTransactionalObjectId

public java.lang.Object getTransactionalObjectId(java.lang.Object o)
Not implemented. The ObjectId returned by this method represents the JDO identity of the instance. The ObjectId is a copy (clone) of the internal state of the instance, and changing it does not affect the JDO identity of the instance.

If the object identity is being changed in the transaction, by the application modifying one or more of the application key fields, then this method returns the current identity in the transaction.

If there is no transaction in progress, or if none of the key fields is being modified, then this method will return the same value as getObjectId.

Parameters:
o - a PersistenceCapable instance
Returns:
the ObjectId of the instance
See Also:
getObjectId(Object pc), getObjectById(Object oid, boolean validate)

makePersistent

public void makePersistent(java.lang.Object o)
Make the transient instance persistent in this PersistenceManager. This method must be called in an active transaction. The PersistenceManager assigns an ObjectId to the instance and transitions it to persistent-new. The instance will be managed in the Extent associated with its Class. The instance will be put into the data store at commit. The closure of instances of PersistenceCapable classes reachable from persistent fields will be made persistent at commit. [This is known as persistence by reachability.]
Parameters:
o - a transient instance of a Class that implements PersistenceCapable

makePersistentAll

public void makePersistentAll(java.lang.Object[] pcs)
Make an array of instances persistent.
Parameters:
pcs - an array of transient instances
Throws:
JDOUserException - if an object cannot be made persistent.
See Also:
makePersistent(Object pc)

makePersistentAll

public void makePersistentAll(java.util.Collection pcs)
Make a Set of instances persistent.
Parameters:
pcs - a Set of transient instances
See Also:
makePersistent(Object pc)

deletePersistent

public void deletePersistent(java.lang.Object o)
Delete the persistent instance from the data store. This method must be called in an active transaction. The data store object will be removed at commit. Unlike makePersistent, which makes the closure of the instance persistent, the closure of the instance is not deleted from the data store. This method has no effect if the instance is already deleted in the current transaction.
Parameters:
o - a persistent instance
Throws:
JDOUserException - if the instance is transient or managed by another PersistenceManager.

deletePersistentAll

public void deletePersistentAll(java.lang.Object[] pcs)
Delete an array of instances from the data store.
Parameters:
pcs - a Set of persistent instances
See Also:
deletePersistent(Object pc)

deletePersistentAll

public void deletePersistentAll(java.util.Collection pcs)
Delete a Set of instances from the data store.
Parameters:
pcs - a Set of persistent instances
See Also:
deletePersistent(Object pc)

makeTransient

public void makeTransient(java.lang.Object o)
Make an instance transient, removing it from management by this PersistenceManager.

The instance loses its JDO identity and it is no longer associated with any PersistenceManager. The state of fields is preserved unchanged.

Parameters:
o - the instance to make transient.
Throws:
JDOUserException - if the instance is dirty.

makeTransientAll

public void makeTransientAll(java.lang.Object[] pcs)
Make an array of instances transient, removing them from management by this PersistenceManager.
Parameters:
pcs - the instances to make transient.
See Also:
makeTransient(Object pc)

makeTransientAll

public void makeTransientAll(java.util.Collection pcs)
Make a Set of instances transient, removing them from management by this PersistenceManager.

The instances lose their JDO identity and they are no longer associated with any PersistenceManager. The state of fields is preserved unchanged.

Parameters:
pcs - the instances to make transient.

makeTransactional

public void makeTransactional(java.lang.Object o)
Make an instance subject to transactional boundaries.
Parameters:
o - the instance to make transactional.
See Also:
javax.jdo.PersistenceManager#makeTransactional

makeTransactionalAll

public void makeTransactionalAll(java.lang.Object[] pcs)
Make an array of instances subject to transactional boundaries.
Parameters:
pcs - the array of instances to make transactional.
See Also:
makeTransactional(Object pc)

makeTransactionalAll

public void makeTransactionalAll(java.util.Collection pcs)
Make a Set of instances subject to transactional boundaries.
Parameters:
pcs - the Set of instances to make transactional.
See Also:
makeTransactional(Object pc)

makeNontransactional

public void makeNontransactional(java.lang.Object o)

makeNontransactionalAll

public void makeNontransactionalAll(java.lang.Object[] pcs)

makeNontransactionalAll

public void makeNontransactionalAll(java.util.Collection pcs)

setUserObject

public void setUserObject(java.lang.Object o)

getUserObject

public java.lang.Object getUserObject()
The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.
Returns:
the user object associated with this PersistenceManager
See Also:
setUserObject(java.lang.Object)

getPersistenceManagerFactory

public javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()

setMultithreaded

public void setMultithreaded(boolean flag)
Set the Multithreaded flag for this PersistenceManager. Applications that use multiple threads to invoke methods or access fields from instances managed by this PersistenceManager must set this flag to true. Instances managed by this PersistenceManager include persistent or transactional instances of PersistenceCapable classes, as well as helper instances such as Query, Transaction, or Extent.
Parameters:
flag - the Multithreaded setting.

getMultithreaded

public boolean getMultithreaded()
Get the current Multithreaded flag for this PersistenceManager. This option is ignored by the implementation.
Returns:
the Multithreaded setting.
See Also:
setMultithreaded(boolean)

setIgnoreCache

public void setIgnoreCache(boolean flag)
Set the ignoreCache parameter for queries.
Parameters:
flag - the ignoreCache setting.

getIgnoreCache

public boolean getIgnoreCache()
Get the ignoreCache setting for queries.
Returns:
the ignoreCache setting.
See Also:
setIgnoreCache(boolean)

newObjectIdInstance

public java.lang.Object newObjectIdInstance(java.lang.Class aClass,
                                            java.lang.String s)

retrieve

public void retrieve(java.lang.Object o)

retrieveAll

public void retrieveAll(java.util.Collection pcs)

retrieveAll

public void retrieveAll(java.lang.Object[] pcs)

getTransactionalPersistenceManager

public org.objectweb.perseus.persistence.api.TransactionalPersistenceManager getTransactionalPersistenceManager()
Description copied from interface: ProxyManager
Removes the proxy infrastructure of a JDO instance
Specified by:
getTransactionalPersistenceManager in interface ProxyManager
Following copied from interface: org.objectweb.speedo.api.ProxyManager
Parameters:
pc - the object requiring architecture deletion or its oid
retainValues - true if fields have to be restored into the JDO instance
Returns:
the modified non-persistant JDO instance

createFieldOfProxy

public org.objectweb.jorm.naming.api.PName createFieldOfProxy(SpeedoProxy sp,
                                                              SpeedoProxy father,
                                                              java.lang.String name)
                                                       throws java.lang.Exception
Sets the reference between two JDO instances
Specified by:
createFieldOfProxy in interface ProxyManager
Parameters:
sp - the reference object whose proxy infrastructure will be build
father - the owner
name - is the name of the field

open

public void open(java.lang.Object connectionspec)
Description copied from interface: ProxyManager
Opens the persistent manager.
Specified by:
open in interface ProxyManager
Following copied from interface: org.objectweb.speedo.api.ProxyManager
Parameters:
connectionSpec - is the information to access to the datastore (user, passwor, ...)

getConnectionSpec

public java.lang.Object getConnectionSpec()
Specified by:
getConnectionSpec in interface ProxyManager