org.castor.persist
Class GlobalTransactionContext

java.lang.Object
  extended by org.castor.persist.AbstractTransactionContext
      extended by org.castor.persist.GlobalTransactionContext
All Implemented Interfaces:
TransactionContext

public final class GlobalTransactionContext
extends AbstractTransactionContext

A transaction context is required in order to perform operations against the database. The transaction context is mapped to Transaction for the ODMG API and into XAResource for XA databases. The only way to begin a new transaction is through the creation of a new transaction context. All database access must be performed through a transaction context.

Since:
1.0
Version:
$Revision: 8994 $ $Date: 2011-08-02 01:40:59 +0200 (Di, 02 Aug 2011) $
Author:
Ralf Joachim

Constructor Summary
GlobalTransactionContext(Database db)
          Create a new transaction context.
 
Method Summary
protected  void closeConnections()
          The derived class must implement this method and close all the connections used in this transaction.
protected  void commitConnections()
          The derived class must implement this method and commit all the connections used in this transaction.
protected  CastorConnection createConnection(LockEngine engine)
          Method creating a new CastorConnection and returning it.
protected  void rollbackConnections()
          The derived class must implement this method and rollback all the connections used in this transaction.
 
Methods inherited from class org.castor.persist.AbstractTransactionContext
addTxSynchronizable, clearConnections, close, commit, connectionsIterator, create, delete, expireCache, fetch, getClassLoader, getConnection, getConnectionInfo, getDatabase, getInstanceFactory, getLockTimeout, getNamedNativeQuery, getNamedQuery, getStatus, getTransactionTimeout, getWaitOnLock, isAutoStore, isCached, isCreated, isDeleted, isDeletedByOID, isDepended, isLocked, isOpen, isPersistent, isReadOnly, isRecorded, isUpdateCacheNeeded, isUpdatePersistNeeded, iterateReadWriteObjectsInTransaction, load, load, markCreate, markModified, markUpdate, prepare, query, removeTxSynchronizable, rollback, setAutoStore, setCallback, setInstanceFactory, setLockTimeout, setStatus, setTransactionTimeout, setWaitOnLock, trackObject, untrackObject, update, writeLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobalTransactionContext

public GlobalTransactionContext(Database db)
Create a new transaction context.

Parameters:
db - Database instance
Method Detail

createConnection

protected CastorConnection createConnection(LockEngine engine)
                                     throws ConnectionFailedException
Method creating a new CastorConnection and returning it.

Specified by:
createConnection in class AbstractTransactionContext
Parameters:
engine - Engine to get connection from.
Returns:
New CastorConnection.
Throws:
ConnectionFailedException - If creation of connection failed.

commitConnections

protected 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.

Specified by:
commitConnections in class AbstractTransactionContext
Throws:
TransactionAbortedException - The transaction could not commit fully or partially and should be rolled back.

rollbackConnections

protected 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.

Specified by:
rollbackConnections in class AbstractTransactionContext

closeConnections

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

Specified by:
closeConnections in class AbstractTransactionContext
Throws:
TransactionAbortedException - The transaction could not close all the connections.


Copyright © 2012. All Rights Reserved.