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,
TransactionalApplicationListenerAdapterTransactionalApplicationListener.SynchronizationCallbackloggerHIGHEST_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.
|
protected String |
getDefaultListenerId()
Determine the default id for the target listener, to be applied in case of
no
annotation-specified id value. |
String |
getListenerId()
Return an identifier for the listener to be able to refer to it individually.
|
TransactionPhase |
getTransactionPhase()
Return the
TransactionPhase in which the listener will be invoked. |
void |
onApplicationEvent(ApplicationEvent event)
Handle an application event.
|
doInvoke, getCondition, getDetailedErrorMessage, getOrder, getTargetBean, getTargetMethod, handleAsyncError, handleResult, processEvent, resolveArguments, supportsEventType, supportsSourceType, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforPayload, forPayload, getOrder, processEventpublic 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()
TransactionalApplicationListenerTransactionPhase in which the listener will be invoked.
The default phase is TransactionPhase.AFTER_COMMIT.
getTransactionPhase in interface TransactionalApplicationListener<ApplicationEvent>public String getListenerId()
TransactionalApplicationListenerIt might be necessary for specific completion callback implementations to provide a specific id, whereas for other scenarios an empty String (as the common default value) is acceptable as well.
protected String getDefaultListenerId()
annotation-specified id value.
The default implementation builds a method name with parameter types.
getListenerId()public void addCallback(TransactionalApplicationListener.SynchronizationCallback callback)
TransactionalApplicationListenerTransactionalApplicationListener.processEvent(E) is being triggered during actual transactions.addCallback in interface TransactionalApplicationListener<ApplicationEvent>callback - the synchronization callback to applypublic void onApplicationEvent(ApplicationEvent event)
ApplicationListeneronApplicationEvent in interface ApplicationListener<ApplicationEvent>onApplicationEvent in class ApplicationListenerMethodAdapterevent - the event to respond to