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 Details

    • XATerminatorImple

      public XATerminatorImple()
  • Method Details

    • commit

      public void commit(Xid xid, boolean onePhase) throws XAException
      Commit the transaction identified and hence any inflow-associated work.
      Specified by:
      commit in interface jakarta.resource.spi.XATerminator
      Parameters:
      xid - the transaction to commit
      onePhase - whether or not this is a one-phase commit (should only be true 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

      public void forget(Xid xid) throws XAException
      If the transaction subordinate generated a heuristic, then this operation will be called later once that heuristic has been resolved.
      Specified by:
      forget in interface jakarta.resource.spi.XATerminator
      Parameters:
      xid - the transaction.
      Throws:
      XAException - if any error happens.
    • prepare

      public int prepare(Xid xid) throws XAException
      Prepare the imported transaction.
      Specified by:
      prepare in interface jakarta.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

      public Xid[] recover(int flag) throws XAException
      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 interface jakarta.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

      public Xid[] doRecover(Xid xid, String parentNodeName) throws XAException
      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 interface org.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 the ExtendedJBossXATerminator.doRecover(Xid, String) call will throw NotSupportedException
      Specified by:
      isRecoveryByNodeOrXidSupported in interface org.jboss.tm.ExtendedJBossXATerminator
      Returns:
    • rollback

      public void rollback(Xid xid) throws XAException
      Rollback the imported transaction subordinate.
      Specified by:
      rollback in interface jakarta.resource.spi.XATerminator
      Parameters:
      xid - the transaction to roll back.
      Throws:
      XAException - thrown if there are any errors.
    • beforeCompletion

      public boolean beforeCompletion(Xid xid) throws jakarta.transaction.SystemException
      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 interface XATerminatorExtensions
      Parameters:
      xid - the transaction instance.
      Returns:
      success (or not).
      Throws:
      jakarta.transaction.SystemException
    • getTransaction

      public jakarta.transaction.Transaction getTransaction(Xid xid) throws XAException
      Description copied from interface: org.jboss.tm.ExtendedJBossXATerminator
      Convert an imported Xid into a Transaction object.
      Specified by:
      getTransaction in interface org.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 interface org.jboss.tm.ExtendedJBossXATerminator
      Parameters:
      xid - The global Xid of the target transaction to lookup
      timeoutIfNew - 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

      public SubordinateTransaction getImportedTransaction(Xid xid) throws XAException
      Description copied from interface: org.jboss.tm.ExtendedJBossXATerminator
      Lookup an imported transaction by its Xid
      Specified by:
      getImportedTransaction in interface org.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

      public jakarta.transaction.Transaction getTransactionById(Object id)
      Description copied from interface: org.jboss.tm.ExtendedJBossXATerminator
      Look up a transaction by its id
      Specified by:
      getTransactionById in interface org.jboss.tm.ExtendedJBossXATerminator
      Parameters:
      id - an id that uniquelly identifies a transaction
      Returns:
    • getCurrentTransactionId

      public Object getCurrentTransactionId()
      Description copied from interface: org.jboss.tm.ExtendedJBossXATerminator
      Obtain the unique id of the currently associated transaction
      Specified by:
      getCurrentTransactionId in interface org.jboss.tm.ExtendedJBossXATerminator
      Returns:
      the id or null if no transaction is associated with the calling thread
    • removeImportedTransaction

      public void removeImportedTransaction(Xid xid) throws XAException
      Description copied from interface: org.jboss.tm.ExtendedJBossXATerminator
      forget about this imported transaction.
      Specified by:
      removeImportedTransaction in interface org.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 interface org.jboss.tm.ExtendedJBossXATerminator
      Parameters:
      recoverInFlight - indicates whether or not to include transactions that have not begun 2PC
      parentNodeName - If not null then only recover transactions for this node
      recoveryFlags - 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.