Class TransactionManagerImpl

  • All Implemented Interfaces:
    javax.transaction.TransactionManager
    Direct Known Subclasses:
    EmbeddedBaseTransactionManager, RemoteTransactionManager

    public abstract class TransactionManagerImpl
    extends Object
    implements javax.transaction.TransactionManager
    A simple TransactionManager implementation.

    It provides the basic to handle Transactions and supports any XAResource.

    Implementation notes:

    • The state is kept in memory only.
    • Does not support recover.
    • Does not support multi-thread transactions. Although it is possible to execute the transactions in multiple threads, this transaction manager does not wait for them to complete. It is the application responsibility to wait before invoking commit() or rollback()
    • The transaction should not block. It is no possible to setTransactionTimeout(int) and this transaction manager won't rollback the transaction if it takes too long.

    If you need any of the requirements above, please consider use another implementation.

    Also, it does not implement any 1-phase-commit optimization.

    Since:
    9.1
    Author:
    Bela Ban, Pedro Ruivo
    • Field Detail

      • transactionManagerId

        protected final UUID transactionManagerId
    • Constructor Detail

      • TransactionManagerImpl

        public TransactionManagerImpl()
    • Method Detail

      • dissociateTransaction

        public static void dissociateTransaction()
      • getTransaction

        public javax.transaction.Transaction getTransaction()
        Specified by:
        getTransaction in interface javax.transaction.TransactionManager
      • begin

        public void begin()
                   throws javax.transaction.NotSupportedException,
                          javax.transaction.SystemException
        Specified by:
        begin in interface javax.transaction.TransactionManager
        Throws:
        javax.transaction.NotSupportedException
        javax.transaction.SystemException
      • commit

        public void commit()
                    throws javax.transaction.RollbackException,
                           javax.transaction.HeuristicMixedException,
                           javax.transaction.HeuristicRollbackException,
                           SecurityException,
                           IllegalStateException,
                           javax.transaction.SystemException
        Specified by:
        commit in interface javax.transaction.TransactionManager
        Throws:
        javax.transaction.RollbackException
        javax.transaction.HeuristicMixedException
        javax.transaction.HeuristicRollbackException
        SecurityException
        IllegalStateException
        javax.transaction.SystemException
      • setRollbackOnly

        public void setRollbackOnly()
                             throws IllegalStateException,
                                    javax.transaction.SystemException
        Specified by:
        setRollbackOnly in interface javax.transaction.TransactionManager
        Throws:
        IllegalStateException
        javax.transaction.SystemException
      • getStatus

        public int getStatus()
                      throws javax.transaction.SystemException
        Specified by:
        getStatus in interface javax.transaction.TransactionManager
        Throws:
        javax.transaction.SystemException
      • setTransactionTimeout

        public void setTransactionTimeout​(int seconds)
                                   throws javax.transaction.SystemException
        Specified by:
        setTransactionTimeout in interface javax.transaction.TransactionManager
        Throws:
        javax.transaction.SystemException
      • suspend

        public javax.transaction.Transaction suspend()
                                              throws javax.transaction.SystemException
        Specified by:
        suspend in interface javax.transaction.TransactionManager
        Throws:
        javax.transaction.SystemException
      • resume

        public void resume​(javax.transaction.Transaction tx)
                    throws javax.transaction.InvalidTransactionException,
                           IllegalStateException,
                           javax.transaction.SystemException
        Specified by:
        resume in interface javax.transaction.TransactionManager
        Throws:
        javax.transaction.InvalidTransactionException
        IllegalStateException
        javax.transaction.SystemException
      • createTransaction

        protected abstract javax.transaction.Transaction createTransaction()