Top Description Fields Constructors Methods
org.springframework.transaction.jta

public Class ManagedTransactionAdapter

extends Object
implements Transaction
Class Inheritance
All Implemented Interfaces
jakarta.transaction.Transaction
Imports
javax.transaction.xa.XAResource, jakarta.transaction.HeuristicMixedException, .HeuristicRollbackException, .RollbackException, .Synchronization, .SystemException, .Transaction, .TransactionManager, org.springframework.util.Assert

Adapter for a managed JTA Transaction handle, taking a JTA jakarta.transaction.TransactionManager reference and creating a JTA jakarta.transaction.Transaction handle for it.
Author
Juergen Hoeller
Since
3.0.2

Field Summary

Modifier and TypeField and Description
private final TransactionManager

Constructor Summary

AccessConstructor and Description
public
ManagedTransactionAdapter(TransactionManager
the JTA TransactionManager to wrap
transactionManager
)

Create a new ManagedTransactionAdapter for the given TransactionManager.

Method Summary

Modifier and TypeMethod and Description
public void
commit()

Implements jakarta.transaction.Transaction.commit.

Complete the transaction represented by this Transaction object.
public boolean
delistResource(XAResource
The XAResource object associated with the resource (connection).
xaRes
,
int
One of the values of TMSUCCESS, TMSUSPEND, or TMFAIL.
flag
)

Implements jakarta.transaction.Transaction.delistResource.

Disassociate the resource specified from the transaction associated with the target Transaction object.
public boolean
enlistResource(XAResource
The XAResource object associated with the resource (connection).
xaRes
)

Implements jakarta.transaction.Transaction.enlistResource.

Enlist the resource specified with the transaction associated with the target Transaction object.
public int
getStatus()

Implements jakarta.transaction.Transaction.getStatus.

Obtain the status of the transaction associated with the target Transaction object.
public final TransactionManager
getTransactionManager()

Return the JTA TransactionManager that this adapter delegates to.

public void
registerSynchronization(Synchronization
The Synchronization object for the transaction associated with the target object.
sync
)

Implements jakarta.transaction.Transaction.registerSynchronization.

Register a synchronization object for the transaction currently associated with the target object.
public void
rollback()

Implements jakarta.transaction.Transaction.rollback.

Rollback the transaction represented by this Transaction object.
public void
setRollbackOnly()

Implements jakarta.transaction.Transaction.setRollbackOnly.

Modify the transaction associated with the target object such that the only possible outcome of the transaction is to roll back the transaction.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

transactionManagerback to summary
private final TransactionManager transactionManager

Constructor Detail

ManagedTransactionAdapterback to summary
public ManagedTransactionAdapter(TransactionManager transactionManager) throws SystemException

Create a new ManagedTransactionAdapter for the given TransactionManager.

Parameters
transactionManager:TransactionManager

the JTA TransactionManager to wrap

Method Detail

commitback to summary
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException

Implements jakarta.transaction.Transaction.commit.

Doc from jakarta.transaction.Transaction.commit.

Complete the transaction represented by this Transaction object.

Annotations
@Override
Exceptions
RollbackException:
Thrown to indicate that the transaction has been rolled back rather than committed.
HeuristicMixedException:
Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.
HeuristicRollbackException:
Thrown to indicate that a heuristic decision was made and that all relevant updates have been rolled back.
SecurityException:
Thrown to indicate that the thread is not allowed to commit the transaction.
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
delistResourceback to summary
public boolean delistResource(XAResource xaRes, int flag) throws SystemException

Implements jakarta.transaction.Transaction.delistResource.

Doc from jakarta.transaction.Transaction.delistResource.

Disassociate the resource specified from the transaction associated with the target Transaction object.

Parameters
xaRes:XAResource

The XAResource object associated with the resource (connection).

flag:int

One of the values of TMSUCCESS, TMSUSPEND, or TMFAIL.

Returns:boolean

true if the resource was delisted successfully; otherwise false.

Annotations
@Override
Exceptions
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
enlistResourceback to summary
public boolean enlistResource(XAResource xaRes) throws RollbackException, SystemException

Implements jakarta.transaction.Transaction.enlistResource.

Doc from jakarta.transaction.Transaction.enlistResource.

Enlist the resource specified with the transaction associated with the target Transaction object.

Parameters
xaRes:XAResource

The XAResource object associated with the resource (connection).

Returns:boolean

true if the resource was enlisted successfully; otherwise false.

Annotations
@Override
Exceptions
RollbackException:
Thrown to indicate that the transaction has been marked for rollback only.
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
getStatusback to summary
public int getStatus() throws SystemException

Implements jakarta.transaction.Transaction.getStatus.

Doc from jakarta.transaction.Transaction.getStatus.

Obtain the status of the transaction associated with the target Transaction object.

Returns:int

The transaction status. If no transaction is associated with the target object, this method returns the Status.NoTransaction value.

Annotations
@Override
Exceptions
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
getTransactionManagerback to summary
public final TransactionManager getTransactionManager()

Return the JTA TransactionManager that this adapter delegates to.

registerSynchronizationback to summary
public void registerSynchronization(Synchronization sync) throws RollbackException, SystemException

Implements jakarta.transaction.Transaction.registerSynchronization.

Doc from jakarta.transaction.Transaction.registerSynchronization.

Register a synchronization object for the transaction currently associated with the target object. The transction manager invokes the beforeCompletion method prior to starting the two-phase transaction commit process. After the transaction is completed, the transaction manager invokes the afterCompletion method.

Parameters
sync:Synchronization

The Synchronization object for the transaction associated with the target object.

Annotations
@Override
Exceptions
RollbackException:
Thrown to indicate that the transaction has been marked for rollback only.
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
rollbackback to summary
public void rollback() throws SystemException

Implements jakarta.transaction.Transaction.rollback.

Doc from jakarta.transaction.Transaction.rollback.

Rollback the transaction represented by this Transaction object.

Annotations
@Override
Exceptions
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.
setRollbackOnlyback to summary
public void setRollbackOnly() throws SystemException

Implements jakarta.transaction.Transaction.setRollbackOnly.

Doc from jakarta.transaction.Transaction.setRollbackOnly.

Modify the transaction associated with the target object such that the only possible outcome of the transaction is to roll back the transaction.

Annotations
@Override
Exceptions
SystemException:
Thrown if the transaction manager encounters an unexpected error condition.