Package bitronix.tm

Class BitronixTransactionManager

java.lang.Object
bitronix.tm.BitronixTransactionManager
All Implemented Interfaces:
Service, jakarta.transaction.TransactionManager, jakarta.transaction.UserTransaction, Referenceable

public class BitronixTransactionManager extends Object implements jakarta.transaction.TransactionManager, jakarta.transaction.UserTransaction, Referenceable, Service
Implementation of TransactionManager and UserTransaction.
Author:
lorban
  • Constructor Details

    • BitronixTransactionManager

      public BitronixTransactionManager()
      Create the BitronixTransactionManager. Open the journal, load resources and perform recovery synchronously. The recovery service then gets scheduled for background recovery.
  • Method Details

    • begin

      public void begin() throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemException
      Start a new transaction and bind the context to the calling thread.
      Specified by:
      begin in interface jakarta.transaction.TransactionManager
      Specified by:
      begin in interface jakarta.transaction.UserTransaction
      Throws:
      jakarta.transaction.NotSupportedException - if a transaction is already bound to the calling thread.
      jakarta.transaction.SystemException - if the transaction manager is shutting down.
    • 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.TransactionManager
      Specified by:
      commit in interface jakarta.transaction.UserTransaction
      Throws:
      jakarta.transaction.RollbackException
      jakarta.transaction.HeuristicMixedException
      jakarta.transaction.HeuristicRollbackException
      SecurityException
      IllegalStateException
      jakarta.transaction.SystemException
    • rollback

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

      public int getStatus() throws jakarta.transaction.SystemException
      Specified by:
      getStatus in interface jakarta.transaction.TransactionManager
      Specified by:
      getStatus in interface jakarta.transaction.UserTransaction
      Throws:
      jakarta.transaction.SystemException
    • getTransaction

      public jakarta.transaction.Transaction getTransaction() throws jakarta.transaction.SystemException
      Specified by:
      getTransaction in interface jakarta.transaction.TransactionManager
      Throws:
      jakarta.transaction.SystemException
    • setRollbackOnly

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

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

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

      public void resume(jakarta.transaction.Transaction transaction) throws jakarta.transaction.InvalidTransactionException, IllegalStateException, jakarta.transaction.SystemException
      Specified by:
      resume in interface jakarta.transaction.TransactionManager
      Throws:
      jakarta.transaction.InvalidTransactionException
      IllegalStateException
      jakarta.transaction.SystemException
    • getReference

      public Reference getReference() throws NamingException
      BitronixTransactionManager can only have a single instance per JVM so this method always returns a reference with no special information to find back the sole instance. BitronixTransactionManagerObjectFactory will be used by the JNDI server to get the BitronixTransactionManager instance of the JVM.
      Specified by:
      getReference in interface Referenceable
      Returns:
      an empty reference to get the BitronixTransactionManager.
      Throws:
      NamingException
    • getInFlightTransactions

      public Map getInFlightTransactions()
      Return all in-flight transactions.
      Returns:
      a map of BitronixTransaction objects using Uid as key and BitronixTransaction as value.
    • getOldestInFlightTransactionTimestamp

      public long getOldestInFlightTransactionTimestamp()
      Return the timestamp of the oldest in-flight transaction.
      Returns:
      the timestamp or Long.MIN_VALUE if there is no in-flight transaction.
    • getCurrentTransaction

      public BitronixTransaction getCurrentTransaction()
      Get the transaction currently registered on the current thread context.
      Returns:
      the current transaction or null if no transaction has been started on the current thread.
    • dumpTransactionContexts

      public void dumpTransactionContexts()
      Dump an overview of all running transactions as debug logs.
    • shutdown

      public void shutdown()
      Shut down the transaction manager and release all resources held by it.

      This call will also close the resources pools registered by the ResourceLoader like JMS and JDBC pools. The manually created ones are left untouched.

      The Transaction Manager will wait during a configurable graceful period before forcibly killing active transactions.

      After this method is called, attempts to create new transactions (via calls to TransactionManager.begin()) will be rejected with a SystemException.

      Specified by:
      shutdown in interface Service
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object