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 J�rg/Erik document what each are providing.


Field Summary
protected  org.datanucleus.JTATransactionImpl.JoinStatus joinStatus
           
 
Fields inherited from class org.datanucleus.TransactionImpl
LOCALISER, nontransactionalRead, nontransactionalWrite, optimistic, restoreValues, retainValues, rollbackOnly, serializeRead
 
Fields inherited from interface org.datanucleus.Transaction
TRANSACTION_ISOLATION_OPTION
 
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()
          "16.1.3 Stateless Session Bean with Bean Managed Transactions": "acquiring a PersistenceManager without beginning a UserTransaction results in the PersistenceManager being able to manage transaction boundaries via begin, commit, and rollback methods on javax.
protected  void checkTransactionJoin()
           
 void commit()
          Allow UserTransaction demarcation
 boolean isActive()
          Accessor for whether the transaction is active.
 void rollback()
          Allow UserTransaction demarcation
 void setRollbackOnly()
          Allow UserTransaction demarcation
 
Methods inherited from class org.datanucleus.TransactionImpl
addTransactionEventListener, end, flush, getNontransactionalRead, getNontransactionalWrite, getOptimistic, getOptions, getRestoreValues, getRetainValues, getRollbackOnly, getSerializeRead, getSynchronization, internalBegin, internalCommit, internalPostCommit, internalPreCommit, internalPreRollback, internalRollback, isCommitting, lockReadObjects, removeTransactionEventListener, setNontransactionalRead, setNontransactionalWrite, setOptimistic, setOption, setOption, setOption, setRestoreValues, setRetainValues, setSerializeRead, setSynchronization
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

joinStatus

protected org.datanucleus.JTATransactionImpl.JoinStatus joinStatus
Method Detail

checkTransactionJoin

protected void checkTransactionJoin()

isActive

public boolean isActive()
Accessor for whether the transaction is active. The UserTransaction is considered active if its status is anything other than Status.STATUS_NO_TRANSACTION, i.e. when the current thread is associated with a JTA transaction.

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

begin

public void begin()
"16.1.3 Stateless Session Bean with Bean Managed Transactions": "acquiring a PersistenceManager without beginning a UserTransaction results in the PersistenceManager being able to manage transaction boundaries via begin, commit, and rollback methods on javax. jdo.Transaction. The PersistenceManager will automatically begin the User- Transaction during javax.jdo.Transaction.begin and automatically commit the UserTransaction during javax.jdo.Transaction.commit"

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

commit

public void commit()
Allow UserTransaction demarcation

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

rollback

public void rollback()
Allow UserTransaction demarcation

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

setRollbackOnly

public void setRollbackOnly()
Allow UserTransaction demarcation

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 © 2010. All Rights Reserved.