Class JavaEETransactionImpl

  • All Implemented Interfaces:
    JavaEETransaction, jakarta.transaction.Transaction, Runnable

    public final class JavaEETransactionImpl
    extends Object
    implements Runnable, JavaEETransaction
    This class implements the JTA Transaction API for the J2EE RI. It is a wrapper over the JTS Transaction object that provides optimized local transaction support when a transaction uses zero/one non-XA resource, and delegates to JTS otherwise. This object can be in two states: local tx (jtsTx==null) or global (JTS) tx. If jtsTx!=null, all calls are delegated to jtsTx. Time out capability is added to the local transactions. This class extends the TimerTask. When the transaction needs to be timedout, this schedules with the timer. At the commit and rollback time, task will be cancelled. If the transaction is timedout, run() method will be called and transaction will be marked for rollback.
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface Runnable
      • cancelTimerTask

        public int cancelTimerTask()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • onTxCompletion

        protected void onTxCompletion​(boolean status)
      • commit

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

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

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

        public boolean enlistResource​(XAResource xaRes)
                               throws jakarta.transaction.RollbackException,
                                      IllegalStateException,
                                      jakarta.transaction.SystemException
        Specified by:
        enlistResource in interface jakarta.transaction.Transaction
        Throws:
        jakarta.transaction.RollbackException
        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
      • setRollbackOnly

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

        public String getTransactionId()
      • getStartTime

        public long getStartTime()
      • getAllParticipatingPools

        public Set getAllParticipatingPools()
        Return all pools registered in the resourceTable. This will cut down the scope of pools on which transactionComplted is called by the PoolManagerImpl. This method will return only those pools that have ever participated in a tx
        Specified by:
        getAllParticipatingPools in interface JavaEETransaction
      • setActiveTxCache

        public void setActiveTxCache​(Object cache)
      • getActiveTxCache

        public Object getActiveTxCache()
      • getRemainingTimeout

        public int getRemainingTimeout()
        Return duration in seconds before transaction would timeout. Returns zero if this transaction has no timeout set. Returns negative value if already timed out.