org.springframework.transaction.support
Class TransactionSynchronizationUtils

java.lang.Object
  extended by org.springframework.transaction.support.TransactionSynchronizationUtils

public abstract class TransactionSynchronizationUtils
extends Object

Utility methods for triggering specific TransactionSynchronization callback methods on all currently registered synchronizations.

Since:
2.0
Author:
Juergen Hoeller
See Also:
TransactionSynchronization, TransactionSynchronizationManager.getSynchronizations()

Constructor Summary
TransactionSynchronizationUtils()
           
 
Method Summary
static void invokeAfterCommit(List<TransactionSynchronization> synchronizations)
          Actually invoke the afterCommit methods of the given Spring TransactionSynchronization objects.
static void invokeAfterCompletion(List<TransactionSynchronization> synchronizations, int completionStatus)
          Actually invoke the afterCompletion methods of the given Spring TransactionSynchronization objects.
static boolean sameResourceFactory(ResourceTransactionManager tm, Object resourceFactory)
          Check whether the given resource transaction managers refers to the given (underlying) resource factory.
static void triggerAfterCommit()
          Trigger afterCommit callbacks on all currently registered synchronizations.
static void triggerAfterCompletion(int completionStatus)
          Trigger afterCompletion callbacks on all currently registered synchronizations.
static void triggerBeforeCommit(boolean readOnly)
          Trigger beforeCommit callbacks on all currently registered synchronizations.
static void triggerBeforeCompletion()
          Trigger beforeCompletion callbacks on all currently registered synchronizations.
static void triggerFlush()
          Trigger flush callbacks on all currently registered synchronizations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionSynchronizationUtils

public TransactionSynchronizationUtils()
Method Detail

sameResourceFactory

public static boolean sameResourceFactory(ResourceTransactionManager tm,
                                          Object resourceFactory)
Check whether the given resource transaction managers refers to the given (underlying) resource factory.

See Also:
ResourceTransactionManager.getResourceFactory(), InfrastructureProxy.getWrappedObject()

triggerFlush

public static void triggerFlush()
Trigger flush callbacks on all currently registered synchronizations.

Throws:
RuntimeException - if thrown by a flush callback
See Also:
TransactionSynchronization.flush()

triggerBeforeCommit

public static void triggerBeforeCommit(boolean readOnly)
Trigger beforeCommit callbacks on all currently registered synchronizations.

Parameters:
readOnly - whether the transaction is defined as read-only transaction
Throws:
RuntimeException - if thrown by a beforeCommit callback
See Also:
TransactionSynchronization.beforeCommit(boolean)

triggerBeforeCompletion

public static void triggerBeforeCompletion()
Trigger beforeCompletion callbacks on all currently registered synchronizations.

See Also:
TransactionSynchronization.beforeCompletion()

triggerAfterCommit

public static void triggerAfterCommit()
Trigger afterCommit callbacks on all currently registered synchronizations.

Throws:
RuntimeException - if thrown by a afterCommit callback
See Also:
TransactionSynchronizationManager.getSynchronizations(), TransactionSynchronization.afterCommit()

invokeAfterCommit

public static void invokeAfterCommit(List<TransactionSynchronization> synchronizations)
Actually invoke the afterCommit methods of the given Spring TransactionSynchronization objects.

Parameters:
synchronizations - List of TransactionSynchronization objects
See Also:
TransactionSynchronization.afterCommit()

triggerAfterCompletion

public static void triggerAfterCompletion(int completionStatus)
Trigger afterCompletion callbacks on all currently registered synchronizations.

Parameters:
completionStatus - the completion status according to the constants in the TransactionSynchronization interface
See Also:
TransactionSynchronizationManager.getSynchronizations(), TransactionSynchronization.afterCompletion(int), TransactionSynchronization.STATUS_COMMITTED, TransactionSynchronization.STATUS_ROLLED_BACK, TransactionSynchronization.STATUS_UNKNOWN

invokeAfterCompletion

public static void invokeAfterCompletion(List<TransactionSynchronization> synchronizations,
                                         int completionStatus)
Actually invoke the afterCompletion methods of the given Spring TransactionSynchronization objects.

Parameters:
synchronizations - List of TransactionSynchronization objects
completionStatus - the completion status according to the constants in the TransactionSynchronization interface
See Also:
TransactionSynchronization.afterCompletion(int), TransactionSynchronization.STATUS_COMMITTED, TransactionSynchronization.STATUS_ROLLED_BACK, TransactionSynchronization.STATUS_UNKNOWN