Class PersistentApplicationEventMulticaster.TransactionalEventListeners
java.lang.Object
org.springframework.modulith.events.support.PersistentApplicationEventMulticaster.TransactionalEventListeners
- Enclosing class:
- PersistentApplicationEventMulticaster
First-class collection to work with transactional event listeners, i.e.
ApplicationListener
instances that
implement TransactionalApplicationListener
.- Author:
- Oliver Drotbohm
- See Also:
-
Constructor Summary
ConstructorDescriptionTransactionalEventListeners
(Collection<ApplicationListener<?>> listeners) Creates a newPersistentApplicationEventMulticaster.TransactionalEventListeners
instance by filtering all elements implementingTransactionalApplicationListener
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
doWithListener
(String identifier, Consumer<TransactionalApplicationListener<ApplicationEvent>> callback) Invokes the givenConsumer
for the listener with the given identifier.void
forEach
(Consumer<TransactionalApplicationListener<?>> callback) Invokes the givenConsumer
for all transactional event listeners.forPhase
(TransactionPhase phase) Returns allPersistentApplicationEventMulticaster.TransactionalEventListeners
for the givenTransactionPhase
.boolean
void
Executes the given consumer only if there are actual listeners available.stream()
Returns all transactional event listeners.
-
Constructor Details
-
TransactionalEventListeners
Creates a newPersistentApplicationEventMulticaster.TransactionalEventListeners
instance by filtering all elements implementingTransactionalApplicationListener
.- Parameters:
listeners
- must not be null.
-
-
Method Details
-
forPhase
public PersistentApplicationEventMulticaster.TransactionalEventListeners forPhase(TransactionPhase phase) Returns allPersistentApplicationEventMulticaster.TransactionalEventListeners
for the givenTransactionPhase
.- Parameters:
phase
- must not be null.- Returns:
- will never be null.
-
forEach
Invokes the givenConsumer
for all transactional event listeners.- Parameters:
callback
- must not be null.
-
ifPresent
public void ifPresent(Consumer<Stream<TransactionalApplicationListener<ApplicationEvent>>> metadata) Executes the given consumer only if there are actual listeners available.- Parameters:
metadata
- must not be null.
-
stream
Returns all transactional event listeners.- Returns:
- will never be null.
-
doWithListener
public void doWithListener(String identifier, Consumer<TransactionalApplicationListener<ApplicationEvent>> callback) Invokes the givenConsumer
for the listener with the given identifier.- Parameters:
identifier
- must not be null or empty.callback
- must not be null.
-
hasListeners
public boolean hasListeners()
-