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
ConstructorsConstructorDescriptionTransactionalEventListeners(Collection<ApplicationListener<?>> listeners) Creates a newPersistentApplicationEventMulticaster.TransactionalEventListenersinstance by filtering all elements implementingTransactionalApplicationListener. -
Method Summary
Modifier and TypeMethodDescriptionvoiddoWithListener(String identifier, Consumer<TransactionalApplicationListener<ApplicationEvent>> callback) Invokes the givenConsumerfor the listener with the given identifier.voidforEach(Consumer<TransactionalApplicationListener<?>> callback) Invokes the givenConsumerfor all transactional event listeners.forPhase(TransactionPhase phase) Returns allPersistentApplicationEventMulticaster.TransactionalEventListenersfor the givenTransactionPhase.voidExecutes the given consumer only if there are actual listeners available.stream()Returns all transactional event listeners.
-
Constructor Details
-
TransactionalEventListeners
Creates a newPersistentApplicationEventMulticaster.TransactionalEventListenersinstance by filtering all elements implementingTransactionalApplicationListener.- Parameters:
listeners- must not be null.
-
-
Method Details
-
forPhase
public PersistentApplicationEventMulticaster.TransactionalEventListeners forPhase(TransactionPhase phase) Returns allPersistentApplicationEventMulticaster.TransactionalEventListenersfor the givenTransactionPhase.- Parameters:
phase- must not be null.- Returns:
- will never be null.
-
forEach
Invokes the givenConsumerfor 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 givenConsumerfor the listener with the given identifier.- Parameters:
identifier- must not be null or empty.callback- must not be null.
-