E - the specific ApplicationEvent subclass to listen topublic class TransactionalApplicationListenerAdapter<E extends org.springframework.context.ApplicationEvent> extends Object implements TransactionalApplicationListener<E>, org.springframework.core.Ordered
TransactionalApplicationListener adapter that delegates the processing of
an event to a target ApplicationListener instance. Supports the exact
same features as any regular ApplicationListener but is aware of the
transactional context of the event publisher.
For simple PayloadApplicationEvent handling,
consider the TransactionalApplicationListener.forPayload(java.util.function.Consumer<T>) factory methods
as a convenient alternative to custom usage of this adapter class.
TransactionalApplicationListener,
TransactionalEventListener,
TransactionalApplicationListenerMethodAdapterTransactionalApplicationListener.SynchronizationCallback| Constructor and Description |
|---|
TransactionalApplicationListenerAdapter(org.springframework.context.ApplicationListener<E> targetListener)
Construct a new TransactionalApplicationListenerAdapter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCallback(TransactionalApplicationListener.SynchronizationCallback callback)
Add a callback to be invoked on processing within transaction synchronization,
i.e.
|
String |
getListenerId()
Return an id to identify the listener with.
|
int |
getOrder()
Return the synchronization order for the listener.
|
TransactionPhase |
getTransactionPhase()
Return the transaction phase to invoke the listener in.
|
void |
onApplicationEvent(E event) |
void |
processEvent(E event)
Immediately process the given
ApplicationEvent. |
void |
setListenerId(String listenerId)
Specify an id to identify the listener with.
|
void |
setOrder(int order)
Specify the synchronization order for the listener.
|
void |
setTransactionPhase(TransactionPhase transactionPhase)
Specify the transaction phase to invoke the listener in.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforPayload, forPayloadpublic TransactionalApplicationListenerAdapter(org.springframework.context.ApplicationListener<E> targetListener)
targetListener - the actual listener to invoke in the specified transaction phasesetTransactionPhase(org.springframework.transaction.event.TransactionPhase),
TransactionalApplicationListener.forPayload(java.util.function.Consumer<T>)public void setOrder(int order)
public int getOrder()
getOrder in interface org.springframework.core.OrderedgetOrder in interface TransactionalApplicationListener<E extends org.springframework.context.ApplicationEvent>TransactionSynchronization.getOrder()public void setTransactionPhase(TransactionPhase transactionPhase)
The default is TransactionPhase.AFTER_COMMIT.
public TransactionPhase getTransactionPhase()
getTransactionPhase in interface TransactionalApplicationListener<E extends org.springframework.context.ApplicationEvent>public void setListenerId(String listenerId)
The default is an empty String.
public String getListenerId()
getListenerId in interface TransactionalApplicationListener<E extends org.springframework.context.ApplicationEvent>SmartApplicationListener.getListenerId(),
TransactionalEventListener.id(),
TransactionalApplicationListener.addCallback(org.springframework.transaction.event.TransactionalApplicationListener.SynchronizationCallback)public void addCallback(TransactionalApplicationListener.SynchronizationCallback callback)
TransactionalApplicationListenerTransactionalApplicationListener.processEvent(E) is being triggered during actual transactions.addCallback in interface TransactionalApplicationListener<E extends org.springframework.context.ApplicationEvent>callback - the synchronization callback to applypublic void processEvent(E event)
TransactionalApplicationListenerApplicationEvent. In contrast to
ApplicationListener.onApplicationEvent(ApplicationEvent), a call to this method will
directly process the given event without deferring it to the associated
transaction phase.processEvent in interface TransactionalApplicationListener<E extends org.springframework.context.ApplicationEvent>event - the event to process through the target listener implementation