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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin()Start a new transaction and bind the context to the calling thread.voidcommit()voidDump an overview of all running transactions as debug logs.Get the transaction currently registered on the current thread context.Return all in-flight transactions.longReturn the timestamp of the oldest in-flight transaction.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.intjakarta.transaction.Transactionvoidresume(jakarta.transaction.Transaction transaction) voidrollback()voidvoidsetTransactionTimeout(int seconds) voidshutdown()Shut down the transaction manager and release all resources held by it.jakarta.transaction.Transactionsuspend()toString()
-
Constructor Details
-
BitronixTransactionManager
public BitronixTransactionManager()Create theBitronixTransactionManager. 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.SystemExceptionStart a new transaction and bind the context to the calling thread.- Specified by:
beginin interfacejakarta.transaction.TransactionManager- Specified by:
beginin interfacejakarta.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:
commitin interfacejakarta.transaction.TransactionManager- Specified by:
commitin interfacejakarta.transaction.UserTransaction- Throws:
jakarta.transaction.RollbackExceptionjakarta.transaction.HeuristicMixedExceptionjakarta.transaction.HeuristicRollbackExceptionSecurityExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
rollback
public void rollback() throws IllegalStateException, SecurityException, jakarta.transaction.SystemException- Specified by:
rollbackin interfacejakarta.transaction.TransactionManager- Specified by:
rollbackin interfacejakarta.transaction.UserTransaction- Throws:
IllegalStateExceptionSecurityExceptionjakarta.transaction.SystemException
-
getStatus
public int getStatus() throws jakarta.transaction.SystemException- Specified by:
getStatusin interfacejakarta.transaction.TransactionManager- Specified by:
getStatusin interfacejakarta.transaction.UserTransaction- Throws:
jakarta.transaction.SystemException
-
getTransaction
public jakarta.transaction.Transaction getTransaction() throws jakarta.transaction.SystemException- Specified by:
getTransactionin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.SystemException
-
setRollbackOnly
- Specified by:
setRollbackOnlyin interfacejakarta.transaction.TransactionManager- Specified by:
setRollbackOnlyin interfacejakarta.transaction.UserTransaction- Throws:
IllegalStateExceptionjakarta.transaction.SystemException
-
setTransactionTimeout
public void setTransactionTimeout(int seconds) throws jakarta.transaction.SystemException - Specified by:
setTransactionTimeoutin interfacejakarta.transaction.TransactionManager- Specified by:
setTransactionTimeoutin interfacejakarta.transaction.UserTransaction- Throws:
jakarta.transaction.SystemException
-
suspend
public jakarta.transaction.Transaction suspend() throws jakarta.transaction.SystemException- Specified by:
suspendin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.SystemException
-
resume
public void resume(jakarta.transaction.Transaction transaction) throws jakarta.transaction.InvalidTransactionException, IllegalStateException, jakarta.transaction.SystemException - Specified by:
resumein interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.InvalidTransactionExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
getReference
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:
getReferencein interfaceReferenceable- Returns:
- an empty reference to get the BitronixTransactionManager.
- Throws:
NamingException
-
getInFlightTransactions
Return all in-flight transactions.- Returns:
- a map of
BitronixTransactionobjects usingUidas key andBitronixTransactionas 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
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
ResourceLoaderlike 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 toTransactionManager.begin()) will be rejected with aSystemException. -
toString
-