Framework Professional Edition Package


org.mbs.services.transaction
Interface TransactionContext

All Known Subinterfaces:
Transaction

public interface TransactionContext

The TransactionContext provides methods, that allows the Transaction Resources to join and participate in the current transaction. It also prevents them from performing full commit or rollback.

Author:
Valentin Valchev

Field Summary
static int STATUS_ACTIVE
          Directly after it is created the status is ACTIVE.
static int STATUS_COMMITTED
          After the transaction is ended and has ended successfully.
static int STATUS_COMMITTING
          During the second phase
static int STATUS_MARKED_ROLLBACK
          Any participant of the transaction can mark the transaction setRollbackOnly.
static int STATUS_NO_TRANSACTION
          No transaction is currently associated with the target object.
static int STATUS_PREPARED
          After the first phase of 2-phase commit, just before STATUS_COMMITTING
static int STATUS_PREPARING
          During the first phase of the 2-phase commit.
static int STATUS_ROLLEDBACK
          After the transaction is rolled back.
static int STATUS_ROLLING_BACK
          During the roll back phase.
static int STATUS_UNKNOWN
          A transaction is associated with the target object but its current status cannot be determined.
 
Method Summary
 boolean associateThread(java.lang.Thread thread)
          This method allows a resource to associate the current transaction to another thread.
 boolean disassociateThread()
          This method disassociates the current thread from the transaction.
 long getPid()
          This method is used to query the PID of the transaction.
 int getStatus()
          Obtain the status of the transaction associated with the current thread.
 boolean join(TransactionResource tr)
          A resource manager that wants to participate in the transaction should register with this transaction through this method.
 void resetTimeout()
          This method will reset the timeout.
 void setRollbackOnly()
          Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.
 boolean waitThreadsToFinish(int timeout)
          This method waits all threads except one to disassociate from the transaction.
 

Field Detail

STATUS_UNKNOWN

static final int STATUS_UNKNOWN
A transaction is associated with the target object but its current status cannot be determined. This is a transient condition and a subsequent invocation will ultimately return a different status.

See Also:
Constant Field Values

STATUS_ACTIVE

static final int STATUS_ACTIVE
Directly after it is created the status is ACTIVE.

See Also:
Constant Field Values

STATUS_COMMITTING

static final int STATUS_COMMITTING
During the second phase

See Also:
Constant Field Values

STATUS_COMMITTED

static final int STATUS_COMMITTED
After the transaction is ended and has ended successfully.

See Also:
Constant Field Values

STATUS_MARKED_ROLLBACK

static final int STATUS_MARKED_ROLLBACK
Any participant of the transaction can mark the transaction setRollbackOnly. Once this is set, the transaction may continue but a final commit will become a roll-back. The setRollbackOnly method will set the status to STATUS_MARKED_ROLLBACK.

See Also:
Constant Field Values

STATUS_NO_TRANSACTION

static final int STATUS_NO_TRANSACTION
No transaction is currently associated with the target object. This will occur after a transaction has completed.

See Also:
Constant Field Values

STATUS_PREPARED

static final int STATUS_PREPARED
After the first phase of 2-phase commit, just before STATUS_COMMITTING

See Also:
Constant Field Values

STATUS_PREPARING

static final int STATUS_PREPARING
During the first phase of the 2-phase commit.

See Also:
Constant Field Values

STATUS_ROLLEDBACK

static final int STATUS_ROLLEDBACK
After the transaction is rolled back. This is a final state, no more changes are possible.

See Also:
Constant Field Values

STATUS_ROLLING_BACK

static final int STATUS_ROLLING_BACK
During the roll back phase.

See Also:
Constant Field Values
Method Detail

getStatus

int getStatus()
Obtain the status of the transaction associated with the current thread.

Returns:
the status of the transaction

setRollbackOnly

void setRollbackOnly()
Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.


join

boolean join(TransactionResource tr)
A resource manager that wants to participate in the transaction should register with this transaction through this method.

Parameters:
tr - The associated transaction resource manager
Returns:
true if this is the first time, or false if it is already registered

resetTimeout

void resetTimeout()
This method will reset the timeout. This is a little bit like a watch-dog, that will prevent transactions from being locked. The creator of the transaction sets the maximum timeout, allowed for a step to execute. When step is executed, it resets the timeout.


getPid

long getPid()
This method is used to query the PID of the transaction.

Returns:
the transaction PID.

associateThread

boolean associateThread(java.lang.Thread thread)
                        throws TransactionException
This method allows a resource to associate the current transaction to another thread. Notice, that this will not unbind the transaction from the current tread.

Parameters:
thread - the thread, to which the transaction should be associated.
Returns:
true if association is succesfull or false if the target thread, already has an associated transaction.
Throws:
TransactionException - If the transaction is not in the active state

disassociateThread

boolean disassociateThread()
This method disassociates the current thread from the transaction.

Returns:
true if the thread was associated to the transaction, false - if not.

waitThreadsToFinish

boolean waitThreadsToFinish(int timeout)
This method waits all threads except one to disassociate from the transaction.

Parameters:
timeout - the timeout within the threads must disassociate in milliseconds.
Returns:
true if the threads disassociated within the given timeout, false - if not.

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved