Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.arjuna.ats.arjuna
Class AtomicAction

    java.lang.Object
      com.arjuna.ats.arjuna.StateManager
          com.arjuna.ats.arjuna.coordinator.BasicAction
              com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator
                  com.arjuna.ats.arjuna.AtomicAction

All Implemented Interfaces:
  Reapable

Direct Known Subclasses:
  RecoverAtomicAction, TopLevelAction

public class AtomicAction
extends TwoPhaseCoordinator

This is a user-level transaction class, unlike BasicAction. AtomicAction takes care of thread-to-action scoping. This is a "one-shot" object, i.e., once terminated, the instance cannot be re-used for another transaction. An instance of this class is a transaction that can be started and terminated (either committed or rolled back). There are also methods to allow participants (AbstractRecords) to be enlisted with the transaction and to associate/disassociate threads with the transaction.

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

Field Summary
`static int` | `NO_TIMEOUT`

Fields inherited from class com.arjuna.ats.arjuna.coordinator.BasicAction
`failedList, heuristicList, pendingList, preparedList, readonlyList, savedIntentionList`

Fields inherited from class com.arjuna.ats.arjuna.StateManager
`modifyingActions, objectName, objectUid, smAttributes, usingActions`

Constructor Summary
`` | `AtomicAction()` Create a new transaction.
`protected` | `AtomicAction(int at)` Create a new transaction of the specified type.
`` | `AtomicAction(Uid objUid)` AtomicAction constructor with a Uid.

Method Summary
`int` | `abort()` Abort (rollback) the transaction.
`boolean` | `addThread()` Register the current thread with the transaction.
`boolean` | `addThread(java.lang.Thread t)` Register the specified thread with the transaction.
`int` | `begin()` Start the transaction running.
`int` | `begin(int timeout)` Start the transaction running.
`protected boolean` | `checkForCurrent()` By default the BasicAction class only allows the termination of a transaction if it's the one currently associated with the thread.
`int` | `commit()` Commit the transaction, and have heuristic reporting.
`int` | `commit(boolean report_heuristics)` Commit the transaction.
`void` | `finalize()` AtomicAction destructor.
`int` | `getTimeout()`
`boolean` | `removeThread()` Unregister the current thread from the transaction.
`boolean` | `removeThread(java.lang.Thread t)` Unregister the specified thread from the transaction.
`static boolean` | `resume(AtomicAction act)` Resume transaction association on the current thread.
`static AtomicAction` | `suspend()` Suspend all transaction association from the invoking thread.
`java.lang.String` | `type()` The type of the class is used to locate the state of the transaction log in the object store.

Methods inherited from class com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator
`addSynchronization, afterCompletion, beforeCompletion, cancel, end, running, start, start`

Methods inherited from class com.arjuna.ats.arjuna.coordinator.BasicAction
`Abort, abortStatus, activate, activate, activeThreads, add, addChildAction, addChildThread, addChildThread, addRecord, Begin, childTransactions, commitStatus, criticalEnd, criticalStart, Current, deactivate, destroy, doAbort, doAbort, doCommit, doCommit, doPrepare, doPrepare, End, equals, forgetHeuristics, getHeuristicDecision, getHierarchy, getSavingUid, getStore, hierarchyDepth, insertRecord, isAncestor, maintainHeuristics, onePhaseCommit, parent, phase2Abort, phase2Cleanup, phase2Commit, prepare, preparedStatus, preventCommit, removeChildAction, removeChildThread, removeChildThread, restore_state, save_state, setCheckedAction, status, store, topLevelAction, topLevelActionUid, toString, typeOfAction, updateHeuristic, updateState`

Methods inherited from class com.arjuna.ats.arjuna.StateManager
`attributes, cleanup, deactivate, deactivate, disable, forgetAction, get_uid, getMutex, getStoreRoot, loadObjectState, lockMutex, modified, ObjectType, packHeader, persist, print, rememberAction, setStatus, setupStore, setupStore, terminate, tryLockMutex, unlockMutex, unpackHeader`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.arjuna.ats.arjuna.coordinator.Reapable
`get_uid, preventCommit`

Field Detail

### NO_TIMEOUT

    public static final int NO_TIMEOUT

See Also:
  Constant Field Values

Constructor Detail

### AtomicAction

    public AtomicAction()

  Create a new transaction. If there is already a transaction associated with the thread then this new transaction will be automatically nested. The transaction is *not* running at this point. No timeout is associated with this transaction, i.e., it will not be automatically rolled back by the system.

### AtomicAction

    public AtomicAction(Uid objUid)

  AtomicAction constructor with a Uid. This constructor is for recreating an AtomicAction, typically during crash recovery.

### AtomicAction

    protected AtomicAction(int at)

  Create a new transaction of the specified type.

Method Detail

### finalize

    public void finalize()

  AtomicAction destructor. Under normal circumstances we do very little. However there exists the possibility that this action is being deleted while still running (user forgot to commit/abort) - in which case we do an abort for him and mark all our parents as unable to commit. Additionally due to scoping we may not be the current action - but in that case the current action must be one of our nested actions so by applying abort to it we should end up at ourselves!

  Overrides:
    `finalize` in class `BasicAction`

### begin

    public int begin()

  Start the transaction running. If the transaction is already running or has terminated, then an error code will be returned. No timeout is associated with the transaction.

  Returns:
    `ActionStatus` indicating outcome.

### begin

    public int begin(int timeout)

  Start the transaction running. If the transaction is already running or has terminated, then an error code will be returned.

  Returns:
    `ActionStatus` indicating outcome.

### commit

    public int commit()

  Commit the transaction, and have heuristic reporting. Heuristic reporting via the return code is enabled.

  Returns:
    `ActionStatus` indicating outcome.

### commit

    public int commit(boolean report_heuristics)

  Commit the transaction. The report_heuristics parameter can be used to determine whether or not heuristic outcomes are reported. If the transaction has already terminated, or has not begun, then an appropriate error code will be returned.

  Returns:
    `ActionStatus` indicating outcome.

### abort

    public int abort()

  Abort (rollback) the transaction. If the transaction has already terminated, or has not been begun, then an appropriate error code will be returned.

  Returns:
    `ActionStatus` indicating outcome.

### getTimeout

    public final int getTimeout()

### type

    public java.lang.String type()

  The type of the class is used to locate the state of the transaction log in the object store. Overloads BasicAction.type()

  Overrides:
    `type` in class `TwoPhaseCoordinator`
  Returns:
    a string representation of the hierarchy of the class for storing logs in the transaction object store.

### addThread

    public boolean addThread()

  Register the current thread with the transaction. This operation is not affected by the state of the transaction.

  Returns:
    `true` if successful, `false` otherwise.

### addThread

    public boolean addThread(java.lang.Thread t)

  Register the specified thread with the transaction. This operation is not affected by the state of the transaction.

  Returns:
    `true` if successful, `false` otherwise.

### removeThread

    public boolean removeThread()

  Unregister the current thread from the transaction. This operation is not affected by the state of the transaction.

  Returns:
    `true` if successful, `false` otherwise.

### removeThread

    public boolean removeThread(java.lang.Thread t)

  Unregister the specified thread from the transaction. This operation is not affected by the state of the transaction.

  Returns:
    `true` if successful, `false` otherwise.

### suspend

    public static final AtomicAction suspend()

  Suspend all transaction association from the invoking thread. When this operation returns, the thread will be associated with no transactions. If the current transaction is not an AtomicAction then this method will not suspend.

  Returns:
    a handle on the current AtomicAction (if any) so that the thread can later resume association if required. message com.arjuna.ats.atomicaction_1 Attempt to suspend a non-AtomicAction transaction. Type is {0}

### resume

    public static final boolean resume(AtomicAction act)

  Resume transaction association on the current thread. If the specified transaction is null, then this is the same as doing a suspend. If the current thread is associated with transactions then those associations will be lost.

  Returns:
    `true` if association is successful, `false` otherwise.

### checkForCurrent

    protected boolean checkForCurrent()

  By default the BasicAction class only allows the termination of a transaction if it's the one currently associated with the thread. We override this here.

  Overrides:
    `checkForCurrent` in class `BasicAction`
  Returns:
    `true` to indicate that this transaction can only be terminated by the right thread.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD