Class TransactionManagerImpl

  • All Implemented Interfaces:
    TransactionManager
    Direct Known Subclasses:
    RemoteTransactionManager

    public abstract class TransactionManagerImpl
    extends Object
    implements 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 Transaction getTransaction()
        Description copied from interface: TransactionManager
        Get the transaction object that represents the transaction context of the calling thread.
        Specified by:
        getTransaction in interface TransactionManager
        Returns:
        the Transaction object representing the transaction associated with the calling thread.
      • getStatus

        public int getStatus()
                      throws SystemException
        Description copied from interface: TransactionManager
        Obtain the status of the transaction associated with the current thread.
        Specified by:
        getStatus in interface TransactionManager
        Returns:
        The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.
        Throws:
        SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • setTransactionTimeout

        public void setTransactionTimeout​(int seconds)
                                   throws SystemException
        Description copied from interface: TransactionManager
        Modify the timeout value that is associated with transactions started by the current thread with the begin method.

        If an application has not called this method, the transaction service uses some default value for the transaction timeout.

        Specified by:
        setTransactionTimeout in interface TransactionManager
        Parameters:
        seconds - The value of the timeout in seconds. If the value is zero, the transaction service restores the default value. If the value is negative a SystemException is thrown.
        Throws:
        SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • suspend

        public Transaction suspend()
                            throws SystemException
        Description copied from interface: TransactionManager
        Suspend the transaction currently associated with the calling thread and return a Transaction object that represents the transaction context being suspended. If the calling thread is not associated with a transaction, the method returns a null object reference. When this method returns, the calling thread is not associated with a transaction.
        Specified by:
        suspend in interface TransactionManager
        Returns:
        Transaction object representing the suspended transaction.
        Throws:
        SystemException - Thrown if the transaction manager encounters an unexpected error condition.
      • createTransaction

        protected abstract Transaction createTransaction()