Class AtomicTransaction

java.lang.Object
com.arjuna.ats.jts.extensions.AtomicTransaction
Direct Known Subclasses:
AtomicTransaction, TopLevelTransaction

public class AtomicTransaction extends 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 Details

    • TOP_LEVEL

      public static final int TOP_LEVEL
      The types of transactions which can be created.
      See Also:
    • NESTED

      public static final int NESTED
      See Also:
    • _theAction

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

      protected Status _theStatus
    • _timeout

      protected int _timeout
  • Constructor Details

    • 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 Details

    • finalize

      public void finalize()
      Overrides:
      finalize in class Object
    • get_transaction_name

      public 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 SubtransactionsUnavailable, org.omg.CORBA.SystemException
      Start the transaction.
      Throws:
      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 NoTransaction, HeuristicMixed, HeuristicHazard, org.omg.CORBA.WrongTransaction, org.omg.CORBA.SystemException
      Throws:
      NoTransaction
      HeuristicMixed
      HeuristicHazard
      org.omg.CORBA.WrongTransaction
      org.omg.CORBA.SystemException
    • rollback

      public void rollback() throws NoTransaction, org.omg.CORBA.WrongTransaction, org.omg.CORBA.SystemException
      Throws:
      NoTransaction
      org.omg.CORBA.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 PropagationContext get_txcontext() throws Inactive, org.omg.CORBA.SystemException
      Returns:
      the propagation context for this transaction.
      Throws:
      Inactive - if the current transaction is no longer in the active phase.
      org.omg.CORBA.SystemException
      Since:
      JTS 2.1.
    • registerResource

      public RecoveryCoordinator registerResource(Resource r) throws 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:
      Inactive - if the current transaction is no longer in the active phase.
      org.omg.CORBA.SystemException
    • registerSubtranAware

      public void registerSubtranAware(SubtransactionAwareResource r) throws Inactive, NotSubtransaction, org.omg.CORBA.SystemException
      Register the specified subtransaction aware resource with this transaction. This transaction must be a subtransaction.
      Throws:
      Inactive - if this transaction is no longer in the active phase.
      NotSubtransaction - if this transaction is not a subtransaction.
      org.omg.CORBA.SystemException
    • registerSynchronization

      public void registerSynchronization(Synchronization sync) throws Inactive, SynchronizationUnavailable, org.omg.CORBA.SystemException
      Register the specified synchronization with this transaction. This transaction must be a top-level transaction.
      Throws:
      Inactive - if this transaction is no longer in the active phase.
      SynchronizationUnavailable - if this transaction it not a top-level transaction.
      org.omg.CORBA.SystemException
    • control

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • suspend

      public void suspend() throws NoTransaction, org.omg.CORBA.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:
      NoTransaction - if there is no current transaction.
      org.omg.CORBA.WrongTransaction - if the transaction associated with the current thread is different from this thread.
      org.omg.CORBA.SystemException
    • resume

      public void resume() throws InvalidControl, org.omg.CORBA.SystemException
      Resume this transaction.
      Throws:
      InvalidControl - if this transaction is invalid.
      org.omg.CORBA.SystemException
    • get_status

      public 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, NoTransaction
      Allow action commit to be supressed. Although the OTS would require an InactiveException if the transaction is not active, we ignore that via this route.
      Throws:
      org.omg.CORBA.SystemException
      NoTransaction
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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 Status getStatus()