org.castor.persist
Class LocalTransactionContext

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

public final class LocalTransactionContext
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: 7951 $ $Date: 2006-04-13 10:49:49 -0600 (Thu, 13 Apr 2006) $
Author:
Ralf Joachim

Constructor Summary
LocalTransactionContext(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  java.sql.Connection createConnection(LockEngine engine)
          
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, getLockTimeout, 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, update, writeLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalTransactionContext

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

Parameters:
db - Database instance
Method Detail

createConnection

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

Specified by:
createConnection in class AbstractTransactionContext
Throws:
ConnectionFailedException
See Also:
#createConnection(org.exolab.castor.persist.LockEngine)

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.
See Also:
AbstractTransactionContext.commitConnections()

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
See Also:
AbstractTransactionContext.rollbackConnections()

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.
See Also:
AbstractTransactionContext.closeConnections()


Copyright © 2011. All Rights Reserved.