Class XATerminatorImple
java.lang.Object
com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple
- All Implemented Interfaces:
XATerminatorExtensions
,jakarta.resource.spi.XATerminator
,org.jboss.tm.ExtendedJBossXATerminator
- Direct Known Subclasses:
XATerminator
public class XATerminatorImple
extends Object
implements jakarta.resource.spi.XATerminator, XATerminatorExtensions, org.jboss.tm.ExtendedJBossXATerminator
The XATerminator implementation.
- Author:
- mcl
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
beforeCompletion
(Xid xid) Call beforeCompletion on the registered instance.void
Commit the transaction identified and hence any inflow-associated work.Xid[]
Return a list of indoubt transactions.void
If the transaction subordinate generated a heuristic, then this operation will be called later once that heuristic has been resolved.Obtain the unique id of the currently associated transactionLookup an imported transaction by its Xidjakarta.transaction.Transaction
getTransaction
(Xid xid) Convert an imported Xid into a Transaction object.jakarta.transaction.Transaction
Look up a transaction by its idXid[]
getXidsToRecoverForParentNode
(boolean recoverInFlight, String parentNodeName, int recoveryFlags) Get a list of Xids that are potentially recoverable.org.jboss.tm.TransactionImportResult
importTransaction
(Xid xid, int timeoutIfNew) A thread safe method to convert an imported Xid into a Transaction object.boolean
Test whether or not theExtendedJBossXATerminator.doRecover(Xid, String)
call will throw NotSupportedExceptionint
Prepare the imported transaction.Xid[]
recover
(int flag) Return a list of indoubt transactions.void
forget about this imported transaction.void
Rollback the imported transaction subordinate.
-
Constructor Details
-
XATerminatorImple
public XATerminatorImple()
-
-
Method Details
-
commit
Commit the transaction identified and hence any inflow-associated work.- Specified by:
commit
in interfacejakarta.resource.spi.XATerminator
- Parameters:
xid
- the transaction to commitonePhase
- whether or not this is a one-phase commit (should only betrue
if there is a single resource associated with the transaction).- Throws:
XAException
- thrown if there are any errors, including if the transaction cannot commit and has to roll back.
-
forget
If the transaction subordinate generated a heuristic, then this operation will be called later once that heuristic has been resolved.- Specified by:
forget
in interfacejakarta.resource.spi.XATerminator
- Parameters:
xid
- the transaction.- Throws:
XAException
- if any error happens.
-
prepare
Prepare the imported transaction.- Specified by:
prepare
in interfacejakarta.resource.spi.XATerminator
- Parameters:
xid
- the transaction to prepare.- Returns:
- either XAResource.XA_OK if the transaction prepared, or XAResource.XA_RDONLY if it was a read-only transaction (and in which case, a second phase message is not expected/required.)
- Throws:
XAException
- thrown if any error occurs, including if the transaction has rolled back.
-
recover
Return a list of indoubt transactions. This may include those transactions that are currently in-flight and running 2PC and do not need recovery invoked on them.- Specified by:
recover
in interfacejakarta.resource.spi.XATerminator
- Parameters:
flag
- either XAResource.TMSTARTRSCAN to indicate the start of a recovery scan, or XAResource.TMENDRSCAN to indicate the end of the recovery scan.- Returns:
- a list of potentially indoubt transactions or
null
. - Throws:
XAException
- thrown if any error occurs.
-
doRecover
Return a list of indoubt transactions. This may include those transactions that are currently in-flight and running 2PC and do not need recovery invoked on them.- Specified by:
doRecover
in interfaceorg.jboss.tm.ExtendedJBossXATerminator
- Parameters:
nodeName
- Only recover transactions for this node (unless set to NodeNameXAResourceOrphanFilter.RECOVER_ALL_NODES)- Returns:
- a list of potentially indoubt transactions or
null
. - Throws:
XAException
- thrown if any error occurs.
-
isRecoveryByNodeOrXidSupported
public boolean isRecoveryByNodeOrXidSupported()Description copied from interface:org.jboss.tm.ExtendedJBossXATerminator
Test whether or not theExtendedJBossXATerminator.doRecover(Xid, String)
call will throw NotSupportedException- Specified by:
isRecoveryByNodeOrXidSupported
in interfaceorg.jboss.tm.ExtendedJBossXATerminator
- Returns:
-
rollback
Rollback the imported transaction subordinate.- Specified by:
rollback
in interfacejakarta.resource.spi.XATerminator
- Parameters:
xid
- the transaction to roll back.- Throws:
XAException
- thrown if there are any errors.
-
beforeCompletion
Description copied from interface:XATerminatorExtensions
Call beforeCompletion on the registered instance. Exceptions will cause the transaction to be set rollback only. Note: this will run beforeCompletion even on setRollbackOnly transactions. Users may wish to avoid calling this method in such cases, or prior to calling rollback.- Specified by:
beforeCompletion
in interfaceXATerminatorExtensions
- Parameters:
xid
- the transaction instance.- Returns:
- success (or not).
- Throws:
jakarta.transaction.SystemException
-
getTransaction
Description copied from interface:org.jboss.tm.ExtendedJBossXATerminator
Convert an imported Xid into a Transaction object.- Specified by:
getTransaction
in interfaceorg.jboss.tm.ExtendedJBossXATerminator
- Parameters:
xid
- the global Xid of the target transaction to lookup- Returns:
- A transaction object corresponding to the Xid or null if there is no such transaction
- Throws:
XAException
- with code XA_RBROLLBACK if the transaction has already aborted
-
importTransaction
public org.jboss.tm.TransactionImportResult importTransaction(Xid xid, int timeoutIfNew) throws XAException Description copied from interface:org.jboss.tm.ExtendedJBossXATerminator
A thread safe method to convert an imported Xid into a Transaction object. If the transaction does not exist then a subordinate transaction for the xid will be created and associated with the global transaction. In the case where a new subordinate is created then the timeout parameter will be used. If timeout is non zero then the inflowed transaction will survive for that period before being eligible to be aborted. If timeout is zero then no timeout will be associated with the subordinate transaction.- Specified by:
importTransaction
in interfaceorg.jboss.tm.ExtendedJBossXATerminator
- Parameters:
xid
- The global Xid of the target transaction to lookuptimeoutIfNew
- The timeout associated with the global transaction if one was created.- Returns:
- A wrapper containing the transaction object corresponding to the Xid or null if there is no such transaction
- Throws:
XAException
- with code XA_RBROLLBACK if the transaction has already aborted
-
getImportedTransaction
Description copied from interface:org.jboss.tm.ExtendedJBossXATerminator
Lookup an imported transaction by its Xid- Specified by:
getImportedTransaction
in interfaceorg.jboss.tm.ExtendedJBossXATerminator
- Parameters:
xid
- the Xid of the transaction to lookup- Returns:
- the corresponding imported transaction object or null
- Throws:
XAException
- if the transaction is known to have rolled back
-
getTransactionById
Description copied from interface:org.jboss.tm.ExtendedJBossXATerminator
Look up a transaction by its id- Specified by:
getTransactionById
in interfaceorg.jboss.tm.ExtendedJBossXATerminator
- Parameters:
id
- an id that uniquelly identifies a transaction- Returns:
-
getCurrentTransactionId
Description copied from interface:org.jboss.tm.ExtendedJBossXATerminator
Obtain the unique id of the currently associated transaction- Specified by:
getCurrentTransactionId
in interfaceorg.jboss.tm.ExtendedJBossXATerminator
- Returns:
- the id or null if no transaction is associated with the calling thread
-
removeImportedTransaction
Description copied from interface:org.jboss.tm.ExtendedJBossXATerminator
forget about this imported transaction.- Specified by:
removeImportedTransaction
in interfaceorg.jboss.tm.ExtendedJBossXATerminator
- Parameters:
xid
- the global Xid of the transaction.- Throws:
XAException
- thrown if there are any errors.
-
getXidsToRecoverForParentNode
public Xid[] getXidsToRecoverForParentNode(boolean recoverInFlight, String parentNodeName, int recoveryFlags) throws XAException Description copied from interface:org.jboss.tm.ExtendedJBossXATerminator
Get a list of Xids that are potentially recoverable.- Specified by:
getXidsToRecoverForParentNode
in interfaceorg.jboss.tm.ExtendedJBossXATerminator
- Parameters:
recoverInFlight
- indicates whether or not to include transactions that have not begun 2PCparentNodeName
- If not null then only recover transactions for this noderecoveryFlags
- One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in the parameter. These constants are defined in javax.transaction.xa.XAResource interface- Returns:
- an array of Xids to recover
- Throws:
XAException
- An error has occurred. Possible values are XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.
-