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:
-
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
loggerFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionTransactionalApplicationListenerMethodAdapter(String beanName, Class<?> targetClass, Method method) Construct a new TransactionalApplicationListenerMethodAdapter. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a callback to be invoked on processing within transaction synchronization, i.e.Return theTransactionPhasein which the listener will be invoked.voidHandle 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.event.GenericApplicationListener
supportsEventTypeMethods inherited from interface org.springframework.transaction.event.TransactionalApplicationListener
getListenerId, getOrder, processEvent
-
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 ontargetClass- the target class that the method is declared onmethod- the listener method to invoke
-
-
Method Details
-
getTransactionPhase
Description copied from interface:TransactionalApplicationListenerReturn theTransactionPhasein which the listener will be invoked.The default phase is
TransactionPhase.AFTER_COMMIT.- Specified by:
getTransactionPhasein interfaceTransactionalApplicationListener<ApplicationEvent>
-
addCallback
Description copied from interface:TransactionalApplicationListenerAdd a callback to be invoked on processing within transaction synchronization, i.e. whenTransactionalApplicationListener.processEvent(E)is being triggered during actual transactions.- Specified by:
addCallbackin interfaceTransactionalApplicationListener<ApplicationEvent>- Parameters:
callback- the synchronization callback to apply
-
onApplicationEvent
Description copied from interface:ApplicationListenerHandle an application event.- Specified by:
onApplicationEventin interfaceApplicationListener<ApplicationEvent>- Overrides:
onApplicationEventin classApplicationListenerMethodAdapter- Parameters:
event- the event to respond to
-