org.datanucleus
Class JTATransactionImpl

java.lang.Object
  extended by org.datanucleus.TransactionImpl
      extended by org.datanucleus.JTATransactionImpl
All Implemented Interfaces:
javax.transaction.Synchronization, Transaction

public class JTATransactionImpl
extends TransactionImpl
implements javax.transaction.Synchronization

A transaction that is synchronized with a Java Transaction Service (JTA) transaction. Works only in a J2EE environments where a TranactionManager is present

When this feature is turned on, transactions must be controlled using javax.transaction.UserTransaction, not e.g. using PM.currentTransaction().begin(). Should also work for SessionBeans, as per spec UserTransaction reflects SessionBean-based tx demarcation. Transaction TODO Merge functionality with JTAJCATransactionImpl when Joerg/Erik document what each are providing.


Field Summary
protected  int joinStatus
           
 
Fields inherited from class org.datanucleus.TransactionImpl
LOCALISER, nontransactionalRead, nontransactionalWrite, optimistic, restoreValues, retainValues, rollbackOnly
 
Method Summary
 void afterCompletion(int status)
          This method is called by the transaction manager after the transaction is committed or rolled back.
 void beforeCompletion()
          The beforeCompletion method is called by the transaction manager prior to the start of the two-phase transaction commit process.
 void begin()
          Method to begin the transaction.
protected  void checkTransactionJoin()
           
 void commit()
          Method to commit the transaction.
 boolean isActive()
          Accessor for whether the transaction is active.
 void rollback()
          Method to rollback the transaction.
 void setRollbackOnly()
          Mutator for the "rollback only" flag.
 
Methods inherited from class org.datanucleus.TransactionImpl
addTransactionEventListener, end, flush, getNontransactionalRead, getNontransactionalWrite, getOptimistic, getOptions, getRestoreValues, getRetainValues, getRollbackOnly, getSynchronization, internalBegin, internalCommit, internalPostCommit, internalPreCommit, internalPreRollback, internalRollback, isCommitting, removeTransactionEventListener, setNontransactionalRead, setNontransactionalWrite, setOptimistic, setOption, setOption, setOption, setRestoreValues, setRetainValues, setSynchronization
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

joinStatus

protected int joinStatus
Method Detail

checkTransactionJoin

protected void checkTransactionJoin()

isActive

public boolean isActive()
Accessor for whether the transaction is active.

Specified by:
isActive in interface Transaction
Overrides:
isActive in class TransactionImpl
Returns:
Whether the transaction is active.

begin

public void begin()
Description copied from class: TransactionImpl
Method to begin the transaction.

Specified by:
begin in interface Transaction
Overrides:
begin in class TransactionImpl

commit

public void commit()
Description copied from class: TransactionImpl
Method to commit the transaction.

Specified by:
commit in interface Transaction
Overrides:
commit in class TransactionImpl

rollback

public void rollback()
Description copied from class: TransactionImpl
Method to rollback the transaction.

Specified by:
rollback in interface Transaction
Overrides:
rollback in class TransactionImpl

setRollbackOnly

public void setRollbackOnly()
Description copied from class: TransactionImpl
Mutator for the "rollback only" flag. Sets the transaction as for rollback only.

Specified by:
setRollbackOnly in interface Transaction
Overrides:
setRollbackOnly in class TransactionImpl

beforeCompletion

public void beforeCompletion()
The beforeCompletion method is called by the transaction manager prior to the start of the two-phase transaction commit process. This is not called in JCA mode

Specified by:
beforeCompletion in interface javax.transaction.Synchronization

afterCompletion

public void afterCompletion(int status)
This method is called by the transaction manager after the transaction is committed or rolled back. Must be synchronized because some callees expect to be owner of this object's monitor (internalPostCommit() calls closeSQLConnection() which calls notifyAll()).

Specified by:
afterCompletion in interface javax.transaction.Synchronization
Parameters:
status - The status


Copyright © 2009. All Rights Reserved.