org.castor.persist
public interface TransactionContext
Since: 1.0
Version: $Revision: 6230 $ $Date: 2006-04-22 11:05:30 -0600 (Sat, 22 Apr 2006) $
Method Summary | |
---|---|
void | addTxSynchronizable(TxSynchronizable synchronizable)
Register a listener which wants to synchronize its state to the state of the
transaction.
|
void | close()
Closes all Connections. |
void | commit()
Commits all changes and closes the transaction releasing all locks on all
objects. |
void | create(ClassMolder molder, Object object, OID depended)
Creates a new object in persistent storage. |
void | delete(Object object)
Deletes the object from persistent storage. |
void | expireCache(ClassMolder molder, Identity identity)
Expire object from the cache. |
Object | fetch(ClassMolder molder, Identity identity, AccessMode suggestedAccessMode) |
ClassLoader | getClassLoader()
Get the current application ClassLoader.
|
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. |
String | getNamedQuery(ClassMolder molder, 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, Class cls, Identity identity) |
boolean | isCreated(Object object)
Returns true if the object is marked as created in this transaction. |
boolean | isDeleted(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, Object dependent) |
boolean | isLocked(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(Object object)
Returns true if the object is persistent in this transaction.
|
boolean | isReadOnly(Object object)
Check to see whether this transaction considers an object to have been marked
read-only.
|
boolean | isRecorded(Object object)
Returns true if the object is previously queried/loaded/update/create in
this transaction
|
boolean | isUpdateCacheNeeded(Object object)
Retrieves the state of the object in this transaction. |
boolean | isUpdatePersistNeeded(Object object)
Retrieves the state of the object in this transaction. |
Iterator | iterateReadWriteObjectsInTransaction()
Expose an enumeration of the commited object entries to allow TxSynchronizable
to iterate through the objects.
|
Object | load(Identity identity, ProposedEntity proposedObject, AccessMode suggestedAccessMode)
Load an object for use within the transaction. |
Object | load(Identity identity, ProposedEntity proposedObject, AccessMode suggestedAccessMode, QueryResults results)
Load an object for use within the transaction. |
void | markCreate(ClassMolder molder, Object object, OID rootObjectOID)
Walk a data object tree starting from the specified object, and mark all
objects to be created.
|
void | markModified(Object object, boolean updatePersist, boolean updateCache) |
boolean | markUpdate(ClassMolder molder, 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. |
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 | update(ClassMolder molder, Object object, OID depended)
Update a new object in persistent storage and returns the object's OID. |
void | writeLock(Object object, int timeout)
Acquire a write lock on the object. |
Parameters: synchronizable The TxSynchronizable implementation to register.
Throws: TransactionAbortedException The transaction has been aborted due to inconsistency, duplicate object identity, error with the persistence engine or any other reason.
Throws: TransactionAbortedException The transaction has been aborted due to inconsistency, duplicate object identity, error with the persistence engine or any other reason.
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.
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.
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.
Returns: the current ClassLoader's instance. null
if none
has been provided
Parameters: engine The persistence engine.
Returns: An open connection.
Throws: PersistenceException An error occured talking to the persistence engine.
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.
Returns: The timeout waiting to acquire a lock in seconds.
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
Returns: The status of this transaction.
Returns: The timeout of this transaction in seconds.
Returns: The lock which this transaction attempts to acquire
Returns: true
if autoStore option is enabled.
Parameters: object The object to test the state of in this transaction.
Returns: true
if the object is marked as created within this
transaction.
Parameters: object The object to test the state of in this transaction.
Returns: true
if the object is deleted.
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.
Returns: true
if the transaction is open.
Parameters: object The object.
Returns: true
if persistent in transaction.
Parameters: object The object to test for read-only status
Returns: true
if the object is marked read-only in this transaction;
otherwise, false
.
Parameters: object The object.
Returns: true
if recorded in this transaction.
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.
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.
Returns: Iterator of modifiable (read-write) object entries.
This method is similar to TransactionContext 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.
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.
In addition to load a QueryResults can be specified.
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.
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.
Update will also mark objects to be created if the TIMESTAMP equals to NO_TIMESTAMP.
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.
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.
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.
Parameters: synchronizable The TxSynchronizable implementation to unregister.
Parameters: autoStore When set to true
autoStore will be enabled.
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.
Parameters: callback The callback interceptor, disabled if null.
The factory is used to obatain a new instance of data object when it is needed during loading.
Parameters: factory The instanceFactory to be used, disable if null.
Parameters: timeout The timeout waiting to acquire a lock in seconds.
Parameters: status The status to set for this transaction.
Parameters: timeout The timeout for this transaction in seconds.
Parameters: lock The lock which this transaction attempts to acquire
Update will also mark objects to be created if the TIMESTAMP equals to NO_TIMESTAMP.
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.
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.