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
    Modifier and Type
    Field
    Description
    protected org.springframework.context.ApplicationContext
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    void
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 its isAsynchronous() 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 interface org.springframework.context.event.ApplicationEventMulticaster
      Overrides:
      multicastEvent in class org.springframework.context.event.SimpleApplicationEventMulticaster
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • getTaskExecutor

      public Executor getTaskExecutor()
      Overrides:
      getTaskExecutor in class org.springframework.context.event.SimpleApplicationEventMulticaster
    • setTaskExecutor

      public void setTaskExecutor(Executor taskExecutor)
      Overrides:
      setTaskExecutor in class org.springframework.context.event.SimpleApplicationEventMulticaster