org.exolab.castor.jdo.engine
Class TransactionContextImpl

java.lang.Object
  extended by org.castor.persist.TransactionContext
      extended by org.exolab.castor.jdo.engine.TransactionContextImpl

final class TransactionContextImpl
extends TransactionContext

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.

Version:
$Revision: 1.14 $ $Date: 2005/07/24 17:48:18 $
Author:
Assaf Arkin

Constructor Summary
TransactionContextImpl(Database db, boolean globalTx)
          Create a new transaction context.
TransactionContextImpl(Database db, boolean globalTx, javax.transaction.Transaction transaction)
          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.
 java.sql.Connection getConnection(LockEngine engine)
          The derived class must implement this method and return an open connection for the specified engine.
 DbMetaInfo getConnectionInfo(LockEngine engine)
          Returns meta-data related to the RDBMS used.
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.TransactionContext
addTxSynchronizable, close, commit, create, delete, expireCache, fetch, getClassLoader, getDatabase, getLockTimeout, getObjectState, getScope, getStatus, getTransactionTimeout, getWaitOnLock, getXid, isAutoStore, isCached, isCreated, isDeleted, isDeletedByOID, isDepended, isOpen, isPersistent, isReadOnly, isRecorded, isUpdateCacheNeeded, isUpdatePersistNeeded, iterateReadWriteObjectsInTransaction, load, load, markCreate, markModified, markUpdate, prepare, query, query, release, removeTxSynchronizable, rollback, setAutoStore, setCallback, setInstanceFactory, setLockTimeout, setStatusActive, setTransactionTimeout, setWaitOnLock, softLock, txcommitted, txrolledback, update, writeLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionContextImpl

public TransactionContextImpl(Database db,
                              boolean globalTx)
Create a new transaction context.


TransactionContextImpl

public TransactionContextImpl(Database db,
                              boolean globalTx,
                              javax.transaction.Transaction transaction)
                       throws javax.transaction.SystemException
Create a new transaction context.

Parameters:
db - Database instance
globalTx - Indicates whether we run as part of a global transaction.
transaction - A JTA Transasction instance.
Throws:
javax.transaction.SystemException
Method Detail

commitConnections

protected void commitConnections()
                          throws TransactionAbortedException
Description copied from class: TransactionContext
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 TransactionContext
Throws:
TransactionAbortedException - The transaction could not commit fully or partially and should be rolled back

closeConnections

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

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

rollbackConnections

protected void rollbackConnections()
Description copied from class: TransactionContext
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 TransactionContext

getConnection

public java.sql.Connection getConnection(LockEngine engine)
                                  throws PersistenceException
Description copied from class: TransactionContext
The derived class must implement this method and return an open connection for the specified engine. The connection should be created only one for a given engine in the same transaction.

Specified by:
getConnection in class TransactionContext
Parameters:
engine - The persistence engine
Returns:
An open connection
Throws:
PersistenceException - An error occured talking to the persistence engine

getConnectionInfo

public DbMetaInfo getConnectionInfo(LockEngine engine)
                             throws PersistenceException
Description copied from class: TransactionContext
Returns meta-data related to the RDBMS used.

Specified by:
getConnectionInfo in class TransactionContext
Parameters:
engine - LockEngine instance used.
Returns:
DbMetaInfo object with database connection information
Throws:
PersistenceException


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