org.springframework.transaction.event

## Class TransactionalApplicationListenerMethodAdapter

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

- All Implemented Interfaces:
    EventListener, ApplicationListener<ApplicationEvent>, GenericApplicationListener, SmartApplicationListener, Ordered, TransactionalApplicationListener<ApplicationEvent>

      public class TransactionalApplicationListenerMethodAdapter
      extends ApplicationListenerMethodAdapter
      implements TransactionalApplicationListener<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 and Description
    `TransactionalApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, Method method)` Construct a new TransactionalApplicationListenerMethodAdapter.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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(ApplicationEvent event)` Handle an application event.

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

      `doInvoke, getCondition, getDefaultListenerId, getDetailedErrorMessage, getListenerId, getOrder, getTargetBean, getTargetMethod, handleAsyncError, handleResult, processEvent, resolveArguments, 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.transaction.event.TransactionalApplicationListener

      `forPayload, forPayload, getListenerId, getOrder, processEvent`

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

      `supportsEventType`

- - ### Constructor Detail

    - #### 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 Detail

    - #### 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<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<ApplicationEvent>`
      Parameters:
        `callback` - the synchronization callback to apply

    - #### onApplicationEvent

          public void onApplicationEvent(ApplicationEvent event)

      Description copied from interface: `ApplicationListener`
      Handle an application event.
      Specified by:
        `onApplicationEvent` in interface `ApplicationListener<ApplicationEvent>`
      Overrides:
        `onApplicationEvent` in class `ApplicationListenerMethodAdapter`
      Parameters:
        `event` - the event to respond to