Package com.arjuna.ats.jta.cdi
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
AnabstractTransactionManagerimplementation that delegates all method invocations to anotherTransactionManager.- Author:
- Laird Nelson
- See Also:
TransactionManager, Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDelegatingTransactionManager(jakarta.transaction.TransactionManager delegate)Creates a newDelegatingTransactionManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin()Creates a new transaction and associates it with the current thread.voidcommit()Completes the transaction associated with the current thread.intgetStatus()Returns the status of the transaction associated with the current thread.jakarta.transaction.TransactiongetTransaction()Returns theTransactionobject that represents the transaction context of the calling thread.voidresume(jakarta.transaction.Transaction transaction)Resumes the transaction context association of the calling thread with the transaction represented by the suppliedTransactionobject.voidrollback()Rolls back the transaction associated with the current thread.voidsetRollbackOnly()Irrevocably modifies the transaction associated with the current thread such that the only possible outcome is for it to roll back.voidsetTransactionTimeout(int seconds)Sets the timeout value that is associated with transactions started by the current thread with thebegin()method.jakarta.transaction.Transactionsuspend()Suspends the transaction currently associated with the calling thread and returns aTransactionthat represents the transaction context being suspended, ornullif the calling thread is not associated with a transaction.
-
-
-
Constructor Detail
-
DelegatingTransactionManager
protected DelegatingTransactionManager(jakarta.transaction.TransactionManager delegate)
Creates a newDelegatingTransactionManager.- Parameters:
delegate- theTransactionManagerto which all method invocations will be delegated; may benull, but all methods in this class will then throw aSystemException
-
-
Method Detail
-
begin
public void begin() throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemExceptionCreates a new transaction and associates it with the current thread.- Specified by:
beginin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.NotSupportedException- if the thread is already associated with a transaction and thisTransactionManagerimplementation does not support nested transactionsjakarta.transaction.SystemException- if thisTransactionManagerencounters an unexpected error condition
-
commit
public void commit() throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, jakarta.transaction.SystemExceptionCompletes the transaction associated with the current thread.When this method completes, the thread is no longer associated with a transaction.
- Specified by:
commitin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.RollbackException- if the transaction has been rolled back rather than committedjakarta.transaction.HeuristicMixedException- if a heuristic decision was made and that some relevant updates have been committed while others have been rolled backjakarta.transaction.HeuristicRollbackException- if a heuristic decision was made and all relevant updates have been rolled backSecurityException- if the thread is not allowed to commit the transactionIllegalStateException- if the current thread is not associated with a transactionjakarta.transaction.SystemException- if thisTransactionManagerencounters an unexpected error condition
-
getStatus
public int getStatus() throws jakarta.transaction.SystemExceptionReturns the status of the transaction associated with the current thread.- Specified by:
getStatusin interfacejakarta.transaction.TransactionManager- Returns:
- the transaction status expressed as the value of one of
the
intconstants in theStatusclass; if no transaction is associated with the current thread, this method returnsStatus.STATUS_NO_TRANSACTION - Throws:
jakarta.transaction.SystemException- if thisTransactionManagerencounters an unexpected error condition- See Also:
Status
-
getTransaction
public jakarta.transaction.Transaction getTransaction() throws jakarta.transaction.SystemExceptionReturns theTransactionobject that represents the transaction context of the calling thread.This method never returns
null.- Specified by:
getTransactionin interfacejakarta.transaction.TransactionManager- Returns:
- the
Transactionobject representing the transaction associated with the calling thread; nevernull - Throws:
jakarta.transaction.SystemException- if thisTransactionManagerencounters an unexpected error condition
-
resume
public void resume(jakarta.transaction.Transaction transaction) throws jakarta.transaction.InvalidTransactionException, jakarta.transaction.SystemExceptionResumes the transaction context association of the calling thread with the transaction represented by the suppliedTransactionobject.When this method returns, the calling thread is associated with the transaction context specified.
- Specified by:
resumein interfacejakarta.transaction.TransactionManager- Parameters:
transaction- theTransactionrepresenting the transaction to be resumed; must not benull- Throws:
jakarta.transaction.InvalidTransactionException- iftransactionis invalidIllegalStateException- if the thread is already associated with another transactionjakarta.transaction.SystemException- if thisTransactionManagerencounters an unexpected error condition
-
rollback
public void rollback() throws jakarta.transaction.SystemExceptionRolls back the transaction associated with the current thread.When this method completes, the thread is no longer associated with a transaction.
- Specified by:
rollbackin interfacejakarta.transaction.TransactionManager- Throws:
SecurityException- if the thread is not allowed to roll back the transactionIllegalStateException- if the current thread is not associated with a transactionjakarta.transaction.SystemException- if thisTransactionManagerencounters an unexpected error condition
-
setRollbackOnly
public void setRollbackOnly() throws jakarta.transaction.SystemExceptionIrrevocably modifies the transaction associated with the current thread such that the only possible outcome is for it to roll back.- Specified by:
setRollbackOnlyin interfacejakarta.transaction.TransactionManager- Throws:
IllegalStateException- if the current thread is not associated with a transactionjakarta.transaction.SystemException- if thisTransactionManagerencounters an unexpected error condition
-
setTransactionTimeout
public void setTransactionTimeout(int seconds) throws jakarta.transaction.SystemExceptionSets the timeout value that is associated with transactions started by the current thread with thebegin()method.If an application has not called this method, the transaction service uses some default value for the transaction timeout.
- Specified by:
setTransactionTimeoutin interfacejakarta.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 aSystemExceptionis thrown- Throws:
jakarta.transaction.SystemException- if thisTransactionManagerencounters an unexpected error condition or ifsecondsis less than zero
-
suspend
public jakarta.transaction.Transaction suspend() throws jakarta.transaction.SystemExceptionSuspends the transaction currently associated with the calling thread and returns aTransactionthat represents the transaction context being suspended, ornullif 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:
suspendin interfacejakarta.transaction.TransactionManager- Returns:
- a
Transactionrepresenting the suspended transaction, ornull - Throws:
jakarta.transaction.SystemException- if thisTransactionManagerencounters an unexpected error condition
-
-