先总结: 该方法主要用于注册监听器, 在所有注册的bean中查找listener监听器bean, 注册到消息广播器中
1.遍历应用程序中存在的监听器集合,并将对应的监听器添加到监听器的多路广播器中
for (ApplicationListener<?> listener : getApplicationListeners()) { getApplicationEventMulticaster().addApplicationListener(listener); }
2.从容器中获取所有实现了ApplicationListener接口的bd的bdName, 放入ApplicationListenerBeans集合中
1 String[] listenerBeanNames = getBeanNamesForType(ApplicationListener.class, true, false); 2 for (String listenerBeanName : listenerBeanNames) { 3 getApplicationEventMulticaster().addApplicationListenerBean(listenerBeanName); 4 }
3.发布早期应用程序事件
1 Set<ApplicationEvent> earlyEventsToProcess = this.earlyApplicationEvents; 2 this.earlyApplicationEvents = null; 3 if (!CollectionUtils.isEmpty(earlyEventsToProcess)) { 4 for (ApplicationEvent earlyEvent : earlyEventsToProcess) { 5 getApplicationEventMulticaster().multicastEvent(earlyEvent); 6 } 7 }
标签:earlyEventsToProcess,10,ApplicationListener,getApplicationEventMulticaster,liste From: https://www.cnblogs.com/superpiter/p/18096501