Package org.springframework.transaction.interceptor

# Class TransactionInterceptor

java.lang.Object
org.springframework.transaction.interceptor.TransactionAspectSupport
org.springframework.transaction.interceptor.TransactionInterceptor

All Implemented Interfaces:
  `Serializable`, `org.aopalliance.aop.Advice`, `org.aopalliance.intercept.Interceptor`, `org.aopalliance.intercept.MethodInterceptor`, `org.springframework.beans.factory.Aware`, `org.springframework.beans.factory.BeanFactoryAware`, `org.springframework.beans.factory.InitializingBean`

public class TransactionInterceptor extends TransactionAspectSupport implements org.aopalliance.intercept.MethodInterceptor, Serializable
AOP Alliance MethodInterceptor for declarative transaction management using the common Spring transaction infrastructure (`PlatformTransactionManager`/ `ReactiveTransactionManager`).

Derives from the `TransactionAspectSupport` class which contains the integration with Spring's underlying transaction API. TransactionInterceptor simply calls the relevant superclass methods such as `TransactionAspectSupport.invokeWithinTransaction(java.lang.reflect.Method, java.lang.Class<?>, org.springframework.transaction.interceptor.TransactionAspectSupport.InvocationCallback)` in the correct order.

TransactionInterceptors are thread-safe.

Author:
  Rod Johnson, Juergen Hoeller, Sebastien Deleuze
See Also:
  - `TransactionProxyFactoryBean`
  - `ProxyFactoryBean`
  - `ProxyFactory`
  - Serialized Form

## Nested Class Summary

## Nested classes/interfaces inherited from class org.springframework.transaction.interceptor.TransactionAspectSupport

`TransactionAspectSupport.InvocationCallback, TransactionAspectSupport.TransactionInfo`

## Field Summary

### Fields inherited from class org.springframework.transaction.interceptor.TransactionAspectSupport

`logger`

## Constructor Summary

Constructors
Constructor
Description
`TransactionInterceptor()`
Create a new TransactionInterceptor.
`TransactionInterceptor(PlatformTransactionManager ptm, Properties attributes)`
Deprecated.
as of 5.2.5, in favor of `TransactionAspectSupport.setTransactionAttributes(Properties)`
`TransactionInterceptor(PlatformTransactionManager ptm, TransactionAttributeSource tas)`
Deprecated.
as of 5.2.5, in favor of `TransactionInterceptor(TransactionManager, TransactionAttributeSource)`
`TransactionInterceptor(TransactionManager ptm, TransactionAttributeSource tas)`
Create a new TransactionInterceptor.

## Method Summary

Modifier and Type
Method
Description
`Object`
`invoke(org.aopalliance.intercept.MethodInvocation invocation)`

### Methods inherited from class org.springframework.transaction.interceptor.TransactionAspectSupport

`afterPropertiesSet, cleanupTransactionInfo, clearTransactionManagerCache, commitTransactionAfterReturning, completeTransactionAfterThrowing, createTransactionIfNecessary, currentTransactionInfo, currentTransactionStatus, determineTransactionManager, determineTransactionManager, getBeanFactory, getTransactionAttributeSource, getTransactionManager, getTransactionManagerBeanName, invokeWithinTransaction, methodIdentification, prepareTransactionInfo, setBeanFactory, setTransactionAttributes, setTransactionAttributeSource, setTransactionAttributeSources, setTransactionManager, setTransactionManagerBeanName`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### TransactionInterceptor

public TransactionInterceptor()
Create a new TransactionInterceptor.

Transaction manager and transaction attributes still need to be set.

See Also:
  - `TransactionAspectSupport.setTransactionManager(org.springframework.transaction.TransactionManager)`
  - `TransactionAspectSupport.setTransactionAttributes(java.util.Properties)`
  - `TransactionAspectSupport.setTransactionAttributeSource(TransactionAttributeSource)`

### TransactionInterceptor

public TransactionInterceptor(TransactionManager ptm, TransactionAttributeSource tas)
Create a new TransactionInterceptor.

Parameters:
  `ptm` - the default transaction manager to perform the actual transaction management
  `tas` - the attribute source to be used to find transaction attributes
Since:
  5.2.5
See Also:
  - `TransactionAspectSupport.setTransactionManager(org.springframework.transaction.TransactionManager)`
  - `TransactionAspectSupport.setTransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource)`

### TransactionInterceptor

@Deprecated public TransactionInterceptor(PlatformTransactionManager ptm, TransactionAttributeSource tas)
Deprecated.
as of 5.2.5, in favor of `TransactionInterceptor(TransactionManager, TransactionAttributeSource)`
Create a new TransactionInterceptor.

Parameters:
  `ptm` - the default transaction manager to perform the actual transaction management
  `tas` - the attribute source to be used to find transaction attributes
See Also:
  - `TransactionAspectSupport.setTransactionManager(org.springframework.transaction.TransactionManager)`
  - `TransactionAspectSupport.setTransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource)`

### TransactionInterceptor

@Deprecated public TransactionInterceptor(PlatformTransactionManager ptm, Properties attributes)
Deprecated.
as of 5.2.5, in favor of `TransactionAspectSupport.setTransactionAttributes(Properties)`
Create a new TransactionInterceptor.

Parameters:
  `ptm` - the default transaction manager to perform the actual transaction management
  `attributes` - the transaction attributes in properties format
See Also:
  - `TransactionAspectSupport.setTransactionManager(org.springframework.transaction.TransactionManager)`
  - `TransactionAspectSupport.setTransactionAttributes(java.util.Properties)`

## Method Details

### invoke

@Nullable public Object invoke(org.aopalliance.intercept.MethodInvocation invocation) throws Throwable

Specified by:
  `invoke` in interface `org.aopalliance.intercept.MethodInterceptor`
Throws:
  `Throwable`