com.arjuna.ats.jts.extensions
Class AtomicTransaction

java.lang.Object
  extended bycom.arjuna.ats.jts.extensions.AtomicTransaction
Direct Known Subclasses:
TopLevelTransaction

public class AtomicTransaction
extends java.lang.Object

Similar to CosTransactions::Current. However, this class does transaction scoping, so if an instance is garbage collected and the transaction is still running, it will be rolled back automatically. It also adds some convenience routines which Current does not do.

Since:
JTS 1.0.
Version:
$Id: AtomicTransaction.java 2342 2006-03-30 13:06:17Z $
Author:
Mark Little (mark_little@hp.com)

Field Summary
protected  com.arjuna.ats.internal.jts.ControlWrapper _theAction
           
protected  org.omg.CosTransactions.Status _theStatus
           
protected  int _timeout
           
static int NESTED
           
static int TOP_LEVEL
          The types of transactions which can be created.
 
Constructor Summary
  AtomicTransaction()
          Create a new transaction.
protected AtomicTransaction(com.arjuna.ats.internal.jts.ControlWrapper tx)
           
 
Method Summary
 void begin()
          Start the transaction.
 void commit(boolean report_heuristics)
           
 org.omg.CosTransactions.Control control()
           
 boolean equals(java.lang.Object obj)
           
 void finalize()
           
 org.omg.CosTransactions.Status get_status()
           
 int get_timeout()
           
 java.lang.String get_transaction_name()
           
 org.omg.CosTransactions.PropagationContext get_txcontext()
           
 Uid get_uid()
           
protected  org.omg.CosTransactions.Status getStatus()
           
 int getTimeout()
           
 int hashCode()
           
 org.omg.CosTransactions.RecoveryCoordinator registerResource(org.omg.CosTransactions.Resource r)
          Register the specified resource with this transaction.
 void registerSubtranAware(org.omg.CosTransactions.SubtransactionAwareResource r)
          Register the specified subtransaction aware resource with this transaction.
 void registerSynchronization(org.omg.CosTransactions.Synchronization sync)
          Register the specified synchronization with this transaction.
 void resume()
          Resume this transaction.
 void rollback()
           
 void rollbackOnly()
          Allow action commit to be supressed.
 void set_timeout(int seconds)
          Set the transaction timeout.
 void suspend()
          Suspend this transaction from the current thread.
protected  boolean validTransaction()
          If this transaction current? Assume we have checked that we are actually a transaction! If not valid then abort this transaction here.
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOP_LEVEL

public static final int TOP_LEVEL
The types of transactions which can be created.

See Also:
Constant Field Values

NESTED

public static final int NESTED
See Also:
Constant Field Values

_theAction

protected com.arjuna.ats.internal.jts.ControlWrapper _theAction

_theStatus

protected org.omg.CosTransactions.Status _theStatus

_timeout

protected int _timeout
Constructor Detail

AtomicTransaction

public AtomicTransaction()
Create a new transaction. It is not running at this stage.


AtomicTransaction

protected AtomicTransaction(com.arjuna.ats.internal.jts.ControlWrapper tx)
Method Detail

finalize

public void finalize()

get_transaction_name

public java.lang.String get_transaction_name()
                                      throws org.omg.CORBA.SystemException
Returns:
the transaction name. Should only be used for debugging purposes.
Throws:
org.omg.CORBA.SystemException

begin

public void begin()
           throws org.omg.CosTransactions.SubtransactionsUnavailable,
                  org.omg.CORBA.SystemException
Start the transaction.

Throws:
org.omg.CosTransactions.SubtransactionsUnavailable - if subtransactions have been disabled, and the invoking thread already has a transaction associated with it.
org.omg.CORBA.INVALID_TRANSACTION - if the transaction has already begun or has completed.
org.omg.CORBA.SystemException

commit

public void commit(boolean report_heuristics)
            throws org.omg.CosTransactions.NoTransaction,
                   org.omg.CosTransactions.HeuristicMixed,
                   org.omg.CosTransactions.HeuristicHazard,
                   org.omg.CosTransactions.WrongTransaction,
                   org.omg.CORBA.SystemException
Throws:
org.omg.CosTransactions.NoTransaction
org.omg.CosTransactions.HeuristicMixed
org.omg.CosTransactions.HeuristicHazard
org.omg.CosTransactions.WrongTransaction
org.omg.CORBA.SystemException

rollback

public void rollback()
              throws org.omg.CosTransactions.NoTransaction,
                     org.omg.CosTransactions.WrongTransaction,
                     org.omg.CORBA.SystemException
Throws:
org.omg.CosTransactions.NoTransaction
org.omg.CosTransactions.WrongTransaction
org.omg.CORBA.SystemException

set_timeout

public void set_timeout(int seconds)
                 throws org.omg.CORBA.SystemException
Set the transaction timeout. This is the same as calling org.omg.CosTransactions.Current.set_timeout().

Throws:
org.omg.CORBA.SystemException

get_timeout

public int get_timeout()
                throws org.omg.CORBA.SystemException
Returns:
the timeout associated with transactions created by the current thread.
Throws:
org.omg.CORBA.SystemException

getTimeout

public int getTimeout()
               throws org.omg.CORBA.SystemException
Returns:
the timeout associated with this transaction.
Throws:
org.omg.CORBA.SystemException

get_txcontext

public org.omg.CosTransactions.PropagationContext get_txcontext()
                                                         throws org.omg.CosTransactions.Inactive,
                                                                org.omg.CORBA.SystemException
Returns:
the propagation context for this transaction.
Throws:
org.omg.CosTransactions.Inactive - if the current transaction is no longer in the active phase.
org.omg.CORBA.SystemException
Since:
JTS 2.1.

registerResource

public org.omg.CosTransactions.RecoveryCoordinator registerResource(org.omg.CosTransactions.Resource r)
                                                             throws org.omg.CosTransactions.Inactive,
                                                                    org.omg.CORBA.SystemException
Register the specified resource with this transaction.

Returns:
the org.omg.CosTransactions.RecoveryCoordinator reference that can be used to later query the outcome of the transaction.
Throws:
org.omg.CosTransactions.Inactive - if the current transaction is no longer in the active phase.
org.omg.CORBA.SystemException

registerSubtranAware

public void registerSubtranAware(org.omg.CosTransactions.SubtransactionAwareResource r)
                          throws org.omg.CosTransactions.Inactive,
                                 org.omg.CosTransactions.NotSubtransaction,
                                 org.omg.CORBA.SystemException
Register the specified subtransaction aware resource with this transaction. This transaction must be a subtransaction.

Throws:
org.omg.CosTransactions.Inactive - if this transaction is no longer in the active phase.
org.omg.CosTransactions.NotSubtransaction - if this transaction is not a subtransaction.
org.omg.CORBA.SystemException

registerSynchronization

public void registerSynchronization(org.omg.CosTransactions.Synchronization sync)
                             throws org.omg.CosTransactions.Inactive,
                                    org.omg.CosTransactions.SynchronizationUnavailable,
                                    org.omg.CORBA.SystemException
Register the specified synchronization with this transaction. This transaction must be a top-level transaction.

Throws:
org.omg.CosTransactions.Inactive - if this transaction is no longer in the active phase.
org.omg.CosTransactions.SynchronizationUnavailable - if this transaction it not a top-level transaction.
org.omg.CORBA.SystemException

control

public org.omg.CosTransactions.Control control()
                                        throws org.omg.CosTransactions.NoTransaction,
                                               org.omg.CORBA.SystemException
Returns:
the org.omg.CosTransactions.Control reference to this transaction.
Throws:
org.omg.CosTransactions.NoTransaction
org.omg.CORBA.SystemException

equals

public boolean equals(java.lang.Object obj)

suspend

public void suspend()
             throws org.omg.CosTransactions.NoTransaction,
                    org.omg.CosTransactions.WrongTransaction,
                    org.omg.CORBA.SystemException
Suspend this transaction from the current thread. This transaction must be active on the calling thread for this method to succeed.

Throws:
org.omg.CosTransactions.NoTransaction - if there is no current transaction.
org.omg.CORBA.WRONG_TRANSACTION - if the transaction associated with the current thread is different from this thread.
org.omg.CosTransactions.WrongTransaction
org.omg.CORBA.SystemException

resume

public void resume()
            throws org.omg.CosTransactions.InvalidControl,
                   org.omg.CORBA.SystemException
Resume this transaction.

Throws:
org.omg.CosTransactions.InvalidControl - if this transaction is invalid.
org.omg.CORBA.SystemException

get_status

public org.omg.CosTransactions.Status get_status()
                                          throws org.omg.CORBA.SystemException
Returns:
the status of this transaction.
Throws:
org.omg.CORBA.SystemException

rollbackOnly

public void rollbackOnly()
                  throws org.omg.CORBA.SystemException,
                         org.omg.CosTransactions.NoTransaction
Allow action commit to be supressed.

Throws:
org.omg.CORBA.SystemException
org.omg.CosTransactions.NoTransaction

hashCode

public int hashCode()

get_uid

public Uid get_uid()

validTransaction

protected final boolean validTransaction()
If this transaction current? Assume we have checked that we are actually a transaction! If not valid then abort this transaction here. Leave current alone.


getStatus

protected final org.omg.CosTransactions.Status getStatus()