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.
TransactionalEventListener
,
TransactionalApplicationListener
,
TransactionalApplicationListenerAdapter
TransactionalApplicationListener.SynchronizationCallback
logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
TransactionalApplicationListenerMethodAdapter(String beanName,
Class<?> targetClass,
Method method)
Construct a new TransactionalApplicationListenerMethodAdapter.
|
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.
|
doInvoke, getCondition, getDefaultListenerId, getDetailedErrorMessage, getListenerId, getOrder, getTargetBean, getTargetMethod, handleAsyncError, handleResult, processEvent, resolveArguments, supportsEventType, supportsSourceType, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forPayload, forPayload, getListenerId, getOrder, processEvent
supportsEventType
public TransactionalApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, Method method)
beanName
- the name of the bean to invoke the listener method ontargetClass
- the target class that the method is declared onmethod
- the listener method to invokepublic TransactionPhase getTransactionPhase()
TransactionalApplicationListener
TransactionPhase
in which the listener will be invoked.
The default phase is TransactionPhase.AFTER_COMMIT
.
getTransactionPhase
in interface TransactionalApplicationListener<ApplicationEvent>
public void addCallback(TransactionalApplicationListener.SynchronizationCallback callback)
TransactionalApplicationListener
TransactionalApplicationListener.processEvent(E)
is being triggered during actual transactions.addCallback
in interface TransactionalApplicationListener<ApplicationEvent>
callback
- the synchronization callback to applypublic void onApplicationEvent(ApplicationEvent event)
ApplicationListener
onApplicationEvent
in interface ApplicationListener<ApplicationEvent>
onApplicationEvent
in class ApplicationListenerMethodAdapter
event
- the event to respond to