Package io.helidon.integrations.jta.cdi
Class DelegatingTransactionManager
- java.lang.Object
-
- io.helidon.integrations.jta.cdi.DelegatingTransactionManager
-
- All Implemented Interfaces:
TransactionManager
public abstract class DelegatingTransactionManager extends Object implements TransactionManager
Anabstract
TransactionManager
implementation that delegates all method invocations to anotherTransactionManager
.Design Notes
This class is
public
for convenience. It is extended by other non-public
internal classes.- See Also:
TransactionManager
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DelegatingTransactionManager(TransactionManager delegate)
Creates a newDelegatingTransactionManager
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
begin()
Creates a new transaction and associates it with the current thread.void
commit()
Completes the transaction associated with the current thread.int
getStatus()
Returns the status of the transaction associated with the current thread.Transaction
getTransaction()
Returns theTransaction
object that represents the transaction context of the calling thread.void
resume(Transaction transaction)
Resumes the transaction context association of the calling thread with the transaction represented by the suppliedTransaction
object.void
rollback()
Rolls back the transaction associated with the current thread.void
setRollbackOnly()
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 thebegin()
method.Transaction
suspend()
Suspends the transaction currently associated with the calling thread and returns aTransaction
that represents the transaction context being suspended, ornull
if the calling thread is not associated with a transaction.
-
-
-
Constructor Detail
-
DelegatingTransactionManager
protected DelegatingTransactionManager(TransactionManager delegate)
Creates a newDelegatingTransactionManager
.- Parameters:
delegate
- theTransactionManager
to which all method invocations will be delegated; may benull
, but then aSystemException
will be thrown by every method in this class when invoked
-
-
Method Detail
-
begin
public void begin() throws NotSupportedException, SystemException
Creates a new transaction and associates it with the current thread.- Specified by:
begin
in interfaceTransactionManager
- Throws:
NotSupportedException
- if the thread is already associated with a transaction and thisTransactionManager
implementation does not support nested transactionsSystemException
- if thisTransactionManager
encounters an unexpected error condition
-
commit
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, 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 interfaceTransactionManager
- Throws:
RollbackException
- if the transaction has been rolled back rather than committedHeuristicMixedException
- if a heuristic decision was made and that some relevant updates have been committed while others have been rolled backHeuristicRollbackException
- 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 transactionSystemException
- if thisTransactionManager
encounters an unexpected error condition
-
getStatus
public int getStatus() throws SystemException
Returns the status of the transaction associated with the current thread.- Specified by:
getStatus
in interfaceTransactionManager
- Returns:
- the transaction status expressed as the value of one of
the
int
constants in theStatus
class; if no transaction is associated with the current thread, this method returnsStatus.STATUS_NO_TRANSACTION
- Throws:
SystemException
- if thisTransactionManager
encounters an unexpected error condition- See Also:
Status
-
getTransaction
public Transaction getTransaction() throws SystemException
Returns theTransaction
object that represents the transaction context of the calling thread.This method never returns
null
.- Specified by:
getTransaction
in interfaceTransactionManager
- Returns:
- the
Transaction
object representing the transaction associated with the calling thread; nevernull
- Throws:
SystemException
- if thisTransactionManager
encounters an unexpected error condition
-
resume
public void resume(Transaction transaction) throws InvalidTransactionException, SystemException
Resumes the transaction context association of the calling thread with the transaction represented by the suppliedTransaction
object.When this method returns, the calling thread is associated with the transaction context specified.
- Specified by:
resume
in interfaceTransactionManager
- Parameters:
transaction
- theTransaction
representing the transaction to be resumed; must not benull
- Throws:
InvalidTransactionException
- iftransaction
is invalidIllegalStateException
- if the thread is already associated with another transactionSystemException
- if thisTransactionManager
encounters an unexpected error condition
-
rollback
public void rollback() throws 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 interfaceTransactionManager
- Throws:
SecurityException
- if the thread is not allowed to roll back the transactionIllegalStateException
- if the current thread is not associated with a transactionSystemException
- if thisTransactionManager
encounters an unexpected error condition
-
setRollbackOnly
public void setRollbackOnly() throws 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 interfaceTransactionManager
- Throws:
IllegalStateException
- if the current thread is not associated with a transactionSystemException
- if thisTransactionManager
encounters an unexpected error condition
-
setTransactionTimeout
public void setTransactionTimeout(int seconds) throws SystemException
Sets 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:
setTransactionTimeout
in interfaceTransactionManager
- Parameters:
seconds
- the timeout in seconds; if the value is zero, the transaction service restores the default value; if the value is negative aSystemException
is thrown- Throws:
SystemException
- if thisTransactionManager
encounters an unexpected error condition or ifseconds
is less than zero
-
suspend
public Transaction suspend() throws SystemException
Suspends the transaction currently associated with the calling thread and returns aTransaction
that represents the transaction context being suspended, ornull
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 interfaceTransactionManager
- Returns:
- a
Transaction
representing the suspended transaction, ornull
- Throws:
SystemException
- if thisTransactionManager
encounters an unexpected error condition
-
-