物采系统启动后,加载文件的执行顺序

1.加载web.xml文件。web.xml里面定义了一下几方面的内容:

  (1).spring配置文件的存放位置:

  <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath*:/conf/appContext*.xml</param-value>
  <!-- <param-value>classpath*:/**/appContext*.xml</param-value> -->
 </context-param>

  (2).自定义的几个Action:

  <servlet>
  <servlet-name>dispatcher</servlet-name>
  <servlet-class>com.cnpc.pms.base.common.action.DispatcherAction</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>dispatcher</servlet-name>
  <url-pattern>dispatcher.action</url-pattern>
 </servlet-mapping>

 (3).过滤器(filter):

 <filter>
  <filter-name>initialFilter</filter-name>
  <filter-class>com.cnpc.pms.base.filter.InitialFilter</filter-class>
 </filter>

 <filter>
  <filter-name>authFilter</filter-name>
  <filter-class>com.cnpc.pms.bizbase.filter.AuthFilter</filter-class>
 </filter>

(4).监听器(listener):

  在web.xml里面最下面一行有一个Listener:

 <listener>
  <listener-class>com.cnpc.pms.base.filter.PMSContextLoaderListener</listener-class>
 </listener>

2.PMSContextLoaderListener类,里面定义了再加载完web.xml后,也就是在contextInitialized后,执行PMSContextLoaderListener类里重写了的contextInitialized()方法。

下面列出contextInitialized()方法的内容和注释:

 

public void contextInitialized(ServletContextEvent event) {
	log.debug("Start Initialize Web PMS Context");
	Slf4jWebConfigurer.initLogging(event.getServletContext());
	log.debug("Start Initialize Web ContextLoader ====>");
	contextLoader = createContextLoader();//加载appContext.xml文件
		
	//注册里面定义的beans:
	//(1).PMSPropertyPlaceholderConfigurer加载application.properties文件,
	//    该文件包含了数据库的连接信息.
	//    PMSPropertyPlaceholderConfigurer类中重写了processProperties()方法,
	//    该方法又从dataSource.xml中读取了一部分数据库信息.
	//(2).PMSReloadableResourceBundleMessageSource加载国际化文件i18n/*query*.xml
	contextLoader.initWebApplicationContext(event.getServletContext());
	log.debug("<====End of Initialize Web ContextLoader");
	WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
	GenericWebApplicationContext genericWac = new GenericWebApplicationContext();
	genericWac.setParent(wac);
	log.debug("<====End of Initialize GenericWebApplicationContext");
	SpringHelper.setApplicationContext(genericWac);//设置ThreadLocal<ApplicationContext>的值
	appContext.initialize();//(1)注册module文件夹下的xml中定义的bean,(2)加载query文件夹下的xml
	event.getServletContext().setAttribute(APPLICATION_CONTEXT_ATTRIBUTE, genericWac);
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值