spring-framework / org.springframework.transaction.jta / SpringJtaSynchronizationAdapter

SpringJtaSynchronizationAdapter

open class SpringJtaSynchronizationAdapter : Synchronization

Adapter that implements the JTA javax.transaction.Synchronization interface delegating to an underlying Spring org.springframework.transaction.support.TransactionSynchronization.

Useful for synchronizing Spring resource management code with plain JTA / EJB CMT transactions, despite the original code being built for Spring transaction synchronization.

Author
Juergen Hoeller

Since
2.0

See Also
javax.transaction.Transaction#registerSynchronizationorg.springframework.transaction.support.TransactionSynchronization

Constructors

<init>

SpringJtaSynchronizationAdapter(springSynchronization: TransactionSynchronization)

Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.

SpringJtaSynchronizationAdapter(springSynchronization: TransactionSynchronization, jtaUserTransaction: UserTransaction)
SpringJtaSynchronizationAdapter(springSynchronization: TransactionSynchronization, jtaTransactionManager: TransactionManager)

Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.

Note that this adapter will never perform a rollback-only call on WebLogic, since WebLogic Server is known to automatically mark the transaction as rollback-only in case of a beforeCompletion exception. Hence, on WLS, this constructor is equivalent to the single-arg constructor.

Functions

afterCompletion

open fun afterCompletion(status: Int): Unit

JTA afterCompletion callback: invoked after commit/rollback.

Needs to invoke the Spring synchronization's beforeCompletion at this late stage in case of a rollback, since there is no corresponding callback with JTA.

beforeCompletion

open fun beforeCompletion(): Unit

JTA beforeCompletion callback: just invoked before commit.

In case of an exception, the JTA transaction will be marked as rollback-only.