zoukankan      html  css  js  c++  java
  • Spring源码情操陶冶-AbstractApplicationContext#initApplicationEventMulticaster

    承接前文Spring源码情操陶冶-AbstractApplicationContext#initMessageSource
    约定web.xml配置的contextClass为默认值XmlWebApplicationContext

    瞧瞧官方注释

    	/**
    	 * Initialize the ApplicationEventMulticaster.
    	 * Uses SimpleApplicationEventMulticaster if none defined in the context.
    	 * @see org.springframework.context.event.SimpleApplicationEventMulticaster
    	 */
    

    初始化ApplicationEventMulticaster事件,默认使用SimpleApplicationEventMulticaster事件

    直接源码

    protected void initApplicationEventMulticaster() {
    		ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    		//查找是否存在id为applicationEventMulticaster的bean对象
    		if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
    			this.applicationEventMulticaster =
    					beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
    			if (logger.isDebugEnabled()) {
    				logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
    			}
    		}
    		else {
    			//默认使用SimpleApplicationEventMulticaster,并注册为单例
    			this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
    			beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
    			if (logger.isDebugEnabled()) {
    				logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
    						APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
    						"': using default [" + this.applicationEventMulticaster + "]");
    			}
    		}
    	}
    

    小结

    此节内容跟前文initMessageSource类似

    下节预告

    Spring源码情操陶冶-AbstractApplicationContext#onRefresh

  • 相关阅读:
    php 魔术方法
    有用的函数系统采集(一)
    php后期静态绑定
    php对象引用及序列化
    php文件操作
    复习mysql视图总结
    jQuery调用WebService详解
    这个网站的界面描述甚好,我喜欢
    喜欢和技术有关的一切~
    Introduction
  • 原文地址:https://www.cnblogs.com/question-sky/p/6842544.html
Copyright © 2011-2022 走看看