org.objectweb.speedo.pm.lib
Class SpeedoProxyManager

java.lang.Object
  extended byorg.objectweb.speedo.pm.lib.SpeedoProxyManager
All Implemented Interfaces:
ProxyManager

public class SpeedoProxyManager
extends java.lang.Object
implements ProxyManager

Author:
S.Chassande-Barrioz

Field Summary
static java.lang.String COMPONENT_BINDING
           
static java.lang.String JORM_FACTORY_BINDING
           
static java.lang.String LOGGER_NAME
           
static java.lang.String PNAME_CODER_BINDING
           
static java.lang.String PROXY_MANAGER_FACTORY_BINDING
           
static java.lang.String QUERY_MANAGER_BINDING
           
static java.lang.String TRANSACTION_BINDING
           
static java.lang.String TRANSACTIONAL_PERSISTENCE_MANAGER_BINDING
           
 
Constructor Summary
SpeedoProxyManager()
           
 
Method Summary
 void addUse()
          Signal to the persistence maneger that it is used
 void afterCompletion(int i)
           
 void beforeCompletion()
           
 void bindFc(java.lang.String s, java.lang.Object o)
           
 void close()
          This method closes the PersistenceManager.
 Query createQuery(java.lang.Object o)
           
 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 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()
           
 Extent getExtent(java.lang.Class persistenceCapableClass, boolean subclasses)
          Not implemented.
 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)
          Fetches the Null PName associated to the PBinder of the persistent class
 PersistenceManagerFactory getPersistenceManagerFactory()
           
 Semaphore getSemaphore()
           
 java.lang.Object getTransactionalObjectId(java.lang.Object o)
          Not implemented.
 TransactionalPersistenceManager getTransactionalPersistenceManager()
           
 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.
 java.lang.String[] listFc()
           
 java.lang.Object lookupFc(java.lang.String s)
           
 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.
 java.lang.Object newObjectIdInstance(java.lang.Class aClass, java.lang.String s)
           
 Query newQuery()
          Create a new Query with no elements.
 Query newQuery(java.lang.Class cls)
          Create a new Query specifying the Class of the candidate instances.
 Query newQuery(java.lang.Class cls, java.util.Collection cln)
          Create a new Query with the Class of the candidate instances and candidate Set.
 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.
 Query newQuery(Extent extent, java.lang.String filter)
           
 Query newQuery(java.lang.Object compiled)
          Create a new Query using elements from another Query.
 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 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)
           
 void speedoDeletePersistent(java.lang.Object o)
          Delete persistent a SpeedoProxy.
 java.lang.Object speedoGetObjectById(java.lang.Object oid, boolean validate)
           
 void speedoMakePersistent(SpeedoProxy sp)
          Make persistent a SpeedoProxy.
 void unbindFc(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXY_MANAGER_FACTORY_BINDING

public static final java.lang.String PROXY_MANAGER_FACTORY_BINDING
See Also:
Constant Field Values

TRANSACTIONAL_PERSISTENCE_MANAGER_BINDING

public static final java.lang.String TRANSACTIONAL_PERSISTENCE_MANAGER_BINDING
See Also:
Constant Field Values

QUERY_MANAGER_BINDING

public static final java.lang.String QUERY_MANAGER_BINDING
See Also:
Constant Field Values

TRANSACTION_BINDING

public static final java.lang.String TRANSACTION_BINDING
See Also:
Constant Field Values

JORM_FACTORY_BINDING

public static final java.lang.String JORM_FACTORY_BINDING
See Also:
Constant Field Values

PNAME_CODER_BINDING

public static final java.lang.String PNAME_CODER_BINDING
See Also:
Constant Field Values

COMPONENT_BINDING

public static final java.lang.String COMPONENT_BINDING
See Also:
Constant Field Values

LOGGER_NAME

public static final java.lang.String LOGGER_NAME
See Also:
Constant Field Values
Constructor Detail

SpeedoProxyManager

public SpeedoProxyManager()
Method Detail

createQuery

public Query createQuery(java.lang.Object o)

listFc

public java.lang.String[] listFc()

lookupFc

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

bindFc

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

unbindFc

public void unbindFc(java.lang.String s)

getObjectIdClass

public java.lang.Class getObjectIdClass(java.lang.Class cls)
Fetches the Null PName associated to the PBinder of the persistent class


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:
javax.jdo.JDOUserException - if some instances cannot be removed.
See Also:
evict(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.Object pc)

newQuery

public Query newQuery()
Create a new Query with no elements.

Returns:
the new Query.

newQuery

public 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 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 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 Query newQuery(Extent extent,
                      java.lang.String filter)

newQuery

public 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 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 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(java.lang.Object pc), getTransactionalObjectId(java.lang.Object pc)

speedoGetObjectById

public java.lang.Object speedoGetObjectById(java.lang.Object oid,
                                            boolean validate)
Specified by:
speedoGetObjectById in interface ProxyManager

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(java.lang.Object pc), getObjectById(java.lang.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(java.lang.Object pc), getObjectById(java.lang.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

speedoMakePersistent

public void speedoMakePersistent(SpeedoProxy sp)
Description copied from interface: ProxyManager
Make persistent a SpeedoProxy. This method does the same thing than the PersistenceManager.makePersistent(Object) method except the call to the bind to the ProxyManager to the current thread.

Specified by:
speedoMakePersistent in interface ProxyManager
Parameters:
sp - is the instance to make persistent.

makePersistentAll

public void makePersistentAll(java.lang.Object[] pcs)
Make an array of instances persistent.

Parameters:
pcs - an array of transient instances
Throws:
javax.jdo.JDOUserException - if an object cannot be made persistent.
See Also:
makePersistent(java.lang.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(java.lang.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:
javax.jdo.JDOUserException - if the instance is transient or managed by another PersistenceManager.

speedoDeletePersistent

public void speedoDeletePersistent(java.lang.Object o)
Description copied from interface: ProxyManager
Delete persistent a SpeedoProxy. This method does the same thing than the PersistenceManager.deletePersistent(Object) method except the call to the bind to the ProxyManager to the current thread.

Specified by:
speedoDeletePersistent in interface ProxyManager
Parameters:
o - is the instance to make persistent.

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(java.lang.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(java.lang.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:
javax.jdo.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(java.lang.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:
PersistenceManager

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(java.lang.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(java.lang.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 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 TransactionalPersistenceManager getTransactionalPersistenceManager()
Specified by:
getTransactionalPersistenceManager in interface ProxyManager

open

public void open(java.lang.Object connectionspec)
Description copied from interface: ProxyManager
Opens the persistent manager.

Specified by:
open in interface 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

addUse

public void addUse()
Description copied from interface: ProxyManager
Signal to the persistence maneger that it is used

Specified by:
addUse in interface ProxyManager

beforeCompletion

public void beforeCompletion()

afterCompletion

public void afterCompletion(int i)

getSemaphore

public Semaphore getSemaphore()
Specified by:
getSemaphore in interface ProxyManager