Spring源码学习--XmlWebApplicationContext(四)
来源:互联网 发布:凯立德导航端口怎么看 编辑:程序博客网 时间:2024/04/29 23:27
ApplicationContext应用上下文体系如下:
XmlWebApplicationContext是用于web容器的应用上下文的,其也没有太多操作,主要还是applicationContext.xml的解析操作,完整源码如下
public class XmlWebApplicationContext extends AbstractRefreshableWebApplicationContext {/** Default config location for the root context *///默认配置文件地址public static final String DEFAULT_CONFIG_LOCATION = "/WEB-INF/applicationContext.xml";/** Default prefix for building a config location for a namespace */public static final String DEFAULT_CONFIG_LOCATION_PREFIX = "/WEB-INF/";/** Default suffix for building a config location for a namespace */public static final String DEFAULT_CONFIG_LOCATION_SUFFIX = ".xml";//解析applicationContext.xml@Overrideprotected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {// Create a new XmlBeanDefinitionReader for the given BeanFactory.XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);// Configure the bean definition reader with this context's// resource loading environment.beanDefinitionReader.setEnvironment(getEnvironment());beanDefinitionReader.setResourceLoader(this);beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));// Allow a subclass to provide custom initialization of the reader,// then proceed with actually loading the bean definitions.initBeanDefinitionReader(beanDefinitionReader);loadBeanDefinitions(beanDefinitionReader);}protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {}protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws IOException {String[] configLocations = getConfigLocations();if (configLocations != null) {for (String configLocation : configLocations) {reader.loadBeanDefinitions(configLocation);}}}//获取默认配置文件地址@Overrideprotected String[] getDefaultConfigLocations() {if (getNamespace() != null) {return new String[] {DEFAULT_CONFIG_LOCATION_PREFIX + getNamespace() + DEFAULT_CONFIG_LOCATION_SUFFIX};}else {return new String[] {DEFAULT_CONFIG_LOCATION};}}}
2 1
- Spring源码学习--XmlWebApplicationContext(四)
- Spring源码学习之一 ContextLoaderListener及XmlWebApplicationContext
- spring源码学习之三 XmlWebApplicationContext.loadBeanDefinitions源码分析
- spring源码学习之二 XmlWebApplicationContext类结构概述
- Spring学习笔记-初始化XmlWebApplicationContext
- 小读spring ioc源码(三)——XmlWebApplicationContext初始化的整体过程
- spring XmlWebApplicationContext详解
- spring源码学习笔记-初始化(四)-PostProcessor
- spring源码学习笔记-初始化(四)-PostProcessor
- spring源码学习笔记-初始化(四)-PostProcessor
- Spring源码学习笔记(四)-Aop获取增强、切点
- Spring源码学习--Bean对象循环依赖问题解决(四)
- spring源码学习之四 BeanDefinitionParserDelegate分析
- XmlWebApplicationContext加载bean XML源码解析
- Spring学习(四)
- Spring学习(四)
- Spring启动<二>——XmlWebApplicationContext
- Spring启动<三>——XmlWebApplicationContext
- 什么是jsx
- c语言
- 什么是jsx
- 【原创达人】如何为WINPE添加NVME驱动
- 如何使用jsx
- Spring源码学习--XmlWebApplicationContext(四)
- 蓝桥杯 基础练习 十六进制转八进制
- qml 字体
- zookeeper集群搭建
- 单片机
- 移动端 单位 rem
- 非dom属性介绍
- hbase安装
- unity shader 之 几何变换--波