tyrex.tm.impl
final class TransactionImpl extends Object implements TyrexTransaction, Status
Synchronizations are called in the reverse order in which they are added.
Version: $Revision: 1.50 $ $Date: 2005/11/30 13:20:14 $
See Also: InternalXAResourceHolder TransactionManagerImpl TransactionDomain ResourceImpl
Field Summary | |
---|---|
protected int | _hashCode
The transaction hash code derived from the transaction identifier. |
protected int | _heuristic
The heuristic decision made by the transaction after a call to
TransactionImpl, TransactionImpl, TransactionImpl.
|
protected TransactionImpl | _nextEntry
The next entry in the hashtable maintained by TransactionDomain. |
protected TransactionImpl | _parent
If this transaction is a subtransaction of some global
transaction, this variable will reference the parent transaction.
|
protected long | _started
Indicates when the transaction started as system clock. |
protected int | _status
Holds the current status of the transaction. |
protected SystemException | _sysError
Held during a commit/rollback process to indicate that
an unexpected error occured. |
protected long | _timeout
Indicates when the transaction will timeout as system clock. |
protected TransactionDomainImpl | _txDomain
The domain to which this transaction belongs. |
protected BaseXid | _xid
The transaction identifier. |
Constructor Summary | |
---|---|
TransactionImpl(BaseXid xid, TransactionImpl parent, TransactionDomainImpl txDomain, long timeout)
Hidden constructor used by TransactionDomain to create
a new transaction. | |
TransactionImpl(BaseXid xid, PropagationContext pgContext, TransactionDomainImpl txDomain, long timeout)
Hidden constructor used by TransactionDomain to create
a new transaction. | |
TransactionImpl(BaseXid xid, int heuristic, TransactionDomainImpl txDomain)
Hidden constructor used by TransactionDomain to recreate
a transaction during recovery. |
Method Summary | |
---|---|
protected void | addRecovery(XAResource xaResource, Xid xid)
Called during recovery to add a resource. |
void | asyncCommit() |
void | asyncRollback() |
boolean | canUseOnePhaseCommit() |
void | commit() |
boolean | delistResource(XAResource xaResource, int flag) |
protected void | endResources()
Called to end the resources as part of the one phase commit protocol.
|
boolean | enlistResource(XAResource xaResource) |
boolean | enlistResource(XAResource xaResource, XAResourceCallback callback) |
boolean | equals(Object other) |
protected void | forget(int ignoreHeuristic)
Called to forget about the transaction at the end of either
a commit or rollback. |
Control | getControl() |
protected int | getHeuristic()
Returns the heuristic decision of this transaction after it
has been prepared, commited or rolledback. |
Transaction | getParent() |
protected PropagationContext | getPropagationContext()
Returns the propagation context used to import this
transaction or null if the transaction was not imported. |
long | getStarted() |
int | getStatus() |
protected boolean | getTimedOut()
Returns true if the transaction has timed out and rolled back. |
long | getTimeout() |
Transaction | getTopLevel() |
Xid | getXid() |
int | hashCode() |
protected void | internalCommit(boolean onePhaseCommit)
Performs the second part of the two phase commit, after a call
to TransactionImpl returned a heuristic decision to commit.
|
protected void | internalRollback()
Called to perform the actual rollback on the transaction.
|
protected void | internalSetTransactionTimeout(int seconds)
Called by TransactionDomain to change the timeout for
the transaction's resources to the new value. |
protected String[] | listResources()
Returns a listing of the resources associated with this
transaction. |
protected int | normalize(int heuristic)
Returns a normalized heuristic decision based on the supplied
non-normalized heuristic. |
void | onePhaseCommit() |
protected void | prepare()
Called to prepare the resource as part of the two phase commit protocol.
|
protected void | registerResource(Resource resource)
Called to register an OTS resource with the transaction. |
void | registerSynchronization(Synchronization sync) |
protected void | resumeAndEnlistResources(XAResourceHolder[] xaResourceHolders)
Resume previously suspended resources in the transaction and
enlist the new specified resources in the transaction.
|
void | rollback() |
void | setRollbackOnly() |
void | setTransactionTimeout(int seconds)
Change the timeout for the transaction's resources
to the new value.
|
protected void | suspendResources()
Suspend the resources associated with the transaction.
|
protected void | timedOut()
Indicates that the transaction has been rolled back due to time out.
|
String | toString() |
Parameters: xid The Xid for this transaction parent The parent of this transaction if this is a nested transaction, null if this is a top level transaction txDomain The transaction domain timeout The timeout for this transaction, in milliseconds
Parameters: xid The Xid for this transaction pgContext The propagation context txDomain The transaction domain timeout The timeout for this transaction, in milliseconds
Throws: Inactive The parent transaction has rolled back or is inactive
Parameters: xid The Xid for this transaction heuristic The recorded heuristic decision txDomain The transaction domain
Parameters: xaResource The XA resource xid The Xid for the transaction branch
) or ).
The heuristic decision can be any of the following:
All resources are ended successfully
need to be commited using one phase commit on the resources.
.ROLLBACK
The transaction has been marked for
rollback, an error has occured or at least one resource failed to
end
Throws: IllegalStateException The transaction is not active or is in the process of being commited, or prepared for two phase commit.
The ignoreHeuristic argument is used to determine what heuristic outcomes cause forget to be called on the resources associated with the transaction. For instance if transaction commit has been called and the outcome is Heuristic.COMMIT then resource forget should be not be called. In this case resource forget should be called on all other heuristic outcomes like Heuristic.ROLLBACK for instance. Similarly if transaction rollback has been called and the outcome is Heuristic.ROLLBACK then resource forget should not be called. In this case resource forget should be called on all other heuristic outcomes like Heuristic.COMMIT.
Forget always gets called if we are doing two-phase commit.
Parameters: ignoreHeuristic the heuristic to ignore
Throws: IllegalStateException The transaction has not commited or rolledback yet
See Also: HeuristicExceptions
.READONLY
.
Returns: The heuristic decision of this transaction
The heuristic decision can be any of the following:
.COMMIT
All resources were commited
successfuly
.ROLLBACK
No resources were commited
successfuly, all resources were rolledback successfuly
.MIXED
Some resources have commited,
others have rolled back
Parameters: onePhaseCommit True if one phase commit is to be used
Throws: IllegalStateException Transaction has not been prepared
The heuristic decision can be any of the following:
.READONLY
There were no resources for this
transaction, or all resources are read only -- there is no need to
commit/rollback this transaction
.COMMIT
All resources have decided to commit
.ROLLBACK
All resources have rolled back
(except for read-only resources)
.MIXED
Some resources have already commited,
others have rolled back
Throws: IllegalStateException The transaction is not active
Parameters: secods The new timeout in seconds
See Also: TransactionDomain#setTransactionTimeout
Returns: Array of description of all resources enlisted with this transaction
Parameters: heuristic A non-normalized heuristic decision
Returns: A normalized heuristic decision
) or ).
All enlisted resources are notified that the transaction has ended,
and are they asked to prepare it. If a resource succeeds we will commit
it (unless we decide to rollback the entire transaction). If a resource
is read-only (or shared) we will mark it as read-only. If at least one
resource fails to prepare, or any other error is encountered, we stop
preparation and return a heuristic decision.
The heuristic decision can be any of the following:
There were no resources for this
transaction, or all resources are read only -- there is no need to
commit/rollback this transaction
.COMMIT
All resources are prepared and those
with a false InternalXAResourceHolder need to be commited.
.ROLLBACK
The transaction has been marked for
rollback, an error has occured or at least one resource failed to
prepare and there were no resources that commited
.MIXED
Some resources have already commited,
others have either rolledback or failed to commit, or we got an
error in the process: all resources must be rolledback
Throws: IllegalStateException The transaction is not active or is in the process of being commited
Parameters: res The OTS resource to register
Active resources (ie non-suspended) are not affected.
Parameters: xaResources The resources to be enlisted in the transaction, may be bull
Parameters: seconds The new timeout in seconds
See Also: TransactionDomain#setTransactionTimeout
The resources that are already suspended are not affected.