The Spring Framework

org.springframework.transaction.jta
Class SpringJtaSynchronizationAdapter

java.lang.Object
  extended by org.springframework.transaction.jta.SpringJtaSynchronizationAdapter
All Implemented Interfaces:
Synchronization

public class SpringJtaSynchronizationAdapter
extends Object
implements Synchronization

Adapter that implements the JTA Synchronization interface delegating to an underlying Spring TransactionSynchronization.

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

Since:
2.0
Author:
Juergen Hoeller
See Also:
Transaction.registerSynchronization(javax.transaction.Synchronization), TransactionSynchronization

Field Summary
protected static Log logger
           
 
Constructor Summary
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 Summary
 void afterCompletion(int status)
          JTA afterCompletion callback: invoked after commit/rollback.
 void beforeCompletion()
          JTA beforeCompletion callback: just invoked on commit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Log logger
Constructor Detail

SpringJtaSynchronizationAdapter

public SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization,
                                       UserTransaction jtaUserTransaction)
Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.

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)

SpringJtaSynchronizationAdapter

public SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization,
                                       TransactionManager jtaTransactionManager)
Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.

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 Detail

beforeCompletion

public void beforeCompletion()
JTA beforeCompletion callback: just invoked on commit.

In case of an exception, the JTA transaction gets set to rollback-only.

Specified by:
beforeCompletion in interface Synchronization
See Also:
TransactionSynchronization.beforeCommit(boolean)

afterCompletion

public void afterCompletion(int status)
JTA afterCompletion callback: invoked after commit/rollback.

Needs to invoke SpringSessionSynchronization's beforeCompletion at this late stage, as there's no corresponding callback with JTA.

Specified by:
afterCompletion in interface Synchronization
See Also:
TransactionSynchronization.beforeCompletion(), TransactionSynchronization.afterCompletion(int)

The Spring Framework

Copyright © 2002-2006 The Spring Framework.