Top Description Inners Fields Constructors Methods
org.springframework.transaction.support

public abstract Class TransactionSynchronizationUtils

extends Object
Class Inheritance
Imports
java.util.List, org.apache.commons.logging.Log, .LogFactory, org.springframework.aop.scope.ScopedObject, org.springframework.core.InfrastructureProxy, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils

Utility methods for triggering specific TransactionSynchronization callback methods on all currently registered synchronizations.
Author
Juergen Hoeller
Since
2.0
See Also
TransactionSynchronization, TransactionSynchronizationManager#getSynchronizations()

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
TransactionSynchronizationUtils.ScopedProxyUnwrapper

Inner class to avoid hard-coded dependency on AOP module.

Field Summary

Modifier and TypeField and Description
private static final boolean
private static final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
invokeAfterCommit(List<TransactionSynchronization>
a List of TransactionSynchronization objects
synchronizations
)

Actually invoke the afterCommit methods of the given Spring TransactionSynchronization objects.

public static void
invokeAfterCompletion(List<TransactionSynchronization>
a List of TransactionSynchronization objects
synchronizations
,
int
the completion status according to the constants in the TransactionSynchronization interface
completionStatus
)

Actually invoke the afterCompletion methods of the given Spring TransactionSynchronization objects.

public static boolean
sameResourceFactory(ResourceTransactionManager tm, Object resourceFactory)

Check whether the given resource transaction manager refers to the given (underlying) resource factory.

public static void
triggerAfterCommit()

Trigger afterCommit callbacks on all currently registered synchronizations.

public static void
triggerAfterCompletion(int
the completion status according to the constants in the TransactionSynchronization interface
completionStatus
)

Trigger afterCompletion callbacks on all currently registered synchronizations.

public static void
triggerBeforeCommit(boolean
whether the transaction is defined as read-only transaction
readOnly
)

Trigger beforeCommit callbacks on all currently registered synchronizations.

public static void
triggerBeforeCompletion()

Trigger beforeCompletion callbacks on all currently registered synchronizations.

public static void
triggerFlush()

Trigger flush callbacks on all currently registered synchronizations.

public static Object
unwrapResourceIfNecessary(Object resource)

Unwrap the given resource handle if necessary; otherwise return the given handle as-is.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aopAvailableback to summary
private static final boolean aopAvailable
loggerback to summary
private static final Log logger

Constructor Detail

TransactionSynchronizationUtilsback to summary
public TransactionSynchronizationUtils()

Method Detail

invokeAfterCommitback to summary
public static void invokeAfterCommit(List<TransactionSynchronization> synchronizations)

Actually invoke the afterCommit methods of the given Spring TransactionSynchronization objects.

Parameters
synchronizations:List<TransactionSynchronization>

a List of TransactionSynchronization objects

See Also
TransactionSynchronization#afterCommit()
invokeAfterCompletionback to summary
public static void invokeAfterCompletion(List<TransactionSynchronization> synchronizations, int completionStatus)

Actually invoke the afterCompletion methods of the given Spring TransactionSynchronization objects.

Parameters
synchronizations:List<TransactionSynchronization>

a List of TransactionSynchronization objects

completionStatus:int

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
sameResourceFactoryback to summary
public static boolean sameResourceFactory(ResourceTransactionManager tm, Object resourceFactory)

Check whether the given resource transaction manager refers to the given (underlying) resource factory.

See Also
ResourceTransactionManager#getResourceFactory(), InfrastructureProxy#getWrappedObject()
triggerAfterCommitback to summary
public static void triggerAfterCommit()

Trigger afterCommit callbacks on all currently registered synchronizations.

Exceptions
RuntimeException:
if thrown by a afterCommit callback
See Also
TransactionSynchronizationManager#getSynchronizations(), TransactionSynchronization#afterCommit()
triggerAfterCompletionback to summary
public static void triggerAfterCompletion(int completionStatus)

Trigger afterCompletion callbacks on all currently registered synchronizations.

Parameters
completionStatus:int

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
triggerBeforeCommitback to summary
public static void triggerBeforeCommit(boolean readOnly)

Trigger beforeCommit callbacks on all currently registered synchronizations.

Parameters
readOnly:boolean

whether the transaction is defined as read-only transaction

Exceptions
RuntimeException:
if thrown by a beforeCommit callback
See Also
TransactionSynchronization#beforeCommit(boolean)
triggerBeforeCompletionback to summary
public static void triggerBeforeCompletion()

Trigger beforeCompletion callbacks on all currently registered synchronizations.

See Also
TransactionSynchronization#beforeCompletion()
triggerFlushback to summary
public static void triggerFlush()

Trigger flush callbacks on all currently registered synchronizations.

Exceptions
RuntimeException:
if thrown by a flush callback
See Also
TransactionSynchronization#flush()
unwrapResourceIfNecessaryback to summary
public static Object unwrapResourceIfNecessary(Object resource)

Unwrap the given resource handle if necessary; otherwise return the given handle as-is.

Since
5.3.4
See Also
InfrastructureProxy#getWrappedObject()
org.springframework.transaction.support back to summary

private Class TransactionSynchronizationUtils.ScopedProxyUnwrapper

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.transaction.support.TransactionSynchronizationUtils.ScopedProxyUnwrapper

Inner class to avoid hard-coded dependency on AOP module.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ScopedProxyUnwrapperback to summary
private ScopedProxyUnwrapper()

Method Detail

unwrapIfNecessaryback to summary
public static Object unwrapIfNecessary(Object resource)