Class DelegatingTransactionManager

java.lang.Object
com.arjuna.ats.jta.cdi.DelegatingTransactionManager
All Implemented Interfaces:
jakarta.transaction.TransactionManager, Serializable

public abstract class DelegatingTransactionManager extends Object implements Serializable, jakarta.transaction.TransactionManager
An abstract TransactionManager implementation that delegates all method invocations to another TransactionManager.
Author:
Laird Nelson
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    DelegatingTransactionManager(jakarta.transaction.TransactionManager delegate)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Creates a new transaction and associates it with the current thread.
    void
    Completes the transaction associated with the current thread.
    int
    Returns the status of the transaction associated with the current thread.
    jakarta.transaction.Transaction
    Returns the Transaction object that represents the transaction context of the calling thread.
    void
    resume(jakarta.transaction.Transaction transaction)
    Resumes the transaction context association of the calling thread with the transaction represented by the supplied Transaction object.
    void
    Rolls back the transaction associated with the current thread.
    void
    Irrevocably modifies the transaction associated with the current thread such that the only possible outcome is for it to roll back.
    void
    setTransactionTimeout(int seconds)
    Sets the timeout value that is associated with transactions started by the current thread with the begin() method.
    jakarta.transaction.Transaction
    Suspends the transaction currently associated with the calling thread and returns a Transaction that represents the transaction context being suspended, or null if the calling thread is not associated with a transaction.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DelegatingTransactionManager

      protected DelegatingTransactionManager(jakarta.transaction.TransactionManager delegate)
      Parameters:
      delegate - the TransactionManager to which all method invocations will be delegated; may be null, but all methods in this class will then throw a SystemException
  • Method Details

    • begin

      public void begin() throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemException
      Creates a new transaction and associates it with the current thread.
      Specified by:
      begin in interface jakarta.transaction.TransactionManager
      Throws:
      jakarta.transaction.NotSupportedException - if the thread is already associated with a transaction and this TransactionManager implementation does not support nested transactions
      jakarta.transaction.SystemException - if this TransactionManager encounters an unexpected error condition
    • commit

      public void commit() throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, jakarta.transaction.SystemException
      Completes the transaction associated with the current thread.

      When this method completes, the thread is no longer associated with a transaction.

      Specified by:
      commit in interface jakarta.transaction.TransactionManager
      Throws:
      jakarta.transaction.RollbackException - if the transaction has been rolled back rather than committed
      jakarta.transaction.HeuristicMixedException - if a heuristic decision was made and that some relevant updates have been committed while others have been rolled back
      jakarta.transaction.HeuristicRollbackException - if a heuristic decision was made and all relevant updates have been rolled back
      SecurityException - if the thread is not allowed to commit the transaction
      IllegalStateException - if the current thread is not associated with a transaction
      jakarta.transaction.SystemException - if this TransactionManager encounters an unexpected error condition
    • getStatus

      public int getStatus() throws jakarta.transaction.SystemException
      Returns the status of the transaction associated with the current thread.
      Specified by:
      getStatus in interface jakarta.transaction.TransactionManager
      Returns:
      the transaction status expressed as the value of one of the int constants in the Status class; if no transaction is associated with the current thread, this method returns Status.STATUS_NO_TRANSACTION
      Throws:
      jakarta.transaction.SystemException - if this TransactionManager encounters an unexpected error condition
      See Also:
      • Status
    • getTransaction

      public jakarta.transaction.Transaction getTransaction() throws jakarta.transaction.SystemException
      Returns the Transaction object that represents the transaction context of the calling thread.

      This method never returns null.

      Specified by:
      getTransaction in interface jakarta.transaction.TransactionManager
      Returns:
      the Transaction object representing the transaction associated with the calling thread; never null
      Throws:
      jakarta.transaction.SystemException - if this TransactionManager encounters an unexpected error condition
    • resume

      public void resume(jakarta.transaction.Transaction transaction) throws jakarta.transaction.InvalidTransactionException, jakarta.transaction.SystemException
      Resumes the transaction context association of the calling thread with the transaction represented by the supplied Transaction object.

      When this method returns, the calling thread is associated with the transaction context specified.

      Specified by:
      resume in interface jakarta.transaction.TransactionManager
      Parameters:
      transaction - the Transaction representing the transaction to be resumed; must not be null
      Throws:
      jakarta.transaction.InvalidTransactionException - if transaction is invalid
      IllegalStateException - if the thread is already associated with another transaction
      jakarta.transaction.SystemException - if this TransactionManager encounters an unexpected error condition
    • rollback

      public void rollback() throws jakarta.transaction.SystemException
      Rolls back the transaction associated with the current thread.

      When this method completes, the thread is no longer associated with a transaction.

      Specified by:
      rollback in interface jakarta.transaction.TransactionManager
      Throws:
      SecurityException - if the thread is not allowed to roll back the transaction
      IllegalStateException - if the current thread is not associated with a transaction
      jakarta.transaction.SystemException - if this TransactionManager encounters an unexpected error condition
    • setRollbackOnly

      public void setRollbackOnly() throws jakarta.transaction.SystemException
      Irrevocably modifies the transaction associated with the current thread such that the only possible outcome is for it to roll back.
      Specified by:
      setRollbackOnly in interface jakarta.transaction.TransactionManager
      Throws:
      IllegalStateException - if the current thread is not associated with a transaction
      jakarta.transaction.SystemException - if this TransactionManager encounters an unexpected error condition
    • setTransactionTimeout

      public void setTransactionTimeout(int seconds) throws jakarta.transaction.SystemException
      Sets 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 jakarta.transaction.TransactionManager
      Parameters:
      seconds - 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:
      jakarta.transaction.SystemException - if this TransactionManager encounters an unexpected error condition or if seconds is less than zero
    • suspend

      public jakarta.transaction.Transaction suspend() throws jakarta.transaction.SystemException
      Suspends the transaction currently associated with the calling thread and returns a Transaction that represents the transaction context being suspended, or null if the calling thread is not associated with a transaction.

      This method may return null.

      When this method returns, the calling thread is no longer associated with a transaction.

      Specified by:
      suspend in interface jakarta.transaction.TransactionManager
      Returns:
      a Transaction representing the suspended transaction, or null
      Throws:
      jakarta.transaction.SystemException - if this TransactionManager encounters an unexpected error condition