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
logger
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionTransactionalApplicationListenerMethodAdapter
(String beanName, Class<?> targetClass, Method method) Construct a new TransactionalApplicationListenerMethodAdapter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a callback to be invoked on processing within transaction synchronization, i.e.Return theTransactionPhase
in which the listener will be invoked.void
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.context.event.GenericApplicationListener
supportsEventType
Methods 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:TransactionalApplicationListener
Return theTransactionPhase
in which the listener will be invoked.The default phase is
TransactionPhase.AFTER_COMMIT
.- Specified by:
getTransactionPhase
in interfaceTransactionalApplicationListener<ApplicationEvent>
-
addCallback
Description copied from interface:TransactionalApplicationListener
Add a callback to be invoked on processing within transaction synchronization, i.e. whenTransactionalApplicationListener.processEvent(E)
is being triggered during actual transactions.- Specified by:
addCallback
in interfaceTransactionalApplicationListener<ApplicationEvent>
- Parameters:
callback
- the synchronization callback to apply
-
onApplicationEvent
Description copied from interface:ApplicationListener
Handle an application event.- Specified by:
onApplicationEvent
in interfaceApplicationListener<ApplicationEvent>
- Overrides:
onApplicationEvent
in classApplicationListenerMethodAdapter
- Parameters:
event
- the event to respond to
-