根据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);
}
}
}