From 35aa4eb2644c12f0b0b38e2cbd5bf49c61d3dec9 Mon Sep 17 00:00:00 2001
From: kn5886348135 <56352848+kn5886348135@users.noreply.github.com>
Date: Sat, 3 Dec 2022 22:10:00 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ConfigurationClassPostProcess?=
=?UTF-8?q?or?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
framework-source-code/spring/spring.md | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/framework-source-code/spring/spring.md b/framework-source-code/spring/spring.md
index e57d0e4..6881090 100644
--- a/framework-source-code/spring/spring.md
+++ b/framework-source-code/spring/spring.md
@@ -1,3 +1,5 @@
+Spring框架源码版本5.3.x
+
### 框架源码的前置知识
* 设计模式
@@ -24,12 +26,14 @@ xxbean.method();
#### SSM框架项目中spring处理bean的主要流程
-* 加载xml文件
-* 解析xml文件
+* 加载bean定义文件,一般是xml文件或者注解
+* 解析bean定义文件
* 封装BeanDefinition
-* 实例化
-* 放到容器中
-* 从容器中获取
+* 处理PostProcessor
+* 准备监听器
+* 创建代理(JDK或者Cglib),使用反射实例化
+* 属性填充和初始化
+* 销毁
容器使用map保存bean,map的key和value内容
|序号| Key | Value |
@@ -39,7 +43,7 @@ xxbean.method();
|3| String | ObjectFactory |
|4| String | BeanDefinition |
-## Spring创建Bean过程中用到的主要接口
+## Spring创建Bean过程中用到的主要接口和类
* BeanDefinitionReader
* BeanDefinition
@@ -52,6 +56,7 @@ xxbean.method();
* Aware
* BeanNameAware
* AbstractAutoProxyCreator
+* ConfigurationClassPostProcessor
#### BeanDefinitionReader
@@ -160,3 +165,6 @@ ApplicationContext可以在其 bean 定义中自动检测 BeanPostProcessor bean
子类可以应用任何策略来决定是否要代理一个 bean,例如 按类型、按名称、按定义详细信息等。它们还可以返回应仅应用于特定 bean 实例的其他拦截器。 一个简单的具体实现是 {@link BeanNameAutoProxyCreator},通过给定名称识别要代理的 bean。
可以使用任意数量的 {@link TargetSourceCreator} 实现来创建自定义目标源:例如,池化原型对象。 即使没有建议,自动代理也会发生,只要 TargetSourceCreator 指定自定义 {@link org.springframework.aop.TargetSource}。 如果没有设置 TargetSourceCreators,或者没有匹配项,默认情况下将使用 {@link org.springframework.aop.target.SingletonTargetSource} 来包装目标 bean 实例。
+
+#### ConfigurationClassPostProcessor
+启动过程中处理@Configuration注解。通过或者标签注册,也可以通过其他BeanFactoryPostProcessor手动注册。他实现了PriorityOrdered接口,@Configuration注解修饰的类中所有具有bean定义的方法在所有BeanFactoryPostProcessor执行之前注册。