org.apache.jdo.impl.pm
Class PersistenceManagerImpl

java.lang.Object
  extended by org.apache.jdo.impl.pm.PersistenceManagerImpl
All Implemented Interfaces:
javax.jdo.PersistenceManager, PersistenceManagerInternal
Direct Known Subclasses:
FOStorePM

public abstract class PersistenceManagerImpl
extends java.lang.Object
implements PersistenceManagerInternal

This is the StoreManager independent implemetation of the org.apache.jdo.pm.PersistenceManagerInternal interface. Delegates most of the method execution to the corresponding instance of the CacheManagerImpl.

Author:
Marina Vatkina

Field Summary
protected static I18NHelper msg
          I18N message handler
 
Constructor Summary
PersistenceManagerImpl(PersistenceManagerFactoryInternal pmf, java.lang.String username, java.lang.String password)
          Constructs new instance of PersistenceManagerImpl for this PersistenceManagerFactoryInternal and particular combination of username and password.
 
Method Summary
protected  void afterCompletion(int status)
          Called by Transaction commit() or rollback() cleans up transactional cache
 void assertIsOpen()
          assert this PM instance is open
 void assertReadAllowed()
          Assert the NontransactionalRead flag is true or a transaction is active.
 void close()
          Close this persistence manager
 javax.jdo.Transaction currentTransaction()
          Returns transaction associated with this persistence manager
 void deletePersistent(java.lang.Object pc)
          Delete the persistent instance from the data store.
 void deletePersistentAll(java.util.Collection pcs)
          Delete a Collection of instances from the data store.
 void deletePersistentAll(java.lang.Object[] pcs)
          Delete an array of instances from the data store.
 void deregister(java.lang.Object oid)
          Removes the object from the cache.
protected  void deregisterJTA()
          Disassociate this PersistenceManager with the current JTA transaction.
 void deregisterTransient(StateManagerInternal sm)
          Removes transient object from the transient cache.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 void evict(java.lang.Object pc)
          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 Collection 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.
 StateManagerInternal findStateManager(javax.jdo.spi.PersistenceCapable pc)
          A helper method to find the StateManager associated with this PC instance
 void flush()
          Called by Query or Extent to flush updates to the database in a datastore transaction.
protected  void flushInstances()
          Called by Transaction commit() Loops through transactional cache and calls PersistentStore.updatePersistent() on each instance
protected  void forceClose()
          Close this persistence manager even if there are open wrappers or an uncomplete transaction.
 java.lang.ClassLoader getContextClassLoaderPrivileged()
          Calls getContextClassLoader for the current Thread in a doPrivileged block.
 javax.jdo.PersistenceManager getCurrentWrapper()
          Returns current wrapper
 javax.jdo.Extent getExtent(java.lang.Class persistenceCapableClass, boolean subclasses)
          The PersistenceManager may manage a collection of instances in the data store based on the class of the instances.
 boolean getIgnoreCache()
          Get the value of the ignoreCache flag.
 java.util.Collection getInsertedInstances()
          Returns a Collection of instances that has been made persistent or become persistent through persistence-by-reachability algorithm in this transaction.
 java.lang.Object getInternalObjectId(java.lang.Object pc)
          Gets the internal object id for this instance.
 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)
          Return the Class that implements the JDO Identity for the specified PersistenceCapable Class.
 javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()
          This method returns the PersistenceManagerFactory used to create this PersistenceManager.
 java.util.Properties getProperties()
          The JDO vendor might store certain non-operational properties and make those properties available to applications (for troubleshooting).
 StateManagerInternal getStateManager(java.lang.Object oid, java.lang.Class pcClass)
          Provides a StateManagerInternal for the given Object Id.
 StoreManager getStoreManager()
          Provides a StoreManager that is ready to accept operations on it.
 java.lang.Object getTransactionalObjectId(java.lang.Object pc)
           
 java.lang.Object getUserObject()
          The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.
 int hashCode()
          Returns a hash code value for this PersistenceManager.
 void hereIsStateManager(StateManagerInternal sm, javax.jdo.spi.PersistenceCapable pc)
          A helper method called from the StateManager inside getPersistenceManager() to identify StateManager associated with this PC instance
 boolean insideCommit()
          Returns true if the call initiated as a result of the commit process, versus flush for query in a datastore transaction.
 boolean isClosed()
          Return whether this PersistenceManager is closed.
 boolean isSupportedSCOType(java.lang.Class type)
          Called by StateManager to verify field type.
 java.lang.Class loadClass(java.lang.String name, java.lang.ClassLoader given)
          Provides a Class of the given name.
 java.lang.Class loadPCClassForObjectIdClass(java.lang.Class objectIdClass)
          Provides the Class object of the persistence-capable class that defines the specified class as its ObjectId class.
 void makeNontransactional(java.lang.Object pc)
          Make an instance non-transactional after commit.
 void makeNontransactionalAll(java.util.Collection pcs)
          Make a Collection of instances non-transactional after commit.
 void makeNontransactionalAll(java.lang.Object[] pcs)
          Make an array of instances non-transactional after commit.
 void makePersistent(java.lang.Object pc)
          Make the transient instance persistent in this PersistenceManager.
 void makePersistentAll(java.util.Collection pcs)
          Make an collection of instances persistent.
 void makePersistentAll(java.lang.Object[] pcs)
          Make an array of instances persistent.
 void makeTransactional(java.lang.Object pc)
          Make an instance subject to transactional boundaries.
 void makeTransactionalAll(java.util.Collection pcs)
          Make a Collection 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 pc)
          Make an instance transient, removing it from management by this PersistenceManager.
 void makeTransientAll(java.util.Collection pcs)
          Make a Collection 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.
 void markAsFlushed(StateManagerInternal sm)
          Called by StateManagerInternal#markAsFlushed() to adjust transactional cache(s) if necessary after successful flush to the data store.
 java.util.Collection newCollectionInstanceInternal(java.lang.Class type, java.lang.Class elementType, boolean allowNulls, java.lang.Integer initialSize, java.lang.Float loadFactor, java.util.Collection initialContents, java.util.Comparator comparator)
          Called by internally by the runtime to create a new tracked instance.
 java.util.Map newMapInstanceInternal(java.lang.Class type, java.lang.Class keyType, java.lang.Class valueType, boolean allowNulls, java.lang.Integer initialSize, java.lang.Float loadFactor, java.util.Map initialContents, java.util.Comparator comparator)
          Called by internally by the runtime to create a new tracked instance.
 java.lang.Object newObjectIdInstance(java.lang.Class pcClass, java.lang.String str)
          This method returns an object id instance corresponding to the Class and String arguments.
abstract  javax.jdo.Query newQuery()
          Create a new Query with no elements.
abstract  javax.jdo.Query newQuery(java.lang.Class cls)
          Create a new Query specifying the Class of the results.
abstract  javax.jdo.Query newQuery(java.lang.Class cls, java.util.Collection cln)
          Create a new Query with the Class of the results and candidate Collection.
abstract  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 results, candidate Collection, and Filter.
abstract  javax.jdo.Query newQuery(java.lang.Class cls, java.lang.String filter)
          Create a new Query with the Class of the results and Filter.
abstract  javax.jdo.Query newQuery(javax.jdo.Extent cln)
          Create a new Query with the candidate Extent; the class is taken from the Extent.
abstract  javax.jdo.Query newQuery(javax.jdo.Extent cln, java.lang.String filter)
          Create a new Query with the candidate Extent and Filter.
abstract  javax.jdo.Query newQuery(java.lang.Object compiled)
          Create a new Query using elements from another Query.
abstract  javax.jdo.Query newQuery(java.lang.String language, java.lang.Object query)
          Create a new Query using the specified language.
 java.lang.Object newSCOInstanceInternal(java.lang.Class type)
          Called by internally by the runtime to create a new tracked instance.
protected  void notifyOptimistic(boolean optimistic)
          For Transaction to notify PersistenceManager that optimistic flag is changed
protected  void notifyStatusChange(boolean isActive)
          For Transaction to notify PersistenceManager that status is changed
protected  void popCurrentWrapper(PersistenceManagerWrapper prev)
          Replace current wrapper with the previous
protected  void pushCurrentWrapper(PersistenceManagerWrapper pmw)
          Remember the current wrapper
 void refresh(java.lang.Object pc)
          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 Collection 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 register(StateManagerInternal sm, java.lang.Object oid, boolean transactional, boolean throwDuplicateException)
          Adds persistent object to the cache.
 void registerTransient(StateManagerInternal sm)
          Adds transient object to the transient cache.
 void replaceObjectId(java.lang.Object oldId, java.lang.Object newId)
          Replaces the objectId key value in the cache.
 void retrieve(java.lang.Object pc)
          Retrieve field values of an instance from the store.
 void retrieveAll(java.util.Collection pcs)
          Retrieve field values of instances from the store.
 void retrieveAll(java.util.Collection pcs, boolean DFGOnly)
          Retrieve field values of instances from the store.
 void retrieveAll(java.lang.Object[] pcs)
          Retrieve field values of instances from the store.
 void retrieveAll(java.lang.Object[] pcs, boolean DFGOnly)
          Retrieve field values of instances from the store.
 void setIgnoreCache(boolean flag)
           
protected  void setJTATransaction(java.lang.Object t)
          with the current thread in the managed environment
 void setMultithreaded(boolean flag)
          Set the Multithreaded flag for this PersistenceManager.
 void setUserObject(java.lang.Object o)
          The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.
protected  boolean verify(java.lang.String username, java.lang.String password)
          Verify that cached instance of a PersistenceManager was initialy requested with the same values for username and password
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msg

protected static final I18NHelper msg
I18N message handler

Constructor Detail

PersistenceManagerImpl

public PersistenceManagerImpl(PersistenceManagerFactoryInternal pmf,
                              java.lang.String username,
                              java.lang.String password)
Constructs new instance of PersistenceManagerImpl for this PersistenceManagerFactoryInternal and particular combination of username and password.

Parameters:
pmf - calling PersistenceManagerFactory as PersistenceManagerFactoryInternal
username - user name used for accessing Connector or null if none is provided.
password - user password used for accessing Connector or null if none is provided.
Method Detail

setIgnoreCache

public void setIgnoreCache(boolean flag)
Specified by:
setIgnoreCache in interface javax.jdo.PersistenceManager
Parameters:
flag - the ignoreCache value
See Also:
PersistenceManager.setIgnoreCache(boolean flag)

getIgnoreCache

public boolean getIgnoreCache()
Get the value of the ignoreCache flag.

Specified by:
getIgnoreCache in interface javax.jdo.PersistenceManager
Returns:
the IgnoreCache flag
See Also:
PersistenceManager.getIgnoreCache()

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.

Specified by:
setMultithreaded in interface javax.jdo.PersistenceManager
Parameters:
flag - the Multithreaded setting.

getMultithreaded

public boolean getMultithreaded()
Get the current Multithreaded flag for this PersistenceManager.

Specified by:
getMultithreaded in interface javax.jdo.PersistenceManager
Returns:
the Multithreaded setting.
See Also:
setMultithreaded(boolean)

isClosed

public boolean isClosed()
Return whether this PersistenceManager is closed.

Specified by:
isClosed in interface javax.jdo.PersistenceManager
See Also:
PersistenceManager.isClosed()

close

public void close()
Close this persistence manager

Specified by:
close in interface javax.jdo.PersistenceManager
See Also:
PersistenceManager.close()

currentTransaction

public javax.jdo.Transaction currentTransaction()
Returns transaction associated with this persistence manager

Specified by:
currentTransaction in interface javax.jdo.PersistenceManager
Returns:
transaction current transaction

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.

If the validate flag is true: This method verifies that there is an instance in the data store with the same oid, constructs an instance, and returns it. If there is no transaction active, then a hollow instance or persistent non-transactional instance is returned. If there is a transaction active, then a persistent clean instance is returned.

If the validate flag is false: If there is not already an instance in the cache with the same oid, then an instance is constructed and returned. If the instance does not exist in the data store, then this method will not fail. However, a request to access fields of the instance will throw an exception.

Specified by:
getObjectById in interface javax.jdo.PersistenceManager
Parameters:
oid - an ObjectId
validate - if the existence of the instance is to be validated
Returns:
the PersistenceCapable instance with the specified ObjectId

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. Delegates actual execution to the internal method.

Specified by:
getObjectId in interface javax.jdo.PersistenceManager
Parameters:
pc - the PersistenceCapable instance
Returns:
the corresponding ObjectId of the instance. Returns null if pc is null, not persistence-capable, or not persistent.

loadClass

public java.lang.Class loadClass(java.lang.String name,
                                 java.lang.ClassLoader given)
                          throws java.lang.ClassNotFoundException
Description copied from interface: PersistenceManagerInternal
Provides a Class of the given name. This method will use one of as many as three ClassLoaders in attempting to load the named class. The ClassLoaders are: For each such non-null Class Loader, it is used as a parameter of Class.forName. If the result is not null, then the given Comparator's compare method is invoked with that Class and the given Object o. If that returns zero, that Class is returned. If either the Class.forName returns null or the comparator returns non-zero, the next non-null ClassLoader in the above list is tried in the same manner.

If after the above has been tried on all the ClassLoaders, an appropriate Class has not been found, throws JDOUserException.

Specified by:
loadClass in interface PersistenceManagerInternal
Parameters:
name - Fully qualified name of the Class to load.
given - ClassLoader which is the first to be tried in loading the named Class.
Throws:
java.lang.ClassNotFoundException - - if an appropriate Class can not be loaded.
See Also:
PersistenceManagerInternal.loadClass(java.lang.String, java.lang.ClassLoader)

loadPCClassForObjectIdClass

public java.lang.Class loadPCClassForObjectIdClass(java.lang.Class objectIdClass)
                                            throws java.lang.ClassNotFoundException
Description copied from interface: PersistenceManagerInternal
Provides the Class object of the persistence-capable class that defines the specified class as its ObjectId class. This method will use one of as many as three ClassLoaders in attempting to find the persistence-capable class. The ClassLoaders are the same as in PersistenceManagerInternal.loadClass(java.lang.String, java.lang.ClassLoader): The method returns the top most persistence-capable class in the case of an inheritance hierachy.

Specified by:
loadPCClassForObjectIdClass in interface PersistenceManagerInternal
Throws:
java.lang.ClassNotFoundException
See Also:
PersistenceManagerInternal.loadPCClassForObjectIdClass(java.lang.Class)

getInternalObjectId

public java.lang.Object getInternalObjectId(java.lang.Object pc)
Gets the internal object id for this instance. Returns null if it is not a PersistenceCapable instance.

Specified by:
getInternalObjectId in interface PersistenceManagerInternal
Parameters:
pc -
Returns:
the internal object id

getTransactionalObjectId

public java.lang.Object getTransactionalObjectId(java.lang.Object pc)
Specified by:
getTransactionalObjectId in interface javax.jdo.PersistenceManager
See Also:
PersistenceManager.getTransactionalObjectId(java.lang.Object)

newObjectIdInstance

public java.lang.Object newObjectIdInstance(java.lang.Class pcClass,
                                            java.lang.String str)
This method returns an object id instance corresponding to the Class and String arguments. The String argument might have been the result of executing toString on an object id instance.

Specified by:
newObjectIdInstance in interface javax.jdo.PersistenceManager
Parameters:
pcClass - the Class of the persistence-capable instance
str - the String form of the object id
Returns:
an instance of the object identity class

getObjectIdClass

public java.lang.Class getObjectIdClass(java.lang.Class cls)
Return the Class that implements the JDO Identity for the specified PersistenceCapable Class. The application can use the returned Class to construct a JDO Identity instance for application identity PersistenceCapable classes. This JDO Identity instance can then be used to get an instance of the PersistenceCapable class for use in the application.

In order for the application to construct an instance of the ObjectId class it needs to know the class being used by the JDO implementation.

Specified by:
getObjectIdClass in interface javax.jdo.PersistenceManager
Parameters:
cls - the PersistenceCapable Class
Returns:
the Class of the ObjectId of the parameter
See Also:
getObjectById(java.lang.Object, boolean)

newQuery

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

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Returns:
a new Query instance with no elements.

newQuery

public abstract 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.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
compiled - another Query from the same JDO implementation
Returns:
the new Query

newQuery

public abstract javax.jdo.Query newQuery(java.lang.String language,
                                         java.lang.Object query)
Create a new Query using the specified language.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
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 abstract javax.jdo.Query newQuery(java.lang.Class cls)
Create a new Query specifying the Class of the results.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cls - the Class of the results
Returns:
the new Query

newQuery

public abstract javax.jdo.Query newQuery(javax.jdo.Extent cln)
Create a new Query with the candidate Extent; the class is taken from the Extent.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cln - the Extent of candidate instances
Returns:
the new Query

newQuery

public abstract javax.jdo.Query newQuery(java.lang.Class cls,
                                         java.util.Collection cln)
Create a new Query with the Class of the results and candidate Collection.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cls - the Class of results
cln - the Collection of candidate instances
Returns:
the new Query

newQuery

public abstract javax.jdo.Query newQuery(java.lang.Class cls,
                                         java.lang.String filter)
Create a new Query with the Class of the results and Filter.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cls - the Class of results
filter - the Filter for candidate instances
Returns:
the new Query

newQuery

public abstract 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 results, candidate Collection, and Filter.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cls - the Class of results
cln - the Collection of candidate instances
filter - the Filter for candidate instances
Returns:
the new Query

newQuery

public abstract javax.jdo.Query newQuery(javax.jdo.Extent cln,
                                         java.lang.String filter)
Create a new Query with the candidate Extent and Filter. The class is taken from the Extent.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cln - the Extent 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)
The PersistenceManager may manage a collection of instances in the data store based on the class of the instances. This method returns an Extent of instances in the data store that might be iterated or given to a Query as the Extent of candidate instances.

Specified by:
getExtent in interface javax.jdo.PersistenceManager
Parameters:
persistenceCapableClass - Class of instances
subclasses - whether to include instances of subclasses
Returns:
an Extent of instances.
See Also:
StoreManager.getExtent(java.lang.Class, boolean, org.apache.jdo.pm.PersistenceManagerInternal), Query

makePersistent

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

Specified by:
makePersistent in interface javax.jdo.PersistenceManager
Parameters:
pc - a transient instance of a Class that implements PersistenceCapable

makePersistentAll

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

Specified by:
makePersistentAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - an array of transient instances
See Also:
makePersistent(Object pc)

makePersistentAll

public void makePersistentAll(java.util.Collection pcs)
Make an collection of instances persistent.

Specified by:
makePersistentAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - an collection of transient instances
See Also:
makePersistent(Object pc)

deletePersistent

public void deletePersistent(java.lang.Object pc)
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. This method throws an exception if the instance is transient or is managed by another PersistenceManager.

Specified by:
deletePersistent in interface javax.jdo.PersistenceManager
Parameters:
pc - a persistent instance

deletePersistentAll

public void deletePersistentAll(java.lang.Object[] pcs)
Delete an array of instances from the data store.

Specified by:
deletePersistentAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - a Collection of persistent instances
See Also:
deletePersistent(Object pc)

deletePersistentAll

public void deletePersistentAll(java.util.Collection pcs)
Delete a Collection of instances from the data store.

Specified by:
deletePersistentAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - a Collection of persistent instances
See Also:
deletePersistent(Object pc)

makeTransient

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

Specified by:
makeTransient in interface javax.jdo.PersistenceManager
Parameters:
pc - the instance to make transient.

makeTransientAll

public void makeTransientAll(java.lang.Object[] pcs)
Make an array 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.

Specified by:
makeTransientAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances to make transient.

makeTransientAll

public void makeTransientAll(java.util.Collection pcs)
Make a Collection 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.

Specified by:
makeTransientAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances to make transient.

makeTransactional

public void makeTransactional(java.lang.Object pc)
Make an instance subject to transactional boundaries.

Transient instances normally do not observe transaction boundaries. This method makes transient instances sensitive to transaction completion. If an instance is modified in a transaction, and the transaction rolls back, the state of the instance is restored to the state before the first change in the transaction.

For persistent instances read in optimistic transactions, this method allows the application to make the state of the instance part of the transactional state. At transaction commit, the state of the instance in cache is compared to the state of the instance in the data store. If they are not the same, then an exception is thrown.

Specified by:
makeTransactional in interface javax.jdo.PersistenceManager
Parameters:
pc - the instance to make transactional.

makeTransactionalAll

public void makeTransactionalAll(java.lang.Object[] pcs)
Make an array of instances subject to transactional boundaries.

Specified by:
makeTransactionalAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the array of instances to make transactional.
See Also:
makeTransactional(Object pc)

makeTransactionalAll

public void makeTransactionalAll(java.util.Collection pcs)
Make a Collection of instances subject to transactional boundaries.

Specified by:
makeTransactionalAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the Collection of instances to make transactional.
See Also:
makeTransactional(Object pc)

makeNontransactional

public void makeNontransactional(java.lang.Object pc)
Make an instance non-transactional after commit.

Normally, at transaction completion, instances are evicted from the cache. This method allows an application to identify an instance as not being evicted from the cache at transaction completion. Instead, the instance remains in the cache with nontransactional state.

Specified by:
makeNontransactional in interface javax.jdo.PersistenceManager
Parameters:
pc - the instance to make nontransactional.

makeNontransactionalAll

public void makeNontransactionalAll(java.lang.Object[] pcs)
Make an array of instances non-transactional after commit.

Specified by:
makeNontransactionalAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the array of instances to make nontransactional.
See Also:
makeNontransactional(Object pc)

makeNontransactionalAll

public void makeNontransactionalAll(java.util.Collection pcs)
Make a Collection of instances non-transactional after commit.

Specified by:
makeNontransactionalAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the Collection of instances to make nontransactional.
See Also:
makeNontransactional(Object pc)

evict

public void evict(java.lang.Object pc)
Mark an instance as no longer needed in the cache. Eviction is normally done automatically by the PersistenceManager at transaction completion. This method allows the application to explicitly provide a hint to the PersistenceManager that the instance is no longer needed in the cache.

Specified by:
evict in interface javax.jdo.PersistenceManager
Parameters:
pc - 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.

Specified by:
evictAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the array of instances to evict from the cache.
See Also:
evict(Object pc)

evictAll

public void evictAll(java.util.Collection pcs)
Mark a Collection of instances as no longer needed in the cache.

Specified by:
evictAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the Collection of instance to evict from the cache.

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.

Specified by:
evictAll in interface javax.jdo.PersistenceManager
See Also:
evict(Object pc)

refresh

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

Specified by:
refresh in interface javax.jdo.PersistenceManager
Parameters:
pc - the instance to refresh.

refreshAll

public void refreshAll(java.lang.Object[] pcs)
Refresh the state of an array of instances from the data store.

Specified by:
refreshAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the array of instances to refresh.
See Also:
refresh(Object pc)

refreshAll

public void refreshAll(java.util.Collection pcs)
Refresh the state of a Collection of instances from the data store.

Specified by:
refreshAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the Collection 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.

Specified by:
refreshAll in interface javax.jdo.PersistenceManager
See Also:
refresh(Object pc)

retrieve

public void retrieve(java.lang.Object pc)
Retrieve field values of an instance from the store. This tells the PersistenceManager that the application intends to use the instance, and its field values must be retrieved.

The PersistenceManager might use policy information about the class to retrieve associated instances.

Specified by:
retrieve in interface javax.jdo.PersistenceManager
Parameters:
pc - the instance

retrieveAll

public void retrieveAll(java.lang.Object[] pcs)
Retrieve field values of instances from the store. This tells the PersistenceManager that the application intends to use the instances, and all field values must be retrieved.

The PersistenceManager might use policy information about the class to retrieve associated instances.

Specified by:
retrieveAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances

retrieveAll

public void retrieveAll(java.lang.Object[] pcs,
                        boolean DFGOnly)
Retrieve field values of instances from the store. This tells the PersistenceManager that the application intends to use the instances, and their field values should be retrieved. The fields in the default fetch group must be retrieved, and the implementation might retrieve more fields than the default fetch group.

The PersistenceManager might use policy information about the class to retrieve associated instances.

Specified by:
retrieveAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances
DFGOnly - whether to retrieve only the default fetch group fields
Since:
1.0.1

retrieveAll

public void retrieveAll(java.util.Collection pcs)
Retrieve field values of instances from the store. This tells the PersistenceManager that the application intends to use the instances, and all field values must be retrieved.

The PersistenceManager might use policy information about the class to retrieve associated instances.

Specified by:
retrieveAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances

retrieveAll

public void retrieveAll(java.util.Collection pcs,
                        boolean DFGOnly)
Retrieve field values of instances from the store. This tells the PersistenceManager that the application intends to use the instances, and their field values should be retrieved. The fields in the default fetch group must be retrieved, and the implementation might retrieve more fields than the default fetch group.

The PersistenceManager might use policy information about the class to retrieve associated instances.

Specified by:
retrieveAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances
DFGOnly - whether to retrieve only the default fetch group fields
Since:
1.0.1

getPersistenceManagerFactory

public javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()
This method returns the PersistenceManagerFactory used to create this PersistenceManager. It returns null if this instance was created via a constructor.

Specified by:
getPersistenceManagerFactory in interface javax.jdo.PersistenceManager
Returns:
the PersistenceManagerFactory that created this PersistenceManager

setUserObject

public void setUserObject(java.lang.Object o)
The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.

Specified by:
setUserObject in interface javax.jdo.PersistenceManager
Parameters:
o - the user instance to be remembered by the PersistenceManager
See Also:
getUserObject()

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.

Specified by:
getUserObject in interface javax.jdo.PersistenceManager
Returns:
the user object associated with this PersistenceManager
See Also:
setUserObject(java.lang.Object)

getProperties

public java.util.Properties getProperties()
The JDO vendor might store certain non-operational properties and make those properties available to applications (for troubleshooting).

Standard properties include:

  • VendorName
  • VersionNumber
  • Returns:
    the Properties of this PersistenceManager

    assertIsOpen

    public void assertIsOpen()
    assert this PM instance is open

    Specified by:
    assertIsOpen in interface PersistenceManagerInternal

    getStoreManager

    public StoreManager getStoreManager()
    Description copied from interface: PersistenceManagerInternal
    Provides a StoreManager that is ready to accept operations on it.

    Specified by:
    getStoreManager in interface PersistenceManagerInternal
    Returns:
    A StoreManager.
    See Also:
    PersistenceManagerInternal.getStoreManager()

    newSCOInstanceInternal

    public java.lang.Object newSCOInstanceInternal(java.lang.Class type)
    Called by internally by the runtime to create a new tracked instance. Will not result in marking field as dirty

    Specified by:
    newSCOInstanceInternal in interface PersistenceManagerInternal
    Parameters:
    type - Class of the new SCO instance
    Returns:
    the object of the class type
    See Also:
    (Class type)

    newCollectionInstanceInternal

    public java.util.Collection newCollectionInstanceInternal(java.lang.Class type,
                                                              java.lang.Class elementType,
                                                              boolean allowNulls,
                                                              java.lang.Integer initialSize,
                                                              java.lang.Float loadFactor,
                                                              java.util.Collection initialContents,
                                                              java.util.Comparator comparator)
    Called by internally by the runtime to create a new tracked instance. Will not result in marking field as dirty

    Specified by:
    newCollectionInstanceInternal in interface PersistenceManagerInternal
    See Also:
    PersistenceManagerInternal.newCollectionInstanceInternal(Class type, Class elementType, boolean allowNulls, Integer initialSize, Float loadFactor, Collection initialContents, Comparator comparator)

    newMapInstanceInternal

    public java.util.Map newMapInstanceInternal(java.lang.Class type,
                                                java.lang.Class keyType,
                                                java.lang.Class valueType,
                                                boolean allowNulls,
                                                java.lang.Integer initialSize,
                                                java.lang.Float loadFactor,
                                                java.util.Map initialContents,
                                                java.util.Comparator comparator)
    Called by internally by the runtime to create a new tracked instance. Will not result in marking field as dirty.

    Specified by:
    newMapInstanceInternal in interface PersistenceManagerInternal
    See Also:
    PersistenceManagerInternal.newMapInstanceInternal(Class type, Class keyType, Class valueType, boolean allowNulls, Integer initialSize, Float loadFactor, Map initialContents, Comparator comparator)

    isSupportedSCOType

    public boolean isSupportedSCOType(java.lang.Class type)
    Description copied from interface: PersistenceManagerInternal
    Called by StateManager to verify field type.

    Specified by:
    isSupportedSCOType in interface PersistenceManagerInternal
    Parameters:
    type - Class type of the field.
    Returns:
    true if this type is a supported SCO type.
    See Also:
    (Class type)

    register

    public void register(StateManagerInternal sm,
                         java.lang.Object oid,
                         boolean transactional,
                         boolean throwDuplicateException)
    Description copied from interface: PersistenceManagerInternal
    Adds persistent object to the cache.

    Specified by:
    register in interface PersistenceManagerInternal
    Parameters:
    sm - instance of StateManagerInternal to be added
    oid - ObjectId of the corresponding persistence-capable instance
    transactional - true if the corresponding lifecycle state is transactional
    throwDuplicateException - true if the exception should be thrown in case the same ObjectId has been already registered.
    See Also:
    PersistenceManagerInternal.register(StateManagerInternal sm, Object oid, boolean transactional, boolean throwDuplicateException)

    registerTransient

    public void registerTransient(StateManagerInternal sm)
    Description copied from interface: PersistenceManagerInternal
    Adds transient object to the transient cache.

    Specified by:
    registerTransient in interface PersistenceManagerInternal
    Parameters:
    sm - instance of StateManagerInternal to be added
    See Also:
    PersistenceManagerInternal.registerTransient(StateManagerInternal sm)

    deregister

    public void deregister(java.lang.Object oid)
    Description copied from interface: PersistenceManagerInternal
    Removes the object from the cache.

    Specified by:
    deregister in interface PersistenceManagerInternal
    Parameters:
    oid - ObjectId of the instance to be removed.
    See Also:
    PersistenceManagerInternal.deregister(Object oid)

    deregisterTransient

    public void deregisterTransient(StateManagerInternal sm)
    Description copied from interface: PersistenceManagerInternal
    Removes transient object from the transient cache.

    Specified by:
    deregisterTransient in interface PersistenceManagerInternal
    Parameters:
    sm - instance of StateManagerInternal to be removed
    See Also:
    PersistenceManagerInternal.deregisterTransient(StateManagerInternal sm)

    replaceObjectId

    public void replaceObjectId(java.lang.Object oldId,
                                java.lang.Object newId)
    Description copied from interface: PersistenceManagerInternal
    Replaces the objectId key value in the cache.

    Specified by:
    replaceObjectId in interface PersistenceManagerInternal
    Parameters:
    oldId - previous value of ObjectId.
    newId - new value of ObjectId.
    See Also:
    PersistenceManagerInternal.replaceObjectId(Object oldId, Object newId)

    markAsFlushed

    public void markAsFlushed(StateManagerInternal sm)
    Description copied from interface: PersistenceManagerInternal
    Called by StateManagerInternal#markAsFlushed() to adjust transactional cache(s) if necessary after successful flush to the data store.

    Specified by:
    markAsFlushed in interface PersistenceManagerInternal
    Parameters:
    sm - StateManagerInternal instance that has been flushed
    See Also:
    PersistenceManagerInternal.markAsFlushed(StateManagerInternal sm)

    insideCommit

    public boolean insideCommit()
    Description copied from interface: PersistenceManagerInternal
    Returns true if the call initiated as a result of the commit process, versus flush for query in a datastore transaction.

    Specified by:
    insideCommit in interface PersistenceManagerInternal
    Returns:
    true if commit has started
    See Also:
    PersistenceManagerInternal.insideCommit()

    hereIsStateManager

    public void hereIsStateManager(StateManagerInternal sm,
                                   javax.jdo.spi.PersistenceCapable pc)
    A helper method called from the StateManager inside getPersistenceManager() to identify StateManager associated with this PC instance

    Specified by:
    hereIsStateManager in interface PersistenceManagerInternal
    Parameters:
    pc - PC instance
    sm - StateManager to save

    getStateManager

    public StateManagerInternal getStateManager(java.lang.Object oid,
                                                java.lang.Class pcClass)
    Description copied from interface: PersistenceManagerInternal
    Provides a StateManagerInternal for the given Object Id.

    Specified by:
    getStateManager in interface PersistenceManagerInternal
    Parameters:
    oid - the given Object Id.
    pcClass - Class of a PersistenceCapable instance to be created if this Object Id was not registered with this PersistenceManager.
    Returns:
    A StateManagerInternal.
    See Also:
    PersistenceManagerInternal.getStateManager(java.lang.Object, java.lang.Class)

    findStateManager

    public StateManagerInternal findStateManager(javax.jdo.spi.PersistenceCapable pc)
    A helper method to find the StateManager associated with this PC instance

    Specified by:
    findStateManager in interface PersistenceManagerInternal
    Parameters:
    pc - PC instance
    Returns:
    StateManager as StateManagerInternal

    getCurrentWrapper

    public javax.jdo.PersistenceManager getCurrentWrapper()
    Returns current wrapper

    Specified by:
    getCurrentWrapper in interface PersistenceManagerInternal

    getInsertedInstances

    public java.util.Collection getInsertedInstances()
    Returns a Collection of instances that has been made persistent or become persistent through persistence-by-reachability algorithm in this transaction. Called by the Extent.iterator.

    Specified by:
    getInsertedInstances in interface PersistenceManagerInternal
    Returns:
    Collection of Persistent-New instances.
    See Also:
    PersistenceManagerInternal.getInsertedInstances()

    hashCode

    public int hashCode()
    Returns a hash code value for this PersistenceManager.

    Overrides:
    hashCode in class java.lang.Object
    Returns:
    a hash code value for this PersistenceManager.

    equals

    public boolean equals(java.lang.Object obj)
    Indicates whether some other object is "equal to" this one.

    Overrides:
    equals in class java.lang.Object
    Parameters:
    obj - the reference object with which to compare.
    Returns:
    true if this object is the same as the obj argument; false otherwise.

    pushCurrentWrapper

    protected void pushCurrentWrapper(PersistenceManagerWrapper pmw)
    Remember the current wrapper


    popCurrentWrapper

    protected void popCurrentWrapper(PersistenceManagerWrapper prev)
    Replace current wrapper with the previous


    setJTATransaction

    protected void setJTATransaction(java.lang.Object t)
    with the current thread in the managed environment


    deregisterJTA

    protected void deregisterJTA()
    Disassociate this PersistenceManager with the current JTA transaction.


    forceClose

    protected void forceClose()
    Close this persistence manager even if there are open wrappers or an uncomplete transaction. Called by transaction completion in case of an inconsistent state or as a part of a normal close process.


    verify

    protected boolean verify(java.lang.String username,
                             java.lang.String password)
    Verify that cached instance of a PersistenceManager was initialy requested with the same values for username and password


    flushInstances

    protected void flushInstances()
    Called by Transaction commit() Loops through transactional cache and calls PersistentStore.updatePersistent() on each instance


    afterCompletion

    protected void afterCompletion(int status)
    Called by Transaction commit() or rollback() cleans up transactional cache

    Parameters:
    status - javax.transaction.Status

    flush

    public void flush()
    Called by Query or Extent to flush updates to the database in a datastore transaction. Delegates to TransactionImpl to do the processing that will call internaly flushInstances() to do actual flush.

    Specified by:
    flush in interface PersistenceManagerInternal
    See Also:
    flushInstances()

    notifyStatusChange

    protected void notifyStatusChange(boolean isActive)
    For Transaction to notify PersistenceManager that status is changed


    notifyOptimistic

    protected void notifyOptimistic(boolean optimistic)
    For Transaction to notify PersistenceManager that optimistic flag is changed


    getContextClassLoaderPrivileged

    public java.lang.ClassLoader getContextClassLoaderPrivileged()
                                                          throws java.lang.SecurityException
    Calls getContextClassLoader for the current Thread in a doPrivileged block.

    Returns:
    the context class loader of the current Thread
    Throws:
    java.lang.SecurityException - thrown by getContextClassLoader.

    assertReadAllowed

    public void assertReadAllowed()
    Assert the NontransactionalRead flag is true or a transaction is active.

    Specified by:
    assertReadAllowed in interface PersistenceManagerInternal


    Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.