Spring IOC-WebApplicationContext刷新(was.refresh())
来源:互联网 发布:用友网络未来价值2017 编辑:程序博客网 时间:2024/06/06 12:49
在 Spring配置web.xml中标签(ContextLoaderListener类解析)解析一文的最后我们留下了wac.refresh();是怎样执行的问题。
【在ContextLoader类中和FrameworkServlet中都执行了这行代码】
不管是在哪里调用refresh(),执行的都是AbstractApplicationContext的refresh()方法,这里再贴出相应的代码:
public void refresh() throws BeansException, IllegalStateException { synchronized (this.startupShutdownMonitor) { // Prepare this context for refreshing. prepareRefresh(); //会调用XmlWebApplicationContext.loadBeanDefinitions()方法 ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory() // 准备bean工厂 prepareBeanFactory(beanFactory); try { // Allows post-processing of the bean factory in context subclasse postProcessBeanFactory(beanFactory); //对beanFactory对象本身调用在此环境中注册的processors invokeBeanFactoryPostProcessors(beanFactory); //注册所有的对bean的processors registerBeanPostProcessors(beanFactory); // Initialize message source for this context. //初始化国际化支持的bean initMessageSource(); //初始化时间发布器 initApplicationEventMulticaster(); //刷新之后执行的操作 onRefresh(); //注册事件,从bean工厂得到或者这个类设置进来的 registerListeners(); //实例化所有单例的bean finishBeanFactoryInitialization(beanFactory); // Last step: publish corresponding event. finishRefresh(); } catch (BeansException ex) { // Destroy already created singletons to avoid dangling resources. destroyBeans(); // Reset 'active' flag. cancelRefresh(ex); // Propagate exception to caller. throw ex; } } }
可以看到一系列的初始化,这样Context就完成了刷新(重新加载所有的定义的bean)
0 0
- Spring IOC-WebApplicationContext刷新(was.refresh())
- Spring IOC-WebApplicationContext继承结构
- Spring Ioc(3)——WebApplicationContext的构建
- 先码后看 spring IOC原理(WebApplicationContext、ContextLoaderListener) 转侵删
- 先码后看 spring IOC源码(beanfactory、applicationcontext、webapplicationcontext) 侵立删
- Spring WebApplicationContext 准备刷新过程
- 定时刷新(refresh)
- 浅析Spring IoC源码(十一)Spring refresh()方法解析之一
- 浅析Spring IoC源码(十一)Spring refresh()方法解析后记2
- 浅析Spring IoC源码(三)分析refresh()方法前的准备篇(一)
- Spring 的Refresh()
- 04.Spring Ioc 容器 - 刷新
- Spring WebApplicationContext
- spring webapplicationcontext
- Spring WebApplicationContext
- 做一个合格的程序猿之浅析Spring IoC源码(十一)Spring refresh()方法解析之一
- 做一个合格的程序猿之浅析Spring IoC源码(十一)Spring refresh()方法解析后记1
- 做一个合格的程序猿之浅析Spring IoC源码(十一)Spring refresh()方法解析后记2
- 黑马程序员——Java基础---线程的另一个总结(3)--互斥,线程锁
- 手斧Linux – 从LFS到Funtoo (103)
- 黑马程序员——C语言运算符的概念及分类
- ubuntu14.04(32位)下编译android4.4时遇到的问题
- SpringMVC,Servlet,Struts1,Struts2单多例笔记
- Spring IOC-WebApplicationContext刷新(was.refresh())
- 手斧Linux – 从LFS到Funtoo (104)
- 【百度】试题若干
- 学嵌入式需要掌握哪些知识
- 手斧Linux – 从LFS到Funtoo (105)
- 自定义上拉加载下拉刷新 和 UIRefreshControl 刷新
- 手斧Linux – 从LFS到Funtoo (106)
- Android常用框架收集
- 次小生成树POJ 1679