Class SpringJtaSynchronizationAdapter
- All Implemented Interfaces:
- Synchronization
Synchronization
 interface delegating to an underlying Spring
 TransactionSynchronization.
 Useful for synchronizing Spring resource management code with plain JTA / EJB CMT transactions, despite the original code being built for Spring transaction synchronization.
- Since:
- 2.0
- Author:
- Juergen Hoeller
- See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionSpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization) Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization, TransactionManager jtaTransactionManager) Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization, UserTransaction jtaUserTransaction) Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.
- 
Method SummaryModifier and TypeMethodDescriptionvoidafterCompletion(int status) JTAafterCompletioncallback: invoked after commit/rollback.voidJTAbeforeCompletioncallback: just invoked before commit.
- 
Field Details- 
logger
 
- 
- 
Constructor Details- 
SpringJtaSynchronizationAdapterCreate a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.- Parameters:
- springSynchronization- the Spring TransactionSynchronization to delegate to
 
- 
SpringJtaSynchronizationAdapterpublic SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization, @Nullable UserTransaction jtaUserTransaction) 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 beforeCompletionexception. Hence, on WLS, this constructor is equivalent to the single-arg constructor.- Parameters:
- springSynchronization- the Spring TransactionSynchronization to delegate to
- jtaUserTransaction- the JTA UserTransaction to use for rollback-only setting in case of an exception thrown in- beforeCompletion(can be omitted if the JTA provider itself marks the transaction rollback-only in such a scenario, which is required by the JTA specification as of JTA 1.1).
 
- 
SpringJtaSynchronizationAdapterpublic SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization, @Nullable TransactionManager jtaTransactionManager) 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 beforeCompletionexception. Hence, on WLS, this constructor is equivalent to the single-arg constructor.- Parameters:
- springSynchronization- the Spring TransactionSynchronization to delegate to
- jtaTransactionManager- the JTA TransactionManager to use for rollback-only setting in case of an exception thrown in- beforeCompletion(can be omitted if the JTA provider itself marks the transaction rollback-only in such a scenario, which is required by the JTA specification as of JTA 1.1)
 
 
- 
- 
Method Details- 
beforeCompletionpublic void beforeCompletion()JTAbeforeCompletioncallback: just invoked before commit.In case of an exception, the JTA transaction will be marked as rollback-only. - Specified by:
- beforeCompletionin interface- Synchronization
- See Also:
 
- 
afterCompletionpublic void afterCompletion(int status) JTAafterCompletioncallback: invoked after commit/rollback.Needs to invoke the Spring synchronization's beforeCompletionat this late stage in case of a rollback, since there is no corresponding callback with JTA.- Specified by:
- afterCompletionin interface- Synchronization
- See Also:
 
 
-