您的位置:首页 > 编程语言 > Java开发

Dorado 7 源码分析(一)SpringContextLoaderListener

2012-12-20 22:43 489 查看
根据Web.xml的加载顺序context-param->listener->filter->servlet 从SpringContextLoaderListener开始

Dorado7的Web服务是依托Spring MVC构建起来的(对Dorado源码分析将同时对Spring也进一步讲解)

public class SpringContextLoaderListener extends ContextLoaderListener {
// Dorado 日志是基于apache.commons.logging管理的 至于后面配置log4j是由apache.commons.logging转向log4j
private static final Log logger = LogFactory
.getLog(SpringContextLoaderListener.class);
/**DoradoLoader是一个单例
*主要是服务启动时读取Dorado 配置文件,
*处理Spring的配置文件
*创建临时的ResourceLoader
*创建临时存储目录
*初始化WebContext等等
*详细在后续DoradoLoader章节讲解
*/
private DoradoLoader doradoLoader;

public SpringContextLoaderListener() {
doradoLoader = DoradoLoader.getInstance();
}

@Override
protected void customizeContext(ServletContext servletContext,
ConfigurableWebApplicationContext applicationContext) {
try {
doradoLoader.preload(servletContext, true);
List<String> doradoContextLocations = doradoLoader
.getContextLocations(false);
String[] realResourcesPath = doradoLoader
.getRealResourcesPath(doradoContextLocations);
applicationContext.setConfigLocations(realResourcesPath);
} catch (Exception e) {
logger.error(e, e);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: