首页 > 编程语言 > 详细

Spring源码:Spring 容器资源加载模板模式应用

时间:2015-07-31 14:57:04      阅读:157      评论:0      收藏:0      [点我收藏+]


模板位于:abstract class AbstractXmlApplicationContext :

	protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException {
		Resource[] configResources = getConfigResources(); //加载路径由子类去覆盖实现
		if (configResources != null) {
			reader.loadBeanDefinitions(configResources);
		}
		String[] configLocations = getConfigLocations();
		if (configLocations != null) {
			reader.loadBeanDefinitions(configLocations);
		}
	}

子类的实现:FileSystemXmlApplicationContext extends AbstractXmlApplicationContext

	@Override
	protected Resource getResourceByPath(String path) {
		if (path != null && path.startsWith("/")) {
			path = path.substring(1);
		}
		return new FileSystemResource(path);
	}

资源的加载,是Spring IOC容器启动的第一步!

版权声明:本文为博主原创文章,未经博主允许不得转载。

Spring源码:Spring 容器资源加载模板模式应用

原文:http://blog.csdn.net/tragedyxd/article/details/47168595

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!