Package bitronix.tm.resource.common
Class TransactionContextHelper
java.lang.Object
bitronix.tm.resource.common.TransactionContextHelper
Helper class that contains static logic common accross all resource types.
- Author:
- lorban
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BitronixTransactionGet the transaction running on the current thead context.static voiddelistFromCurrentTransaction(XAResourceHolder xaResourceHolder) Delist theXAResourceHolderfrom the current transaction or do nothing if there is no global transaction context for this thread.static voidenlistInCurrentTransaction(XAResourceHolder xaResourceHolder) Enlist theXAResourceHolderin the current transaction or do nothing if there is no global transaction context for this thread.static voidrecycle(XAStatefulHolder xaStatefulHolder) Ensure theXAStatefulHolder's release won't be deferred anymore (when appropriate) as it has been recycled.static voidrequeue(XAStatefulHolder xaStatefulHolder, ResourceBean bean) Switch theXAStatefulHolder's state appropriately after the acquired resource handle has been closed.
-
Constructor Details
-
TransactionContextHelper
public TransactionContextHelper()
-
-
Method Details
-
enlistInCurrentTransaction
public static void enlistInCurrentTransaction(XAResourceHolder xaResourceHolder) throws jakarta.transaction.SystemException, jakarta.transaction.RollbackException Enlist theXAResourceHolderin the current transaction or do nothing if there is no global transaction context for this thread.- Parameters:
xaResourceHolder- theXAResourceHolderto enlist.- Throws:
jakarta.transaction.SystemException- if an internal error happens.jakarta.transaction.RollbackException- if the current transaction has been marked as rollback only.
-
delistFromCurrentTransaction
public static void delistFromCurrentTransaction(XAResourceHolder xaResourceHolder) throws jakarta.transaction.SystemException Delist theXAResourceHolderfrom the current transaction or do nothing if there is no global transaction context for this thread.- Parameters:
xaResourceHolder- theXAResourceHolderto delist.- Throws:
jakarta.transaction.SystemException- if an internal error happens.
-
currentTransaction
Get the transaction running on the current thead context.- Returns:
- null if there is no transaction on the current context or if the transaction manager is not running.
-
requeue
public static void requeue(XAStatefulHolder xaStatefulHolder, ResourceBean bean) throws BitronixSystemException Switch theXAStatefulHolder's state appropriately after the acquired resource handle has been closed. The pooled resource will either be marked as closed or not accessible, depending on the value of the bean'sdeferConnectionReleaseproperty and will be marked for release after 2PC execution in the latter case.- Parameters:
xaStatefulHolder- theXAStatefulHolderto requeue.bean- theResourceBeanof theXAResourceHolder.- Throws:
BitronixSystemException- if an internal error happens.
-
recycle
Ensure theXAStatefulHolder's release won't be deferred anymore (when appropriate) as it has been recycled.- Parameters:
xaStatefulHolder- the recycledXAStatefulHolder.
-