码迷,mamicode.com
首页 > 移动开发 > 详细

org.springframework.context.event.AbstractApplicationEventMulticaster

时间:2016-08-01 22:38:09      阅读:354      评论:0      收藏:0      [点我收藏+]

标签:

private Collection<ApplicationListener<?>> retrieveApplicationListeners(ResolvableType eventType, Class<?> sourceType, AbstractApplicationEventMulticaster.ListenerRetriever retriever) {
LinkedList allListeners = new LinkedList();
Object beanFactory = this.retrievalMutex;
LinkedHashSet listeners;
LinkedHashSet listenerBeans;
synchronized(this.retrievalMutex) {
listeners = new LinkedHashSet(this.defaultRetriever.applicationListeners);
listenerBeans = new LinkedHashSet(this.defaultRetriever.applicationListenerBeans);
}

Iterator beanFactory1 = listeners.iterator();

while(beanFactory1.hasNext()) {
ApplicationListener listener = (ApplicationListener)beanFactory1.next();
if(this.supportsEvent(listener, eventType, sourceType)) {
if(retriever != null) {
retriever.applicationListeners.add(listener);
}

allListeners.add(listener);
}
}

if(!listenerBeans.isEmpty()) {
BeanFactory beanFactory2 = this.getBeanFactory();
Iterator listener2 = listenerBeans.iterator();

while(listener2.hasNext()) {
String listenerBeanName = (String)listener2.next();

try {
Class listenerType = beanFactory2.getType(listenerBeanName);
if(listenerType == null || this.supportsEvent(listenerType, eventType)) {
ApplicationListener listener1 = (ApplicationListener)beanFactory2.getBean(listenerBeanName, ApplicationListener.class);
if(!allListeners.contains(listener1) && this.supportsEvent(listener1, eventType, sourceType)) {
if(retriever != null) {
retriever.applicationListenerBeans.add(listenerBeanName);
}

allListeners.add(listener1);
}
}
} catch (NoSuchBeanDefinitionException var13) {
;
}
}
}

AnnotationAwareOrderComparator.sort(allListeners);
return allListeners;
}


org.springframework.context.event.AbstractApplicationEventMulticaster

 

org.springframework.context.event.AbstractApplicationEventMulticaster

标签:

原文地址:http://www.cnblogs.com/softidea/p/5727242.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!