Class BroadleafApplicationEventMulticaster
java.lang.Object
org.springframework.context.event.AbstractApplicationEventMulticaster
org.springframework.context.event.SimpleApplicationEventMulticaster
org.broadleafcommerce.common.event.BroadleafApplicationEventMulticaster
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanClassLoaderAware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.context.ApplicationContextAware
,org.springframework.context.event.ApplicationEventMulticaster
public class BroadleafApplicationEventMulticaster
extends org.springframework.context.event.SimpleApplicationEventMulticaster
implements org.springframework.context.ApplicationContextAware
This class is a simple extension to Spring's SimpleApplicationEventMulticaster. The difference is
that this allows the EventListener to indicate whether it should be asynchronous or not, assuming that a
TaskExecutor has been configured.
Asynchronous execution should be used with care. Events are not durable with this implementation. In addition, this implementation does not broadcast or multicast events to systems outside of the running JVM, although an event listener could be configured to do just that.
- Author:
- Kelly Tisdell
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
multicastEvent
(org.springframework.context.ApplicationEvent event) Take care when specifying that event or application listener should be executed asynchronously.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setTaskExecutor
(Executor taskExecutor) Methods inherited from class org.springframework.context.event.SimpleApplicationEventMulticaster
getErrorHandler, invokeListener, multicastEvent, setErrorHandler
Methods inherited from class org.springframework.context.event.AbstractApplicationEventMulticaster
addApplicationListener, addApplicationListenerBean, getApplicationListeners, getApplicationListeners, removeAllListeners, removeApplicationListener, removeApplicationListenerBean, removeApplicationListenerBeans, removeApplicationListeners, setBeanClassLoader, setBeanFactory, supportsEvent, supportsEvent
-
Field Details
-
ctx
protected org.springframework.context.ApplicationContext ctx
-
-
Constructor Details
-
BroadleafApplicationEventMulticaster
public BroadleafApplicationEventMulticaster()
-
-
Method Details
-
multicastEvent
public void multicastEvent(org.springframework.context.ApplicationEvent event) Take care when specifying that event or application listener should be executed asynchronously. If there is no TaskExecutor configured, this will execute synchronously, regardless. If there is a TaskExecutor configured, then if the listener is a BroadleafApplicationListener and itsisAsynchronous()
method returns true then the event will fire asynchronously. Be aware that the events are not durable in this case. Events that are executed asynchronously should be used with caution, where a loss of event due to error or shutdown of the VM is not a major concern.- Specified by:
multicastEvent
in interfaceorg.springframework.context.event.ApplicationEventMulticaster
- Overrides:
multicastEvent
in classorg.springframework.context.event.SimpleApplicationEventMulticaster
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
getTaskExecutor
- Overrides:
getTaskExecutor
in classorg.springframework.context.event.SimpleApplicationEventMulticaster
-
setTaskExecutor
- Overrides:
setTaskExecutor
in classorg.springframework.context.event.SimpleApplicationEventMulticaster
-