Class TransactionImple

java.lang.Object
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple
All Implemented Interfaces:
Transaction, jakarta.transaction.Transaction
Direct Known Subclasses:
TransactionImple

public class TransactionImple extends Object implements jakarta.transaction.Transaction, Transaction
  • Field Details

  • Constructor Details

    • TransactionImple

      public TransactionImple(int timeout)
      Create a new transaction with the specified timeout.
    • TransactionImple

      protected TransactionImple()
    • TransactionImple

      protected TransactionImple(BasicAction curr)
      Create a new TransactionImple representation of a specified transaction.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overloads Object.equals()
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Return -1 if we fail.
      Overrides:
      hashCode in class Object
    • commit

      public void commit() throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, SecurityException, jakarta.transaction.SystemException, IllegalStateException
      We should never throw a HeuristicRollbackException because if we get a HeuristicRollback from a resource, and can successfully rollback the other resources, this is then the same as having simply been forced to rollback the transaction during phase 1.
      Specified by:
      commit in interface jakarta.transaction.Transaction
      Throws:
      jakarta.transaction.RollbackException
      jakarta.transaction.HeuristicMixedException
      jakarta.transaction.HeuristicRollbackException
      SecurityException
      jakarta.transaction.SystemException
      IllegalStateException
    • rollback

      public void rollback() throws IllegalStateException, SecurityException, jakarta.transaction.SystemException
      Specified by:
      rollback in interface jakarta.transaction.Transaction
      Throws:
      IllegalStateException
      SecurityException
      jakarta.transaction.SystemException
    • setRollbackOnly

      public void setRollbackOnly() throws IllegalStateException, jakarta.transaction.SystemException
      Specified by:
      setRollbackOnly in interface jakarta.transaction.Transaction
      Throws:
      IllegalStateException
      jakarta.transaction.SystemException
    • setRollbackOnly

      public void setRollbackOnly(String reason) throws IllegalStateException, jakarta.transaction.SystemException
      Throws:
      IllegalStateException
      jakarta.transaction.SystemException
    • getStatus

      public int getStatus() throws jakarta.transaction.SystemException
      Specified by:
      getStatus in interface jakarta.transaction.Transaction
      Throws:
      jakarta.transaction.SystemException
    • registerSynchronization

      public void registerSynchronization(jakarta.transaction.Synchronization sync) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException
      Specified by:
      registerSynchronization in interface jakarta.transaction.Transaction
      Throws:
      jakarta.transaction.RollbackException
      IllegalStateException
      jakarta.transaction.SystemException
    • enlistResource

      public boolean enlistResource(XAResource xaRes) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException
      This is the JTA compliant version of the method. However, you had better know that your XAResource and family are truly compliant implementations. If they aren't then we may fail gracefully (e.g., some versions of Oracle don't work with arbitrary Xid implementations!) If the family isn't compliant, then you should use the other method and pass through a relevant XAModifier, which should address the issues we have already come across.
      Specified by:
      enlistResource in interface jakarta.transaction.Transaction
      Throws:
      jakarta.transaction.RollbackException
      IllegalStateException
      jakarta.transaction.SystemException
    • enlistResource

      public boolean enlistResource(XAResource xaRes, Object[] params) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException
      Specified by:
      enlistResource in interface Transaction
      Throws:
      jakarta.transaction.RollbackException
      IllegalStateException
      jakarta.transaction.SystemException
    • delistResource

      public boolean delistResource(XAResource xaRes, int flags) throws IllegalStateException, jakarta.transaction.SystemException
      Specified by:
      delistResource in interface jakarta.transaction.Transaction
      Throws:
      IllegalStateException
      jakarta.transaction.SystemException
    • get_uid

      public final Uid get_uid()
      Specified by:
      get_uid in interface Transaction
    • getTxId

      public final Xid getTxId()
      Specified by:
      getTxId in interface Transaction
    • getDeferredThrowables

      public List<Throwable> getDeferredThrowables()
      Returning list of throwables which are bound to transaction failure. This method is intended to be used when handling some error states. The result exception could be enriched with these returned ones.
    • supportsDeferredThrowables

      public boolean supportsDeferredThrowables()
      Method getDeferredThrowables() will return list of deferred throwables.
      Returns:
      true
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • endAssociation

      public void endAssociation(Xid _tranID, XAResource _theXAResource, int xaState, int txInfoState) throws XAException
      Throws:
      XAException
    • getXAResourceState

      public int getXAResourceState(XAResource xaRes)
      Specified by:
      getXAResourceState in interface Transaction
    • setXAResourceState

      public void setXAResourceState(XAResource xaRes, int state)
    • getTransaction

      public static final TransactionImple getTransaction()
    • getTransaction

      public static final TransactionImple getTransaction(Uid id)
    • getTxLocalResource

      public Object getTxLocalResource(Object key)
      Specified by:
      getTxLocalResource in interface Transaction
    • putTxLocalResource

      public void putTxLocalResource(Object key, Object value)
      Specified by:
      putTxLocalResource in interface Transaction
    • isAlive

      public boolean isAlive()
      Specified by:
      isAlive in interface Transaction
    • commitAndDisassociate

      protected void commitAndDisassociate() throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, SecurityException, jakarta.transaction.SystemException, IllegalStateException
      Does the same as commit, but also changes the thread-to-tx association.
      Throws:
      jakarta.transaction.RollbackException
      jakarta.transaction.HeuristicMixedException
      jakarta.transaction.HeuristicRollbackException
      SecurityException
      jakarta.transaction.SystemException
      IllegalStateException
    • baseXid

      protected Xid baseXid()
      If this is an imported transaction (via JCA) then this will be the Xid we are pretending to be. Otherwise, it will be null.
      Returns:
      null if we are a local transaction, a valid Xid if we have been imported.
    • rollbackAndDisassociate

      protected void rollbackAndDisassociate() throws IllegalStateException, SecurityException, jakarta.transaction.SystemException
      Does the same as rollback, but also changes the thread-to-tx association.
      Throws:
      IllegalStateException
      SecurityException
      jakarta.transaction.SystemException
    • endSuspendedRMs

      protected boolean endSuspendedRMs()
      If there are any suspended RMs then we should call end on them before the transaction is terminated.
    • createXid

      protected Xid createXid(boolean branch, XAModifier theModifier, XAResource xaResource) throws IOException, ObjectStoreException
      Throws:
      IOException
      ObjectStoreException
    • putTransaction

      protected static final void putTransaction(TransactionImple tx)
    • removeTransaction

      public static final void removeTransaction(TransactionImple tx)
    • getTransactions

      public static Map<Uid,jakarta.transaction.Transaction> getTransactions()
    • getResources

      public Map<XAResource,TxInfo> getResources()
      Specified by:
      getResources in interface Transaction
    • getTimeout

      public int getTimeout()
      Specified by:
      getTimeout in interface Transaction
    • getRemainingTimeoutMills

      public long getRemainingTimeoutMills()
      Specified by:
      getRemainingTimeoutMills in interface Transaction
    • getSynchronizations

      public Map<Uid,String> getSynchronizations()
      Specified by:
      getSynchronizations in interface Transaction