工作内容

初始化事件广播器。
如果注册了就用注册的,没有的话就用默认的 SimpleApplicationEventMulticaster

  1. protected void initApplicationEventMulticaster() {
  2. ConfigurableListableBeanFactory beanFactory = getBeanFactory();
  3. if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
  4. this.applicationEventMulticaster =
  5. beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
  6. if (logger.isTraceEnabled()) {
  7. logger.trace("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
  8. }
  9. } else {
  10. this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
  11. beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
  12. if (logger.isTraceEnabled()) {
  13. logger.trace("No '" + APPLICATION_EVENT_MULTICASTER_BEAN_NAME + "' bean, using " +
  14. "[" + this.applicationEventMulticaster.getClass().getSimpleName() + "]");
  15. }
  16. }
  17. }