org.castor.persist
Class AbstractTransactionContext

java.lang.Object
  extended by org.castor.persist.AbstractTransactionContext
All Implemented Interfaces:
TransactionContext
Direct Known Subclasses:
GlobalTransactionContext, LocalTransactionContext

public abstract class AbstractTransactionContext
extends java.lang.Object
implements TransactionContext

A transaction context is required in order to perform operations against the database. The transaction context is mapped to an API transaction or an XA transaction. The only way to begin a new transaction is through the creation of a new transaction context. A transaction context is created from an implementation class directly or through XAResourceImpl.

Since:
1.0
Version:
$Revision: 8471 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
Author:
Assaf Arkin , Ralf Joachim, Werner Guttmann, Gregory Block

Constructor Summary
AbstractTransactionContext(Database db)
          Create a new transaction context.
 
Method Summary
 void addTxSynchronizable(TxSynchronizable synchronizable)
          Register a listener which wants to synchronize its state to the state of the transaction.
protected  void clearConnections()
           
 void close()
          Closes all Connections.
protected abstract  void closeConnections()
          The derived class must implement this method and close all the connections used in this transaction.
 void commit()
          Commits all changes and closes the transaction releasing all locks on all objects.
protected abstract  void commitConnections()
          The derived class must implement this method and commit all the connections used in this transaction.
protected  java.util.Iterator<java.sql.Connection> connectionsIterator()
           
 void create(ClassMolder molder, java.lang.Object object, OID depended)
          Creates a new object in persistent storage.
protected abstract  java.sql.Connection createConnection(LockEngine engine)
           
 void delete(java.lang.Object object)
          Deletes the object from persistent storage.
 void expireCache(ClassMolder molder, Identity identity)
          Expire object from the cache.
 java.lang.Object fetch(ClassMolder molder, Identity identity, AccessMode suggestedAccessMode)
          
 java.lang.ClassLoader getClassLoader()
          Get the current application ClassLoader.
 java.sql.Connection getConnection(LockEngine engine)
          Return an open connection for the specified engine.
 DbMetaInfo getConnectionInfo(LockEngine engine)
          Returns meta-data related to the RDBMS used.
 Database getDatabase()
          
 int getLockTimeout()
          Returns the timeout waiting to acquire a lock.
 NamedNativeQuery getNamedNativeQuery(ClassMolder molder, java.lang.String name)
          Returns a NamedNativeQuery instance query based upon a named query as defined in the mapping file.
 java.lang.String getNamedQuery(ClassMolder molder, java.lang.String name)
          Creates an OQL query based upon a named query as defined in the mapping file.
 int getStatus()
          Returns the status of this transaction.
 int getTransactionTimeout()
          Returns the timeout of this transaction.
 ObjectLock getWaitOnLock()
          Returns the lock which this transaction attempts to acquire.
 boolean isAutoStore()
          Test if autoStore option is enabled or not.
 boolean isCached(ClassMolder molder, java.lang.Class cls, Identity identity)
          
 boolean isCreated(java.lang.Object object)
          Returns true if the object is marked as created in this transaction.
 boolean isDeleted(java.lang.Object object)
          Returns true if and only if the specified object is loaded or created in this transaction and is deleted.
 boolean isDeletedByOID(OID oid)
          
 boolean isDepended(OID master, java.lang.Object dependent)
          
 boolean isLocked(java.lang.Class cls, Identity identity, LockEngine lockEngine)
          Returns true if the object given is locked.
 boolean isOpen()
          Returns true if the transaction is open.
 boolean isPersistent(java.lang.Object object)
          Returns true if the object is persistent in this transaction.
 boolean isReadOnly(java.lang.Object object)
          Check to see whether this transaction considers an object to have been marked read-only.
 boolean isRecorded(java.lang.Object object)
          Returns true if the object is previously queried/loaded/update/create in this transaction.
 boolean isUpdateCacheNeeded(java.lang.Object object)
          Retrieves the state of the object in this transaction.
 boolean isUpdatePersistNeeded(java.lang.Object object)
          Retrieves the state of the object in this transaction.
 java.util.Iterator iterateReadWriteObjectsInTransaction()
          Expose an enumeration of the commited object entries to allow TxSynchronizable to iterate through the objects.
 java.lang.Object load(Identity identity, ProposedEntity proposedObject, AccessMode suggestedAccessMode)
          Load an object for use within the transaction.
 java.lang.Object load(Identity identity, ProposedEntity proposedObject, AccessMode suggestedAccessMode, QueryResults results)
          Load an object for use within the transaction.
 void markCreate(ClassMolder molder, java.lang.Object object, OID rootObjectOID)
          Walk a data object tree starting from the specified object, and mark all objects to be created.
 void markModified(java.lang.Object object, boolean updatePersist, boolean updateCache)
          
 boolean markUpdate(ClassMolder molder, java.lang.Object object, OID depended)
          Update a new object in persistent storage and returns the object's OID.
 boolean prepare()
          Prepares the transaction prior to committing it.
 QueryResults query(LockEngine engine, PersistenceQuery query, AccessMode accessMode, boolean scrollable)
          Perform a query using the query mechanism with the specified access mode.
 void removeTxSynchronizable(TxSynchronizable synchronizable)
          Unregister a listener which wants to synchronize its state to the state of the transaction.
 void rollback()
          Rolls back all changes and closes the transaction releasing all locks on all objects.
protected abstract  void rollbackConnections()
          The derived class must implement this method and rollback all the connections used in this transaction.
 void setAutoStore(boolean autoStore)
          Enable or disable autoStore.
 void setCallback(CallbackInterceptor callback)
          Overrides the default callback interceptor by a custom interceptor for this database source.
 void setInstanceFactory(InstanceFactory factory)
          Overrides the default instance factory by a custom one for this database source.
 void setLockTimeout(int timeout)
          Sets the timeout waiting to acquire a lock.
 void setStatus(int status)
          Sets the status of the current transaction to the given one.
 void setTransactionTimeout(int timeout)
          Sets the timeout of this transaction.
 void setWaitOnLock(ObjectLock lock)
          Indicates which lock this transaction is waiting for.
 void trackObject(ClassMolder molder, OID oid, java.lang.Object object)
           
 void untrackObject(java.lang.Object object)
           
 void update(ClassMolder molder, java.lang.Object object, OID depended)
          Update a new object in persistent storage and returns the object's OID.
 void writeLock(java.lang.Object object, int timeout)
          Acquire a write lock on the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTransactionContext

public AbstractTransactionContext(Database db)
Create a new transaction context. This method is used by the explicit transaction model.

Parameters:
db - Database instance
Method Detail

addTxSynchronizable

public final void addTxSynchronizable(TxSynchronizable synchronizable)
Register a listener which wants to synchronize its state to the state of the transaction.

Specified by:
addTxSynchronizable in interface TransactionContext
Parameters:
synchronizable - The TxSynchronizable implementation to register.
See Also:
TransactionContext.addTxSynchronizable( org.exolab.castor.persist.TxSynchronizable)

removeTxSynchronizable

public final void removeTxSynchronizable(TxSynchronizable synchronizable)
Unregister a listener which wants to synchronize its state to the state of the transaction.

Specified by:
removeTxSynchronizable in interface TransactionContext
Parameters:
synchronizable - The TxSynchronizable implementation to unregister.
See Also:
TransactionContext.removeTxSynchronizable( org.exolab.castor.persist.TxSynchronizable)

setAutoStore

public final void setAutoStore(boolean autoStore)
Enable or disable autoStore. If enabled, all new objects, which are reachable from other object that are queried, loaded, created in the transaction, will be created when the transaction is committed.

Specified by:
setAutoStore in interface TransactionContext
Parameters:
autoStore - When set to true autoStore will be enabled.
See Also:
TransactionContext.setAutoStore(boolean)

isAutoStore

public final boolean isAutoStore()
Test if autoStore option is enabled or not.

Specified by:
isAutoStore in interface TransactionContext
Returns:
true if autoStore option is enabled.
See Also:
TransactionContext.isAutoStore()

setCallback

public final void setCallback(CallbackInterceptor callback)
Overrides the default callback interceptor by a custom interceptor for this database source.

The interceptor is a callback that notifies data objects on persistent state events.

If callback interceptor is not overriden, events will be sent to data object that implements the org.exolab.castor.jdo.Persistent interface.

Specified by:
setCallback in interface TransactionContext
Parameters:
callback - The callback interceptor, disabled if null.
See Also:
TransactionContext.setCallback( org.exolab.castor.persist.spi.CallbackInterceptor)

setInstanceFactory

public final void setInstanceFactory(InstanceFactory factory)
Overrides the default instance factory by a custom one for this database source.

The factory is used to obatain a new instance of data object when it is needed during loading.

Specified by:
setInstanceFactory in interface TransactionContext
Parameters:
factory - The instanceFactory to be used, disable if null.
See Also:
TransactionContext.setInstanceFactory( org.exolab.castor.persist.spi.InstanceFactory)

setTransactionTimeout

public final void setTransactionTimeout(int timeout)
Sets the timeout of this transaction. The timeout is specified in seconds.

Specified by:
setTransactionTimeout in interface TransactionContext
Parameters:
timeout - The timeout for this transaction in seconds.
See Also:
TransactionContext.setTransactionTimeout(int)

getTransactionTimeout

public final int getTransactionTimeout()
Returns the timeout of this transaction. The timeout is specified in seconds.

Specified by:
getTransactionTimeout in interface TransactionContext
Returns:
The timeout of this transaction in seconds.
See Also:
TransactionContext.getTransactionTimeout()

getLockTimeout

public final int getLockTimeout()
Returns the timeout waiting to acquire a lock. The timeout is specified in seconds.

Specified by:
getLockTimeout in interface TransactionContext
Returns:
The timeout waiting to acquire a lock in seconds.
See Also:
TransactionContext.getLockTimeout()

setLockTimeout

public final void setLockTimeout(int timeout)
Sets the timeout waiting to acquire a lock. The timeout is specified in seconds.

Specified by:
setLockTimeout in interface TransactionContext
Parameters:
timeout - The timeout waiting to acquire a lock in seconds.
See Also:
TransactionContext.setLockTimeout(int)

setStatus

public final void setStatus(int status)
Sets the status of the current transaction to the given one.

Specified by:
setStatus in interface TransactionContext
Parameters:
status - The status to set for this transaction.
See Also:
TransactionContext.setStatus(int)

getConnection

public final java.sql.Connection getConnection(LockEngine engine)
                                        throws ConnectionFailedException
Return an open connection for the specified engine. Only one connection should be created for a given engine in the same transaction.

Specified by:
getConnection in interface TransactionContext
Parameters:
engine - The persistence engine.
Returns:
An open connection.
Throws:
ConnectionFailedException
See Also:
TransactionContext.getConnection( org.exolab.castor.persist.LockEngine)

createConnection

protected abstract java.sql.Connection createConnection(LockEngine engine)
                                                 throws ConnectionFailedException
Throws:
ConnectionFailedException

connectionsIterator

protected final java.util.Iterator<java.sql.Connection> connectionsIterator()

clearConnections

protected final void clearConnections()

commitConnections

protected abstract void commitConnections()
                                   throws TransactionAbortedException
The derived class must implement this method and commit all the connections used in this transaction. If the transaction could not commit fully or partially, this method will throw an TransactionAbortedException, causing a rollback to occur as the next step.

Throws:
TransactionAbortedException - The transaction could not commit fully or partially and should be rolled back.

closeConnections

protected abstract void closeConnections()
                                  throws TransactionAbortedException
The derived class must implement this method and close all the connections used in this transaction.

Throws:
TransactionAbortedException - The transaction could not close all the connections.

rollbackConnections

protected abstract void rollbackConnections()
The derived class must implement this method and rollback all the connections used in this transaction. The connections may be closed, as they will not be reused in this transaction. This operation is guaranteed to succeed.


getConnectionInfo

public final DbMetaInfo getConnectionInfo(LockEngine engine)
                                   throws PersistenceException
Returns meta-data related to the RDBMS used.

Specified by:
getConnectionInfo in interface TransactionContext
Parameters:
engine - LockEngine instance used.
Returns:
A DbMetaInfo instance describing various features of the underlying RDBMS.
Throws:
PersistenceException - An error occured talking to the persistence engine.
See Also:
TransactionContext.getConnectionInfo( org.exolab.castor.persist.LockEngine)

fetch

public final java.lang.Object fetch(ClassMolder molder,
                                    Identity identity,
                                    AccessMode suggestedAccessMode)
                             throws PersistenceException

Specified by:
fetch in interface TransactionContext
Throws:
PersistenceException
See Also:
#fetch(org.exolab.castor.persist.ClassMolder, org.exolab.castor.persist.spi.Identity, org.exolab.castor.mapping.AccessMode)

load

public final java.lang.Object load(Identity identity,
                                   ProposedEntity proposedObject,
                                   AccessMode suggestedAccessMode)
                            throws PersistenceException
Load an object for use within the transaction. Multiple access to the same object within the transaction will return the same object instance (except for read-only access).

This method is similar to TransactionContext.fetch(org.exolab.castor.persist.ClassMolder, org.exolab.castor.persist.spi.Identity, org.exolab.castor.mapping.AccessMode) except that it will load the object only once within a transaction and always return the same instance.

If the object is loaded for read-only then no lock is acquired and updates to the object are not reflected at commit time. If the object is loaded for read-write then a read lock is acquired (unless timeout or deadlock detected) and the object is stored at commit time. The object is then considered persistent and may be deleted or upgraded to write lock. If the object is loaded for exclusive access then a write lock is acquired and the object is synchronized with the persistent copy.

Attempting to load the object twice in the same transaction, once with exclusive lock and once with read-write lock will result in an exception.

Specified by:
load in interface TransactionContext
Parameters:
identity - The object's identity.
proposedObject - The object to fetch (single instance per transaction).
suggestedAccessMode - The access mode (see AccessMode) the values in persistent storage.
Returns:
object being loaded.
Throws:
PersistenceException - Timeout or deadlock occured attempting to acquire lock on object. The object was not found in persistent storage. An error reported by the persistence engine.
See Also:
TransactionContext.load( org.exolab.castor.persist.spi.Identity, org.castor.persist.ProposedEntity, org.exolab.castor.mapping.AccessMode)

load

public final java.lang.Object load(Identity identity,
                                   ProposedEntity proposedObject,
                                   AccessMode suggestedAccessMode,
                                   QueryResults results)
                            throws PersistenceException
Load an object for use within the transaction. Multiple access to the same object within the transaction will return the same object instance (except for read-only access).

In addition to TransactionContext.load(Identity,ProposedEntity,AccessMode) a QueryResults can be specified.

Specified by:
load in interface TransactionContext
Parameters:
identity - The object's identity.
proposedObject - The object to fetch (single instance per transaction).
suggestedAccessMode - The access mode (see AccessMode) the values in persistent storage.
results - The QueryResult that the data to be loaded from.
Returns:
object being loaded.
Throws:
PersistenceException - Timeout or deadlock occured attempting to acquire lock on object. The object was not found in persistent storage. An error reported by the persistence engine.
See Also:
TransactionContext.load( org.exolab.castor.persist.spi.Identity, org.castor.persist.ProposedEntity, org.exolab.castor.mapping.AccessMode, org.exolab.castor.persist.QueryResults)

untrackObject

public void untrackObject(java.lang.Object object)

trackObject

public void trackObject(ClassMolder molder,
                        OID oid,
                        java.lang.Object object)

query

public final QueryResults query(LockEngine engine,
                                PersistenceQuery query,
                                AccessMode accessMode,
                                boolean scrollable)
                         throws PersistenceException
Perform a query using the query mechanism with the specified access mode. The query is performed in this transaction, and the returned query results can only be used while this transaction is open. It is assumed that the query mechanism is compatible with the persistence engine.

Specified by:
query in interface TransactionContext
Parameters:
engine - The persistence engine.
query - A query against the persistence engine.
accessMode - The access mode.
scrollable - The db cursor mode.
Returns:
A query result iterator
Throws:
PersistenceException - An error reported by the persistence engine or an invalid query.
See Also:
TransactionContext.query( org.exolab.castor.persist.LockEngine, org.exolab.castor.persist.spi.PersistenceQuery, org.exolab.castor.mapping.AccessMode, boolean)

markCreate

public final void markCreate(ClassMolder molder,
                             java.lang.Object object,
                             OID rootObjectOID)
                      throws PersistenceException
Walk a data object tree starting from the specified object, and mark all objects to be created.

Specified by:
markCreate in interface TransactionContext
Parameters:
molder - The class persistence molder.
object - The object to persist.
rootObjectOID - The OID of the root object to start walking.
Throws:
PersistenceException - An object with this identity already exists in persistent storage. The class is not persistent capable. An error reported by the persistence engine.
See Also:
TransactionContext.markCreate( org.exolab.castor.persist.ClassMolder, java.lang.Object, org.exolab.castor.persist.OID)

create

public final void create(ClassMolder molder,
                         java.lang.Object object,
                         OID depended)
                  throws PersistenceException
Creates a new object in persistent storage. The object will be persisted only if the transaction commits. If an identity is provided then duplicate identity check happens in this method, if no identity is provided then duplicate identity check occurs when the transaction completes and the object is not visible in this transaction.

Specified by:
create in interface TransactionContext
Parameters:
molder - The molder of the creating class.
object - The object to persist.
depended - The master object's OID if exist.
Throws:
PersistenceException - An object with this identity already exists in persistent storage. The class is not persistent capable. An error reported by the persistence engine.
See Also:
TransactionContext.create( org.exolab.castor.persist.ClassMolder, java.lang.Object, org.exolab.castor.persist.OID)

markUpdate

public final boolean markUpdate(ClassMolder molder,
                                java.lang.Object object,
                                OID depended)
                         throws PersistenceException
Update a new object in persistent storage and returns the object's OID. The object will be persisted only if the transaction commits. If an identity is provided then duplicate identity check happens in this method, if no identity is provided then duplicate identity check occurs when the transaction completes and the object is not visible in this transaction.

Update will also mark objects to be created if the TIMESTAMP equals to NO_TIMESTAMP.

Specified by:
markUpdate in interface TransactionContext
Parameters:
molder - The object's molder.
object - The object to persist.
depended - The master objects of the specified object to be created if exisit.
Returns:
true if the object is marked to be created.
Throws:
PersistenceException - An object with this identity already exists in persistent storage. The class is not persistent capable. Dirty checking mechanism may immediately report that the object was modified in the database during the long transaction. An error reported by the persistence engine.
See Also:
TransactionContext.markUpdate( org.exolab.castor.persist.ClassMolder, java.lang.Object, org.exolab.castor.persist.OID)

update

public final void update(ClassMolder molder,
                         java.lang.Object object,
                         OID depended)
                  throws PersistenceException
Update a new object in persistent storage and returns the object's OID. The object will be persisted only if the transaction commits. If an identity is provided then duplicate identity check happens in this method, if no identity is provided then duplicate identity check occurs when the transaction completes and the object is not visible in this transaction.

Update will also mark objects to be created if the TIMESTAMP equals to NO_TIMESTAMP.

Specified by:
update in interface TransactionContext
Parameters:
molder - The object's molder.
object - The object to persist.
depended - The master objects of the specified object to be created if exisit.
Throws:
PersistenceException - An object with this identity already exists in persistent storage. The class is not persistent capable. Dirty checking mechanism may immediately report that the object was modified in the database during the long transaction. An error reported by the persistence engine.
See Also:
TransactionContext.update( org.exolab.castor.persist.ClassMolder, java.lang.Object, org.exolab.castor.persist.OID)

delete

public final void delete(java.lang.Object object)
                  throws PersistenceException
Deletes the object from persistent storage. The deletion will take effect only if the transaction is committed, but the object is no longer viewable for the current transaction and locks for access from other transactions will block until this transaction completes. A write lock is acquired in order to assure the object can be deleted.

Specified by:
delete in interface TransactionContext
Parameters:
object - The object to delete from persistent storage.
Throws:
PersistenceException - The object has not been queried or created in this transaction. Timeout or deadlock occured attempting to acquire lock on object. An error reported by the persistence engine.
See Also:
TransactionContext.delete(java.lang.Object)

writeLock

public final void writeLock(java.lang.Object object,
                            int timeout)
                     throws PersistenceException
Acquire a write lock on the object. Read locks are implicitly available when the object is queried. A write lock is only granted for objects that are created or deleted or for objects loaded in exclusive mode - this method can obtain such a lock explicitly. If the object already has a write lock in this transaction or a read lock in this transaction but no read lock in any other transaction, a write lock is obtained. If this object has a read lock in any other transaction this method will block until the other transaction will release its lock. If the specified timeout has elapsed or a deadlock has been detected, an exception will be thrown but the current lock will be retained.

Specified by:
writeLock in interface TransactionContext
Parameters:
object - The object to lock.
timeout - Timeout waiting to acquire lock, specified in seconds, zero for no waiting, negative to use the default timeout for this transaction.
Throws:
PersistenceException - The object has not been queried or created in this transaction. Timeout or deadlock occured attempting to acquire lock on object. An error reported by the persistence engine.
See Also:
TransactionContext.writeLock(java.lang.Object, int)

markModified

public final void markModified(java.lang.Object object,
                               boolean updatePersist,
                               boolean updateCache)

Specified by:
markModified in interface TransactionContext
See Also:
TransactionContext.markModified( java.lang.Object, boolean, boolean)

prepare

public final boolean prepare()
                      throws TransactionAbortedException
Prepares the transaction prior to committing it. Indicates whether the transaction is read-only (i.e. no modified objects), can commit, or an error has occured and the transaction must be rolled back. This method performs actual storage into the persistence storage. Multiple calls to this method can be done, and do not release locks, allowing checkpoint to occur. An IllegalStateException is thrown if transaction is not in the proper state to perform this operation.

Specified by:
prepare in interface TransactionContext
Returns:
True if the transaction can commit, false if the transaction is read only
Throws:
TransactionAbortedException - The transaction has been aborted due to inconsistency, duplicate object identity, error with the persistence engine or any other reason.
See Also:
TransactionContext.prepare()

commit

public final void commit()
                  throws TransactionAbortedException
Commits all changes and closes the transaction releasing all locks on all objects. All objects are now transient. Must be called after a call to TransactionContext.prepare() has returned successfully. Throws an IllegalStateException when called without calling TransactionContext.prepare() first.

Specified by:
commit in interface TransactionContext
Throws:
TransactionAbortedException - The transaction has been aborted due to inconsistency, duplicate object identity, error with the persistence engine or any other reason.
See Also:
TransactionContext.commit()

iterateReadWriteObjectsInTransaction

public final java.util.Iterator iterateReadWriteObjectsInTransaction()
Expose an enumeration of the commited object entries to allow TxSynchronizable to iterate through the objects.

Specified by:
iterateReadWriteObjectsInTransaction in interface TransactionContext
Returns:
Iterator of modifiable (read-write) object entries.
See Also:
TransactionContext.iterateReadWriteObjectsInTransaction()

rollback

public final void rollback()
Rolls back all changes and closes the transaction releasing all locks on all objects. All objects are now transient, if they were queried in this transaction. This method may be called at any point during the transaction. Throws an IllegalStateException if transaction is not in the proper state to perform this operation.

Specified by:
rollback in interface TransactionContext
See Also:
TransactionContext.rollback()

close

public final void close()
                 throws TransactionAbortedException
Closes all Connections. Must be called before the end of the transaction in EJB environment or after commit in standalone case. Throws an IllegalStateException if this method has been called after the end of the transaction.

Specified by:
close in interface TransactionContext
Throws:
TransactionAbortedException - The transaction has been aborted due to inconsistency, duplicate object identity, error with the persistence engine or any other reason.
See Also:
TransactionContext.close()

isCreated

public final boolean isCreated(java.lang.Object object)
Returns true if the object is marked as created in this transaction. Note that this does not find objects in the 'transitional' state of creating. Primarily intended to be used by tests.

Specified by:
isCreated in interface TransactionContext
Parameters:
object - The object to test the state of in this transaction.
Returns:
true if the object is marked as created within this transaction.
See Also:
TransactionContext.isCreated(java.lang.Object)

isUpdateCacheNeeded

public final boolean isUpdateCacheNeeded(java.lang.Object object)
Retrieves the state of the object in this transaction. Specifically, in this case, that the object requires a cache update.

Specified by:
isUpdateCacheNeeded in interface TransactionContext
Parameters:
object - The object to test the state of in this transaction.
Returns:
true if the object is recorded in this transaction with the requested state.
See Also:
TransactionContext.isUpdateCacheNeeded(java.lang.Object)

isUpdatePersistNeeded

public final boolean isUpdatePersistNeeded(java.lang.Object object)
Retrieves the state of the object in this transaction. Specifically, in this case, that the object requires a persistence update.

Specified by:
isUpdatePersistNeeded in interface TransactionContext
Parameters:
object - The object to test the state of in this transaction.
Returns:
true if the object is recorded in this transaction with the requested state.
See Also:
TransactionContext.isUpdatePersistNeeded(java.lang.Object)

isPersistent

public final boolean isPersistent(java.lang.Object object)
Returns true if the object is persistent in this transaction.

Specified by:
isPersistent in interface TransactionContext
Parameters:
object - The object.
Returns:
true if persistent in transaction.
See Also:
TransactionContext.isPersistent(java.lang.Object)

isRecorded

public final boolean isRecorded(java.lang.Object object)
Returns true if the object is previously queried/loaded/update/create in this transaction.

Specified by:
isRecorded in interface TransactionContext
Parameters:
object - The object.
Returns:
true if recorded in this transaction.
See Also:
TransactionContext.isRecorded(java.lang.Object)

isDepended

public final boolean isDepended(OID master,
                                java.lang.Object dependent)

Specified by:
isDepended in interface TransactionContext
See Also:
TransactionContext.isDepended( org.exolab.castor.persist.OID, java.lang.Object)

getStatus

public final int getStatus()
Returns the status of this transaction.

Specified by:
getStatus in interface TransactionContext
Returns:
The status of this transaction.
See Also:
TransactionContext.getStatus()

isOpen

public final boolean isOpen()
Returns true if the transaction is open.

Specified by:
isOpen in interface TransactionContext
Returns:
true if the transaction is open.
See Also:
TransactionContext.isOpen()

setWaitOnLock

public final void setWaitOnLock(ObjectLock lock)
Indicates which lock this transaction is waiting for. When a transaction attempts to acquire a lock it must indicate which lock it attempts to acquire in order to perform dead-lock detection. This method is called by ObjectLock before entering the temporary lock-acquire state.

Specified by:
setWaitOnLock in interface TransactionContext
Parameters:
lock - The lock which this transaction attempts to acquire
See Also:
TransactionContext.setWaitOnLock( org.exolab.castor.persist.ObjectLock)

getWaitOnLock

public final ObjectLock getWaitOnLock()
Returns the lock which this transaction attempts to acquire.

Specified by:
getWaitOnLock in interface TransactionContext
Returns:
The lock which this transaction attempts to acquire
See Also:
TransactionContext.getWaitOnLock()

isDeleted

public final boolean isDeleted(java.lang.Object object)
Returns true if and only if the specified object is loaded or created in this transaction and is deleted.

Specified by:
isDeleted in interface TransactionContext
Parameters:
object - The object to test the state of in this transaction.
Returns:
true if the object is deleted.
See Also:
TransactionContext.isDeleted(java.lang.Object)

isDeletedByOID

public final boolean isDeletedByOID(OID oid)

Specified by:
isDeletedByOID in interface TransactionContext
See Also:
TransactionContext.isDeletedByOID( org.exolab.castor.persist.OID)

getClassLoader

public final java.lang.ClassLoader getClassLoader()
Get the current application ClassLoader.

Specified by:
getClassLoader in interface TransactionContext
Returns:
the current ClassLoader's instance. null if none has been provided
See Also:
TransactionContext.getClassLoader()

expireCache

public final void expireCache(ClassMolder molder,
                              Identity identity)
                       throws PersistenceException
Expire object from the cache. Objects expired from the cache will be read from persistent storage, as opposed to being read from the cache, during subsequent load/query operations.

Specified by:
expireCache in interface TransactionContext
Parameters:
molder - The class persistence molder.
identity - The object's identity.
Throws:
PersistenceException - If identity is null or any problem that happens during expiration of cache values.
See Also:
TransactionContext.expireCache( org.exolab.castor.persist.ClassMolder, org.exolab.castor.persist.spi.Identity)

isCached

public final boolean isCached(ClassMolder molder,
                              java.lang.Class cls,
                              Identity identity)
                       throws PersistenceException

Specified by:
isCached in interface TransactionContext
Throws:
PersistenceException
See Also:
TransactionContext.isCached( org.exolab.castor.persist.ClassMolder, java.lang.Class, org.exolab.castor.persist.spi.Identity)

isReadOnly

public final boolean isReadOnly(java.lang.Object object)
Check to see whether this transaction considers an object to have been marked read-only.

Specified by:
isReadOnly in interface TransactionContext
Parameters:
object - The object to test for read-only status
Returns:
true if the object is marked read-only in this transaction; otherwise, false.
See Also:
TransactionContext.isReadOnly(java.lang.Object)

getDatabase

public final Database getDatabase()

Specified by:
getDatabase in interface TransactionContext
See Also:
TransactionContext.getDatabase()

isLocked

public final boolean isLocked(java.lang.Class cls,
                              Identity identity,
                              LockEngine lockEngine)
Returns true if the object given is locked.

Specified by:
isLocked in interface TransactionContext
Parameters:
cls - Class instance of the object to be investigated.
identity - Identity of the object to be investigated.
lockEngine - Current LcokEngine instance
Returns:
True if the object in question is locked.

getNamedQuery

public final java.lang.String getNamedQuery(ClassMolder molder,
                                            java.lang.String name)
                                     throws QueryException
Creates an OQL query based upon a named query as defined in the mapping file.

Specified by:
getNamedQuery in interface TransactionContext
Parameters:
molder - Specific class molder.
name - Name of the (named) query to create.
Returns:
An OQL query
Throws:
QueryException - If the named query can not be found

getNamedNativeQuery

public final NamedNativeQuery getNamedNativeQuery(ClassMolder molder,
                                                  java.lang.String name)
                                           throws QueryException
Returns a NamedNativeQuery instance query based upon a named query as defined in the mapping file.

Specified by:
getNamedNativeQuery in interface TransactionContext
Parameters:
molder - Specific class molder.
name - Name of the (named) query to create.
Returns:
A NamedNativeQuery instance.
Throws:
QueryException - If the named query can not be found.


Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com