Environment环境对象
org.springframework.core.env.Environment
PropertySource属性来源对象
org.springframework.core.env.PropertySource
org.springframework.core.env.PropertySource.StubPropertySource
桩代码 --是指只初始化部分属性的对象,可以通过识别类型 来进行未来二次加工。可以看做是占位代码
其中ServletContextPropertySource以及ServletConfigPorpertySource都是StubPropertySource的实现。
Resolver 能力提供者
org.springframework.core.env.PropertyResolver
Context 上下文
org.springframework.web.context.WebApplicationContext
Context上下文的配置地址
org.springframework.web.context.ConfigurableWebApplicationContext#setConfigLocation
指定了spring-context.xml的所在地址,来源于servletContext的contextConfigLocation参数
Loader 加载器
org.springframework.web.context.ContextLoader
初始化类对象
org.springframework.beans.BeanUtils#instantiateClass(java.lang.Class<T>)
Initializer 初始化器
org.springframework.context.ApplicationContextInitializer
globalInitializerClasses 、contextInitializerClasses 可以在web.xml中指定对应初始化类,多个以逗号或者封号隔开
需实现ApplicationContextInitializer。
spring 默认是没有定制的初始化类
customize 定制
org.springframework.core.env.StandardEnvironment#customizePropertySources
org.springframework.web.context.ContextLoader#customizeContext
spring 加载的关键方法
org.springframework.context.support.AbstractApplicationContext#refresh
org.springframework.context.support.AbstractApplicationContext#prepareRefresh //校验需要的属性是否都存在。
org.springframework.context.support.AbstractApplicationContext#obtainFreshBeanFactory //
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
org.springframework.beans.factory.support.AbstractBeanDefinitionReader#loadBeanDefinitions(java.lang.String, java.util.Set<org.springframework.core.io.Resource>)
XML bean定义 读取器
org.springframework.core.io.ResourceLoader
资源加载器
org.springframework.core.io.Resource
资源