|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tyrex.tm.impl.TransactionImpl
Implements a global transaction. This transaction supports X/A
resources (see XAResource
), can be part of an OTS global
transaction (see ResourceImpl
) and can contain OTS
subtransactions (see Resource
). Tightly integrated with
TransactionManagerImpl
and TransactionServer
.
Synchronizations are called in the reverse order in which they are added.
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 prepare() , internalCommit(boolean) , internalRollback() . |
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 javax.transaction.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. |
Fields inherited from interface javax.transaction.Status |
STATUS_ACTIVE, STATUS_COMMITTED, STATUS_COMMITTING, STATUS_MARKED_ROLLBACK, STATUS_NO_TRANSACTION, STATUS_PREPARED, STATUS_PREPARING, STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, STATUS_UNKNOWN |
Constructor Summary | |
(package private) |
TransactionImpl(BaseXid xid,
int heuristic,
TransactionDomainImpl txDomain)
Hidden constructor used by TransactionDomain to recreate
a transaction during recovery. |
(package private) |
TransactionImpl(BaseXid xid,
org.omg.CosTransactions.PropagationContext pgContext,
TransactionDomainImpl txDomain,
long timeout)
Hidden constructor used by TransactionDomain to create
a new transaction. |
(package private) |
TransactionImpl(BaseXid xid,
TransactionImpl parent,
TransactionDomainImpl txDomain,
long timeout)
Hidden constructor used by TransactionDomain to create
a new transaction. |
Method Summary | |
protected void |
addRecovery(javax.transaction.xa.XAResource xaResource,
javax.transaction.xa.Xid xid)
Called during recovery to add a resource. |
void |
asyncCommit()
Perform an asynchronous commit on the transaction. |
void |
asyncRollback()
Perform an asynchronous rollback on the transaction. |
boolean |
canUseOnePhaseCommit()
Return true if the transaction can be safely committed using one-phase commit. |
void |
commit()
|
boolean |
delistResource(javax.transaction.xa.XAResource xaResource,
int flag)
|
protected void |
endResources()
Called to end the resources as part of the one phase commit protocol. |
boolean |
enlistResource(javax.transaction.xa.XAResource xaResource)
|
(package private) boolean |
enlistResource(javax.transaction.xa.XAResource xaResource,
XAResourceCallback callback)
|
boolean |
equals(java.lang.Object other)
|
protected void |
forget(int ignoreHeuristic)
Called to forget about the transaction at the end of either a commit or rollback. |
org.omg.CosTransactions.Control |
getControl()
Returns the control interface of the underlying transaction. |
protected int |
getHeuristic()
Returns the heuristic decision of this transaction after it has been prepared, commited or rolledback. |
javax.transaction.Transaction |
getParent()
Returns the parent of this transaction. |
protected org.omg.CosTransactions.PropagationContext |
getPropagationContext()
Returns the propagation context used to import this transaction or null if the transaction was not imported. |
long |
getStarted()
Returns the start time of the tranasction. |
int |
getStatus()
|
protected boolean |
getTimedOut()
Returns true if the transaction has timed out and rolled back. |
long |
getTimeout()
Returns the timeout for the tranasction. |
javax.transaction.Transaction |
getTopLevel()
Returns the top level parent of this transaction, or this transaction if this is a top level transaction. |
javax.transaction.xa.Xid |
getXid()
Returns the Xid of the transaction. |
int |
hashCode()
|
protected void |
internalCommit(boolean onePhaseCommit)
Performs the second part of the two phase commit, after a call to prepare() 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 java.lang.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()
Perform one-phase commit on the transaction. |
protected void |
prepare()
Called to prepare the resource as part of the two phase commit protocol. |
protected void |
registerResource(org.omg.CosTransactions.Resource resource)
Called to register an OTS resource with the transaction. |
void |
registerSynchronization(javax.transaction.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. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected final BaseXid _xid
BaseXid
.
protected final int _hashCode
protected int _status
protected javax.transaction.SystemException _sysError
protected int _heuristic
prepare()
, internalCommit(boolean)
, internalRollback()
.
Held in case the operation is repeated to return a consistent
heuristic decision. Defaults to read-only (i.e. no heuristic decision).
protected final TransactionDomainImpl _txDomain
protected final TransactionImpl _parent
protected long _timeout
protected final long _started
protected TransactionImpl _nextEntry
TransactionDomain
.
Constructor Detail |
TransactionImpl(BaseXid xid, TransactionImpl parent, TransactionDomainImpl txDomain, long timeout)
TransactionDomain
to create
a new transaction. A transaction can only be created through
TransactionDomain
or TransactionManager
which
take care of several necessary housekeeping duties.
xid
- The Xid for this transactionparent
- The parent of this transaction if this is a
nested transaction, null if this is a top level transactiontxDomain
- The transaction domaintimeout
- The timeout for this transaction, in millisecondsTransactionImpl(BaseXid xid, org.omg.CosTransactions.PropagationContext pgContext, TransactionDomainImpl txDomain, long timeout) throws org.omg.CosTransactions.Inactive
TransactionDomain
to create
a new transaction. A transaction can only be created through
TransactionDomain
or TransactionManager
which
take care of several necessary housekeeping duties. This
transaction is created to import an OTS transaction using
the propagation context.
xid
- The Xid for this transactionpgContext
- The propagation contexttxDomain
- The transaction domaintimeout
- The timeout for this transaction, in milliseconds
org.omg.CosTransactions.Inactive
- The parent transaction has rolled back or
is inactiveTransactionImpl(BaseXid xid, int heuristic, TransactionDomainImpl txDomain)
TransactionDomain
to recreate
a transaction during recovery. The transaction state and heuristic
decision are restored from information available in the recovery log.
xid
- The Xid for this transactionheuristic
- The recorded heuristic decisiontxDomain
- The transaction domainMethod Detail |
public java.lang.String toString()
public int hashCode()
public boolean equals(java.lang.Object other)
public int getStatus()
getStatus
in interface javax.transaction.Transaction
public void registerSynchronization(javax.transaction.Synchronization sync) throws javax.transaction.RollbackException, java.lang.IllegalStateException, javax.transaction.SystemException
registerSynchronization
in interface javax.transaction.Transaction
javax.transaction.RollbackException
java.lang.IllegalStateException
javax.transaction.SystemException
public void commit() throws javax.transaction.RollbackException, javax.transaction.HeuristicMixedException, javax.transaction.HeuristicRollbackException, java.lang.SecurityException, javax.transaction.SystemException
commit
in interface javax.transaction.Transaction
javax.transaction.RollbackException
javax.transaction.HeuristicMixedException
javax.transaction.HeuristicRollbackException
java.lang.SecurityException
javax.transaction.SystemException
public void rollback() throws java.lang.IllegalStateException, javax.transaction.SystemException
rollback
in interface javax.transaction.Transaction
java.lang.IllegalStateException
javax.transaction.SystemException
public boolean enlistResource(javax.transaction.xa.XAResource xaResource) throws java.lang.IllegalStateException, javax.transaction.SystemException, javax.transaction.RollbackException
enlistResource
in interface javax.transaction.Transaction
java.lang.IllegalStateException
javax.transaction.SystemException
javax.transaction.RollbackException
boolean enlistResource(javax.transaction.xa.XAResource xaResource, XAResourceCallback callback) throws java.lang.IllegalStateException, javax.transaction.SystemException, javax.transaction.RollbackException
java.lang.IllegalStateException
javax.transaction.SystemException
javax.transaction.RollbackException
public boolean delistResource(javax.transaction.xa.XAResource xaResource, int flag) throws java.lang.IllegalStateException, javax.transaction.SystemException
delistResource
in interface javax.transaction.Transaction
java.lang.IllegalStateException
javax.transaction.SystemException
public void setRollbackOnly() throws java.lang.IllegalStateException, javax.transaction.SystemException
setRollbackOnly
in interface javax.transaction.Transaction
java.lang.IllegalStateException
javax.transaction.SystemException
public void setTransactionTimeout(int seconds)
setTransactionTimeout
in interface TyrexTransaction
seconds
- The new timeout in secondsTransactionDomain#setTransactionTimeout
public void asyncCommit() throws javax.transaction.SystemException, java.lang.SecurityException, javax.transaction.RollbackException
TyrexTransaction
asyncCommit
in interface TyrexTransaction
java.lang.SecurityException
- The current thread is not allowed to
rollback the transaction
javax.transaction.SystemException
- A problem occured while associating the
transaction with the new thread.
javax.transaction.RollbackException
- The transaction has been marked for rollbackpublic void asyncRollback() throws java.lang.IllegalStateException, javax.transaction.SystemException, java.lang.SecurityException
TyrexTransaction
asyncRollback
in interface TyrexTransaction
java.lang.SecurityException
- The current thread is not allowed to
rollback the transaction.
java.lang.IllegalStateException
- The transaction is not in the proper
state to be rolled back
javax.transaction.SystemException
- A problem occured while associating the
transaction with the new thread.public boolean canUseOnePhaseCommit()
TyrexTransaction
canUseOnePhaseCommit
in interface TyrexTransaction
public void onePhaseCommit() throws javax.transaction.RollbackException, javax.transaction.HeuristicMixedException, javax.transaction.HeuristicRollbackException, java.lang.SecurityException, java.lang.IllegalStateException, javax.transaction.SystemException
TyrexTransaction
onePhaseCommit
in interface TyrexTransaction
java.lang.IllegalStateException
- The current thread is not associated
with a transaction.
javax.transaction.HeuristicRollbackException
- A heuristic decision was made
and that some relevant updates have been rolled back.
javax.transaction.HeuristicMixedException
- A heuristic decision was made and
that some relevant updates have been committed while others have
been rolled back.
javax.transaction.SystemException
- The transaction manager encountered an
unexpected error condition
java.lang.SecurityException
- The thread is not allowed to commit the
transaction.
javax.transaction.RollbackException
- Indicates that the transaction has been
rolled back rather than committed.public javax.transaction.Transaction getParent()
TyrexTransaction
getParent
in interface TyrexTransaction
public javax.transaction.Transaction getTopLevel()
TyrexTransaction
getTopLevel
in interface TyrexTransaction
public long getTimeout()
TyrexTransaction
getTimeout
in interface TyrexTransaction
public long getStarted()
TyrexTransaction
getStarted
in interface TyrexTransaction
public javax.transaction.xa.Xid getXid()
TyrexTransaction
getXid
in interface TyrexTransaction
public org.omg.CosTransactions.Control getControl()
TyrexTransaction
getControl
in interface TyrexTransaction
protected void prepare() throws java.lang.IllegalStateException, javax.transaction.RollbackException
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:
java.lang.IllegalStateException
- The transaction is not active or
is in the process of being commited
javax.transaction.RollbackException
protected void internalCommit(boolean onePhaseCommit) throws java.lang.IllegalStateException
prepare()
returned a heuristic decision to commit.
Will attempt to commit on all the resources that are not read-only.
The end result is described in a heuristic decision. Multiple
calls are supported.
The heuristic decision can be any of the following:
#Heuristic.COMMIT
All resources were commited
successfuly
#Heuristic.ROLLBACK
No resources were commited
successfuly, all resources were rolledback successfuly
#Heuristic.MIXED
Some resources have commited,
others have rolled back
onePhaseCommit
- True if one phase commit is to be used
java.lang.IllegalStateException
- Transaction has not been preparedprotected void internalRollback()
The heuristic decision can be any of the following:
#Heuristic.READONLY
There were no resources for this
transaction, or all resources are read only -- there is no need to
commit/rollback this transaction
#Heuristic.COMMIT
All resources have decided to commit
#Heuristic.ROLLBACK
All resources have rolled back
(except for read-only resources)
#Heuristic.MIXED
Some resources have already commited,
others have rolled back
java.lang.IllegalStateException
- The transaction is not activeprotected void suspendResources() throws java.lang.IllegalStateException, javax.transaction.SystemException
The resources that are already suspended are not affected.
java.lang.IllegalStateException
javax.transaction.SystemException
protected void resumeAndEnlistResources(XAResourceHolder[] xaResourceHolders) throws java.lang.IllegalStateException, javax.transaction.SystemException, javax.transaction.RollbackException
Active resources (ie non-suspended) are not affected.
java.lang.IllegalStateException
javax.transaction.SystemException
javax.transaction.RollbackException
protected void registerResource(org.omg.CosTransactions.Resource resource) throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected int normalize(int heuristic)
heuristic
- A non-normalized heuristic decision
protected int getHeuristic()
#Heuristic.READONLY
.
protected void internalSetTransactionTimeout(int seconds)
TransactionDomain
to change the timeout for
the transaction's resources to the new value. This might or
might not have an effect on the underlying resources.
All consistency checks are made by the server.
TransactionDomain#setTransactionTimeout
protected void timedOut()
protected boolean getTimedOut()
protected org.omg.CosTransactions.PropagationContext getPropagationContext()
protected java.lang.String[] listResources()
protected void endResources() throws java.lang.IllegalStateException, javax.transaction.RollbackException
The heuristic decision can be any of the following:
java.lang.IllegalStateException
- The transaction is not active or
is in the process of being commited, or prepared for two phase commit.
javax.transaction.RollbackException
protected void forget(int ignoreHeuristic) throws java.lang.IllegalStateException
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.
ignoreHeuristic
- the heuristic to ignore
java.lang.IllegalStateException
- The transaction has not commited
or rolledback yetHeuristicExceptions
protected void addRecovery(javax.transaction.xa.XAResource xaResource, javax.transaction.xa.Xid xid)
xaResource
- The XA resourcexid
- The Xid for the transaction branch
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |