ContextLoader,ContextLoaderListener解读
// 在ServletContext进行初始化时执行。是在任何filter或者Servlet初始化之前。
public void contextInitialized(ServletContextEvent sce); // 在ServletContext销毁时执行。是在所有的filter和Servlet销毁之后进行。
public void contextDestroyed(ServletContextEvent sce);
protected WebApplicationContext createWebApplicationContext(ServletContext sc) {
Class<?> contextClass = determineContextClass(sc);
if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) {
throw new ApplicationContextException("Custom context class [" + contextClass.getName() +
"] is not of type [" + ConfigurableWebApplicationContext.class.getName() + "]");
}
return (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass);
}
public class ContextLoaderListener extends ContextLoader implements ServletContextListener
public class ContextLoaderListener extends ContextLoader implements ServletContextListener {
public ContextLoaderListener() {
}
public ContextLoaderListener(WebApplicationContext context) {
super(context);
}
@Override
public void contextInitialized(ServletContextEvent event) {
initWebApplicationContext(event.getServletContext());
}
@Override
public void contextDestroyed(ServletContextEvent event) {
closeWebApplicationContext(event.getServletContext());
ContextCleanupListener.cleanupAttributes(event.getServletContext());
}
}
if (this.context == null) {
this.context = createWebApplicationContext(servletContext);
}
ContextLoader,ContextLoaderListener解读的更多相关文章
- Spring Framework 官方文档学习(二)之IoC容器与bean lifecycle
到目前为止,已经看了一百页.再次感慨下,如果想使用Spring,那可以看视频或者找例子,但如果想深入理解Spring,最好还是看官方文档. 原计划是把一些基本接口的功能.层次以及彼此的关系罗列一下.同 ...
- Spring的监听器ContextLoaderListener
一.作用 ContextLoaderListener监听器的作用就是启动web容器时,自动装配ApplicationContext的配置信息.它实现了ServletContextListener接口, ...
- Spring MVC源码——Root WebApplicationContext
目录 Spring MVC源码--Root WebApplicationContext 上下文层次结构 Root WebApplicationContext 初始化和销毁 ContextLoaderL ...
- Spring MVC 解读——<context:component-scan/>
转自:http://my.oschina.net/HeliosFly/blog/203149 作者:GoodLoser. Spring MVC 解读---<context:component-s ...
- Spring源码情操陶冶-ContextLoader
前言-阅读源码有利于陶冶情操,本文承接前文Spring源码情操陶冶-ContextLoaderListener 静态代码块内容 ContextLoader在被主动调用的时候,会执行其的一个静态块,代码 ...
- Spring源码情操陶冶-ContextLoaderListener
前言:通过实例结合源码的方式解读,其中涉及到的文件来自于博主的Github毕设项目wxServer Note: Springboot应用不在本文章讨论范围 web.xml中启用Spring 在一般的w ...
- SpringMVC 原理 - 设计原理、启动过程、请求处理详细解读
SpringMVC 原理 - 设计原理.启动过程.请求处理详细解读 目录 一. 设计原理 二. 启动过程 三. 请求处理 一. 设计原理 Servlet 规范 SpringMVC 是基于 Servle ...
- [Spring框架] Spring中的 ContextLoaderListener 实现原理.
前言: 这是关于Spring的第三篇文章, 打算后续还会写入AOP 和Spring 事务管理相关的文章, 这么好的两个周末 都在看code了, 确实是有所收获, 现在就来记录一下. 在上一篇讲解Spr ...
- contextloaderlistener
http://blog.csdn.net/c5153000/article/details/6234207 作用:在启动Web容器时,自动装配Spring applicationContext.xml ...
随机推荐
- Android Studio之多个Activity的滑动切换(二)
1.因为Android界面上的全部控件一般都位于Layout控件(比方RelativeLayout)之上,而布局控件能够设置响应touch事件,所以能够通过布局控件的setOnTouchListen来 ...
- Python——Shell编程关于Sha-Bang(#!)
Q. #!的名字为什么叫Sha-Bang? A. Sha-Bang是Sharp和Bang的组合词.Sharp for #, Bang for ! 类似的情况是,C#通常被称为C Sharp Q. Sh ...
- UML学习(一)-工具介绍
这里用于学习UML的工具是StarUML,没有什么原因为什么要用它,或许仅仅是有人说好用和比较小. 首先介绍下这个工具,来张图. 1.菜单栏(最上面) 2.快捷工具栏(菜单栏下面) 3.工具项(Too ...
- Field 'id' doesn't have a default value问题解决方法
Field 'id' doesn't have a default value问题解决方法 突然想温习温习对数据库的读写.于是就用mysql建了一张单独的表(见代码1),用Hibernate写了个应用 ...
- 36、TreeSet详解
TreeSet是SortedSet接口的实现类,TreeSet可以保证元素处于排序状态.与HashSet相比,TreeSet还提供了如下几个而外的方法: 1).Comparator comparato ...
- CSS border 生成三角
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...
- Linux下的进程间通信-详解
详细的讲述进程间通信在这里绝对是不可能的事情,而且笔者很难有信心说自己对这一部分内容的认识达到了什么样的地步,所以在这一节的开头首先向大家推荐著 名作者Richard Stevens的著名作品:&l ...
- linux下vi编辑文件
vi 文件名.进入读文件模式 按i进入编辑模式 按g切光标换到第一行,按G光标切换到最后一行. 按Esc退出编辑模式 :q退出 :wq保存退出 以上命名后面加上!表示强制运行
- Python 3.x 连接 pymysql 数据库
首先,需要安装库: 使用 pycharm IDE,如PyCharm,可以使用 project python 安装第三方模块. [File] >> [settings] >> [ ...
- Prototype的深度探索
http://www.cnblogs.com/meil/archive/2007/06/06/773645.html 1 什么是prototype JavaScript中对象的prototype属性, ...