ApplicationEventMulticaster interface.
Multicasts all events to all registered listeners, leaving it up to
the listeners to ignore events that they are not interested in.
Listeners will usually perform corresponding instanceof
checks on the passed-in event object.
By default, all listeners are invoked in the calling thread. This allows the danger of a rogue listener blocking the entire application, but adds minimal overhead. Specify an alternative task executor to have listeners executed in different threads, for example from a thread pool.
setTaskExecutor
| Modifier and Type | Field and Description |
|---|---|
| private ErrorHandler | |
| private volatile Log | |
| private Executor |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SimpleApplicationEventMulticaster(BeanFactory beanFactory)
Create a new SimpleApplicationEventMulticaster for the given BeanFactory. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| protected ErrorHandler | |
| protected Executor | |
| protected void | invokeListener(ApplicationListener<?>
the ApplicationListener to invoke listener, ApplicationEvent the current event to propagate event)Invoke the given listener with the given event. |
| private boolean | |
| public void | multicastEvent(ApplicationEvent
the event to multicast event)Implements org. Multicast the given application event to appropriate listeners. |
| public void | multicastEvent(ApplicationEvent
the event to multicast event, ResolvableType the type of event (can be eventType)null)Implements org. Multicast the given application event to appropriate listeners. |
| public void | setErrorHandler(ErrorHandler errorHandler)
Set the |
| public void | setTaskExecutor(Executor taskExecutor)
Set a custom executor (typically a |
| errorHandler | back to summary |
|---|---|
| private ErrorHandler errorHandler
| |
| lazyLogger | back to summary |
|---|---|
| private volatile Log lazyLogger
| |
| taskExecutor | back to summary |
|---|---|
| private Executor taskExecutor
| |
| SimpleApplicationEventMulticaster | back to summary |
|---|---|
| public SimpleApplicationEventMulticaster() Create a new SimpleApplicationEventMulticaster. | |
| SimpleApplicationEventMulticaster | back to summary |
|---|---|
| public SimpleApplicationEventMulticaster(BeanFactory beanFactory) Create a new SimpleApplicationEventMulticaster for the given BeanFactory. | |
| doInvokeListener | back to summary |
|---|---|
private void doInvokeListener(ApplicationListener<E extends ApplicationEvent> listener, ApplicationEvent event)
| |
| getErrorHandler | back to summary |
|---|---|
| protected ErrorHandler getErrorHandler() Return the current error handler for this multicaster.
| |
| getTaskExecutor | back to summary |
|---|---|
| protected Executor getTaskExecutor() Return the current task executor for this multicaster.
| |
| invokeListener | back to summary |
|---|---|
| protected void invokeListener(ApplicationListener<?> listener, ApplicationEvent event) Invoke the given listener with the given event.
| |
| matchesClassCastMessage | back to summary |
|---|---|
| private boolean matchesClassCastMessage(String classCastMessage, Class<?> eventClass) | |
| multicastEvent | back to summary |
|---|---|
| public void multicastEvent(ApplicationEvent event) Implements org. Doc from org. Multicast the given application event to appropriate listeners. Consider using If a matching
| |
| multicastEvent | back to summary |
|---|---|
| public void multicastEvent(ApplicationEvent event, ResolvableType eventType) Implements org. Doc from org. Multicast the given application event to appropriate listeners. If the If a matching
| |
| setErrorHandler | back to summary |
|---|---|
| public void setErrorHandler(ErrorHandler errorHandler) Set the Default is none, with a listener exception stopping the current multicast and getting propagated to the publisher of the current event. If a task executor is specified, each individual listener exception will get propagated to the executor but won't necessarily stop execution of other listeners. Consider setting an
| |
| setTaskExecutor | back to summary |
|---|---|
| public void setTaskExecutor(Executor taskExecutor) Set a custom executor (typically a Default is equivalent to Consider specifying an asynchronous task executor here to not block the caller until all listeners have been executed. However, note that asynchronous execution will not participate in the caller's thread context (class loader, transaction context) unless the TaskExecutor explicitly supports this.
| |