TransactionInterceptor
or an AspectJ aspect.
This enables the underlying Spring transaction infrastructure to be used easily to implement an aspect for any aspect system.
Subclasses are responsible for calling methods in this class in the correct order.
If no transaction name has been specified in the TransactionAttribute,
the exposed name will be the fully-qualified class name + "." + method name
(by default).
Uses the Strategy design pattern. A PlatformTransactionManager or
ReactiveTransactionManager implementation will perform the actual transaction
management, and a TransactionAttributeSource (e.g. annotation-based) is used
for determining transaction definitions for a particular class or method.
A transaction aspect is serializable if its TransactionManager and
TransactionAttributeSource are serializable.
PlatformTransactionManager, ReactiveTransactionManager, setTransactionManager, setTransactionAttributes, setTransactionAttributeSource
| Modifier and Type | Class and Description |
|---|---|
| protected static interface | TransactionAspectSupport.CoroutinesInvocationCallback
Coroutines-supporting extension of the callback interface. |
| protected static interface | TransactionAspectSupport.InvocationCallback
Simple callback interface for proceeding with the target invocation. |
| private static class | TransactionAspectSupport.KotlinDelegate
Inner class to avoid a hard dependency on Kotlin at runtime. |
| private static class | TransactionAspectSupport.ReactiveTransactionInfo
Opaque object used to hold transaction information for reactive methods. |
| private class | TransactionAspectSupport.ReactiveTransactionSupport
Delegate for Reactor-based management of transactional methods with a reactive return type. |
| private static class | TransactionAspectSupport.ThrowableHolder
Internal holder class for a Throwable in a callback transaction model. |
| private static class | TransactionAspectSupport.ThrowableHolderException
Internal holder class for a Throwable, used as a RuntimeException to be thrown from a TransactionCallback (and subsequently unwrapped again). |
| protected static class | TransactionAspectSupport.TransactionInfo
Opaque object used to hold transaction information. |
| private static class | TransactionAspectSupport.VavrDelegate
Inner class to avoid a hard dependency on the Vavr library at runtime. |
| Modifier and Type | Field and Description |
|---|---|
| private BeanFactory | |
| private static final String | |
| private static final Object | DEFAULT_TRANSACTION_MANAGER_KEY
Key to use to store the default transaction manager. |
| protected final Log | |
| private final ReactiveAdapterRegistry | |
| private static final boolean | reactiveStreamsPresent
Reactive Streams API present on the classpath? |
| private TransactionAttributeSource | |
| private static final ThreadLocal | transactionInfoHolder
Holder to support the |
| private TransactionManager | |
| private String | |
| private final ConcurrentMap | |
| private final ConcurrentMap | |
| private static final boolean | vavrPresent
Vavr library present on the classpath? |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Implements org. |
| private PlatformTransactionManager | |
| protected void | cleanupTransactionInfo(TransactionAspectSupport.
information about the current transaction (may be txInfonull)Reset the TransactionInfo ThreadLocal. |
| protected void | |
| protected void | commitTransactionAfterReturning(TransactionAspectSupport.
information about the current transaction txInfoExecute after successful completion of call, but not after an exception was handled. |
| protected void | completeTransactionAfterThrowing(TransactionAspectSupport.
information about the current transaction txInfo,throwable encountered ex)Handle a throwable, completing the transaction. |
| protected TransactionAspectSupport. | Returns: a TransactionInfo object, whether a transaction was created. ThehasTransaction() method on TransactionInfo can be used to
tell if there was a transaction created.the TransactionAttribute (may be txAttr, final String null)the fully qualified method name
(used for monitoring and logging purposes) joinpointIdentification)Create a transaction if necessary based on the given TransactionAttribute. |
| protected static TransactionAspectSupport. | Returns: the TransactionInfo bound to this thread, ornull if noneSubclasses can use this to return the current TransactionInfo. |
| public static TransactionStatus | |
| private TransactionManager | |
| protected TransactionManager | determineTransactionManager(TransactionAttribute txAttr)
Determine the specific transaction manager to use for the given transaction. |
| protected final BeanFactory | |
| public TransactionAttributeSource | |
| public TransactionManager | |
| protected final String | |
| protected Object | Returns: the return value of the method, if anythe Method being invoked method, Class<?> the target class that we're invoking the method on targetClass, final TransactionAspectSupport.the callback to use for proceeding with the target invocation invocationGeneral delegate for around-advice-based subclasses, delegating to several other template methods on this class. |
| private String | |
| protected String | Returns: a String representation identifying this methodthe method we're interested in method, Class<?> the class that the method is being invoked on targetClass)Convenience method to return a String representation of this Method for use in logging. |
| protected TransactionAspectSupport. | Returns: the prepared TransactionInfo objectthe TransactionAttribute (may be txAttr, String null)the fully qualified method name
(used for monitoring and logging purposes) joinpointIdentification, TransactionStatus the TransactionStatus for the current transaction status)Prepare a TransactionInfo for the given attribute and status object. |
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Implements org. TransactionManager beans.
|
| public void | setTransactionAttributes(Properties transactionAttributes)
Set properties with method names as keys and transaction attribute descriptors (parsed via TransactionAttributeEditor) as values: e.g. key = "myMethod", value = "PROPAGATION_REQUIRED,readOnly". |
| public void | setTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource)
Set the transaction attribute source which is used to find transaction attributes. |
| public void | setTransactionAttributeSources(TransactionAttributeSource... transactionAttributeSources)
Set multiple transaction attribute sources which are used to find transaction attributes. |
| public void | setTransactionManager(TransactionManager transactionManager)
Specify the default transaction manager to use to drive transactions. |
| public void | setTransactionManagerBeanName(String transactionManagerBeanName)
Specify the name of the default transaction manager bean. |