Package io.micronaut.context.event
Interface ApplicationEventPublisher<T>
- Type Parameters:
T- The event type
- All Known Subinterfaces:
ApplicationContext,BeanContext,ConfigurableApplicationContext,ConfigurableBeanContext,InitializableBeanContext
- All Known Implementing Classes:
DefaultApplicationContext,DefaultBeanContext
public interface ApplicationEventPublisher<T>
Interface for classes that publish events received by ApplicationEventListener instances.
Note that this interface is designed for application level, non-blocking synchronous events for decoupling code and is not a replacement for a messaging system
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanisEmpty()Check whether this publisher is empty (i.e.static <K> ApplicationEventPublisher<K>noOp()Returns a no-op instance ofApplicationEventPublisher.voidpublishEvent(T event) Publish the given event.publishEventAsync(T event) Publish the given event.
-
Field Details
-
NO_OP
-
-
Method Details
-
noOp
Returns a no-op instance ofApplicationEventPublisher.- Type Parameters:
K- The event type- Returns:
- an instance of
ApplicationEventPublisher
-
publishEvent
Publish the given event. The event will be published synchronously and only return once all listeners have consumed the event.- Parameters:
event- The event to publish
-
publishEventAsync
Publish the given event. The event will be published asynchronously. A future is returned that can be used to check whether the event completed successfully or not.- Parameters:
event- The event to publish- Returns:
- A future that completes when the event is published
- Since:
- 1.3.5
-
isEmpty
default boolean isEmpty()Check whether this publisher is empty (i.e. has no listeners). If this method returnstrue,publishEvent(Object)does not need to be called.- Returns:
trueiff there are no subscribers- Since:
- 4.0.0
-