Package org.springframework.transaction.event

# Class TransactionalApplicationListenerMethodAdapter

java.lang.Object
org.springframework.context.event.ApplicationListenerMethodAdapter
org.springframework.transaction.event.TransactionalApplicationListenerMethodAdapter

All Implemented Interfaces:
  `EventListener`, `org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>`, `org.springframework.context.event.GenericApplicationListener`, `org.springframework.context.event.SmartApplicationListener`, `org.springframework.core.Ordered`, `TransactionalApplicationListener<org.springframework.context.ApplicationEvent>`

public class TransactionalApplicationListenerMethodAdapter extends org.springframework.context.event.ApplicationListenerMethodAdapter implements TransactionalApplicationListener<org.springframework.context.ApplicationEvent>
`GenericApplicationListener` adapter that delegates the processing of an event to a `TransactionalEventListener` annotated method. Supports the exact same features as any regular `EventListener` annotated method but is aware of the transactional context of the event publisher.

Processing of `TransactionalEventListener` is enabled automatically when Spring's transaction management is enabled. For other cases, registering a bean of type `TransactionalEventListenerFactory` is required.

Since:
  5.3
Author:
  Stephane Nicoll, Juergen Hoeller
See Also:
  - `TransactionalEventListener`
  - `TransactionalApplicationListener`
  - `TransactionalApplicationListenerAdapter`

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.springframework.transaction.event.TransactionalApplicationListener

`TransactionalApplicationListener.SynchronizationCallback`

## Field Summary

### Fields inherited from class org.springframework.context.event.ApplicationListenerMethodAdapter

`logger`

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

## Constructor Summary

Constructors
Constructor
Description
`TransactionalApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, Method method)`
Construct a new TransactionalApplicationListenerMethodAdapter.

## Method Summary

Modifier and Type
Method
Description
`void`
`addCallback(TransactionalApplicationListener.SynchronizationCallback callback)`
Add a callback to be invoked on processing within transaction synchronization, i.e.
`TransactionPhase`
`getTransactionPhase()`
Return the `TransactionPhase` in which the listener will be invoked.
`void`
`onApplicationEvent(org.springframework.context.ApplicationEvent event)`

### Methods inherited from class org.springframework.context.event.ApplicationListenerMethodAdapter

`doInvoke, getCondition, getDefaultListenerId, getDetailedErrorMessage, getListenerId, getOrder, getTargetBean, getTargetMethod, handleAsyncError, handleResult, isDefaultExecution, processEvent, resolveArguments, shouldHandle, supportsEventType, supportsSourceType, toString`

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

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

### Methods inherited from interface org.springframework.context.event.GenericApplicationListener

`supportsEventType`

### Methods inherited from interface org.springframework.transaction.event.TransactionalApplicationListener

`getListenerId, getOrder, processEvent, supportsAsyncExecution`

## Constructor Details

### TransactionalApplicationListenerMethodAdapter

public TransactionalApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, Method method)
Construct a new TransactionalApplicationListenerMethodAdapter.

Parameters:
  `beanName` - the name of the bean to invoke the listener method on
  `targetClass` - the target class that the method is declared on
  `method` - the listener method to invoke

## Method Details

### getTransactionPhase

public TransactionPhase getTransactionPhase()
Description copied from interface: `TransactionalApplicationListener`
Return the `TransactionPhase` in which the listener will be invoked.

The default phase is `TransactionPhase.AFTER_COMMIT`.

Specified by:
  `getTransactionPhase` in interface `TransactionalApplicationListener<org.springframework.context.ApplicationEvent>`

### addCallback

public void addCallback(TransactionalApplicationListener.SynchronizationCallback callback)
Description copied from interface: `TransactionalApplicationListener`
Add a callback to be invoked on processing within transaction synchronization, i.e. when `TransactionalApplicationListener.processEvent(E)` is being triggered during actual transactions.

Specified by:
  `addCallback` in interface `TransactionalApplicationListener<org.springframework.context.ApplicationEvent>`
Parameters:
  `callback` - the synchronization callback to apply

### onApplicationEvent

public void onApplicationEvent(org.springframework.context.ApplicationEvent event)

Specified by:
  `onApplicationEvent` in interface `org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>`
Overrides:
  `onApplicationEvent` in class `org.springframework.context.event.ApplicationListenerMethodAdapter`