容器的扩展功能主要实现为:

org.springframework.context.support.AbstractApplicationContext.refresh()

    public void refresh() throws BeansException, IllegalStateException {
synchronized (this.startupShutdownMonitor) {
// 准备刷新的上下文环境
// Prepare this context for refreshing.
prepareRefresh(); // 初始化BeanFactory,并进行xml文件读取
// Tell the subclass to refresh the internal bean factory.
ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory(); // 对BeanFactory进行各种功能填充
// Prepare the bean factory for use in this context.
prepareBeanFactory(beanFactory); try {
// 子类覆盖方法做额外的处理
// Allows post-processing of the bean factory in context subclasses.
postProcessBeanFactory(beanFactory); // 激活各种BeanFactory处理器
// Invoke factory processors registered as beans in the context.
invokeBeanFactoryPostProcessors(beanFactory); // 注册拦截bean创建的bean处理器,这里只是注册,真正的调用时在getBean时候
// Register bean processors that intercept bean creation.
registerBeanPostProcessors(beanFactory); // 为上下文初始化Message源,即不同语言的消息体,国际化处理
// Initialize message source for this context.
initMessageSource(); // 初始化应用消息广播器,并放入ApplicationEventMulticaster中
// Initialize event multicaster for this context.
initApplicationEventMulticaster(); // 留给子类来初始化其他的bean
// Initialize other special beans in specific context subclasses.
onRefresh(); // 在所有注册的bean中查找listener bean,注册到消息广播器中
// Check for listener beans and register them.
registerListeners(); // 初始化剩下的单实例(非延迟加载的)
// Instantiate all remaining (non-lazy-init) singletons.
finishBeanFactoryInitialization(beanFactory); // 完成刷新过程,通知生命周期处理器lifecycleProcessor刷新过程,同时发出ContextRefreshEvent通知别人
// 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;
}
}
}

参考:spring源码深度解析

spring容器的功能扩展的更多相关文章

  1. Spring源码学习(6)——容器的功能扩展

    之前的随笔中借BeanFactory介绍了bean的解析和加载的完整过程,实际上,除了BeanFactory,spring还提供了一种功能更加强大的容器:ApplicationContext Appl ...

  2. Spring源码分析(十九)容器的功能扩展概览

    摘要: 本文结合<Spring源码深度解析>来分析Spring 5.0.6版本的源代码.若有描述错误之处,欢迎指正. 经过前面几章的分析,相信大家已经对 Spring 中的容器功能有了简单 ...

  3. spring源码深度解析-2功能扩展

    容器功能的扩展ApplicationContext用于扩展BeanFactory中现有的功能.究竟多出了哪些功能,进一步探索.写法上:BeanFactory bf = new XmlBeanFacto ...

  4. Spring 系列教程之容器的功能

    Spring 系列教程之容器的功能 经过前面几章的分析,相信大家已经对 Spring 中的容器功能有了简单的了解,在前面的章节中我们一直以 BeanFacotry 接口以及它的默认实现类 XmlBea ...

  5. Spring核心技术(七)——Spring容器的扩展

    本文将讨论如何关于在Spring生命周期中扩展Spring中的Bean功能. 容器的扩展 通常来说,开发者不需要通过继承ApplicationContext来实现自己的子类扩展功能.但是Spring ...

  6. spring4.1.8扩展实战之六:注册bean到spring容器(BeanDefinitionRegistryPostProcessor接口)

    本章是<spring4.1.8扩展实战>系列的第六篇,目标是学习如何通过自己写代码的方式,向spring容器中注册bean: 原文地址:https://blog.csdn.net/boli ...

  7. 从Spring容器的角度理解Dubbo扩展点的加载时机

    对于Dubbo提供的扩展点,主程序执行的过程中并没有显示调用加载的过程,无论是自激活的Filter还是自适应的ThreadPool.那么这样的扩展点在程序运行的哪个节点调用的呢?跟踪之前性能监控扩展点 ...

  8. spring4.1.8扩展实战之四:感知spring容器变化(SmartLifecycle接口)

    本章是<spring4.1.8扩展实战>的第四篇,如果业务上需要在spring容器启动和关闭的时候做一些操作,可以自定义SmartLifecycle接口的实现类来扩展,本章我们通过先分析再 ...

  9. Spring是什么,Spring容器提供了那些功能,Spring的工作机制

    spring是什么 spring 是一个轻型的容器,是J2EE规范的轻量级实现,可以一站式开发,其中提供了,bean工厂,用以构造我们需要的Model ,spring 是非侵入式的,spring应用中 ...

随机推荐

  1. centos7 yum 安装lnmp

    centos7 yum 安装lnmp   安装7.2把7.1改成7.2就行 使用第三方扩展epel源安装php7.2 #移除旧版php [root@web02 ~]# yum remove php-m ...

  2. 07webpack--下载对应的css模块

    <!--本节 loader配置处理css样式 在src下新建css文件夹 在css下创建index.css 在main.js这个入口文件中 引入js模块 和 css杨思表是不同的 在main.j ...

  3. 第14节_BLE协议ATT层

    下面这个图是BLE协议各层跟医院的各个科室的类比图: 跟医院类比,ATT层就是化验室,通过它可以得到各种检查结果──属性.这些检查结果之间有什么联系,它们组合起来体现了什么,化验室是不知道的,这些得由 ...

  4. 201871020225-牟星源《面向对象程序设计(java)》第6-7周学习总结

    201871020225-牟星源<面向对象程序设计(java)>第6-7周学习总结 博文正文: 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu- ...

  5. 莫烦TensorFlow_06 plot可视化

    import tensorflow as tf import numpy as np import matplotlib.pyplot as plt def add_layer(inputs, in_ ...

  6. HTTPS各版本安全策略HTTPS1_1_TLS1_0、HTTPS2_TLS1_0、HTTPS2_TLS1_2

    来自阿里云 https://help.aliyun.com/document_detail/115169.html HTTPS安全策略 更新时间:2019-04-26 14:49:12      分组 ...

  7. zz深度学习论文合集大全

        Pull requestsIssues Marketplace Explore             Learn Git and GitHub without any code! Using ...

  8. 基于CAS实现无锁结构

    杨乾成 2017310500302 一.题目要求 基于CAS(Compare and Swap)实现一个无锁结构,可考虑queue,stack,hashmap,freelist等. 能够支持多个线程同 ...

  9. 洛谷 P1950 长方形_NOI导刊2009提高(2)

    传送门 思路 首先定义\(h\)数组,\(h[i][j]\)表示第\(i\)行第\(j\)列最多可以向上延伸多长(直到一个被用过的格子) 然后使用单调栈算出 \(l_i\)和 \(r_i\) ,分别是 ...

  10. [LeetCode] 1028. Recover a Tree From Preorder Traversal 从先序遍历还原二叉树

    We run a preorder depth first search on the rootof a binary tree. At each node in this traversal, we ...