随笔分类 -  Spring系列

摘要:1. ImportBeanDefinitionRegistrar // 和 DeferredImportSelectors 类似, 也可以自己注册 BeanDefinition // 不过这个接口可以继承 EnvironmentAware、BeanFactoryAware、BeanClassLoad 阅读全文
posted @ 2022-04-10 16:48 YangDanMua 阅读(79) 评论(0) 推荐(0) 编辑
摘要:1. 使用的地方 是一个 ConfigurationClassParser 的成员变量,主要是用于判断循环导入? 2. ImportStack 3. 第一处使用 ConfigurationClassParser#processMemberClasses 这个是处理一个类的内部类的,包括静态内部类和实 阅读全文
posted @ 2022-04-10 16:10 YangDanMua 阅读(203) 评论(0) 推荐(0) 编辑
摘要:1. DeferredImportSelector 接口 具体注释待续。 类头注释的英文翻译:ImportSelector的一个变体,在处理完所有@Configuration bean之后运行。当所选导入为@Conditional时,这种类型的选择器特别有用。 实现也可以扩展org.springfr 阅读全文
posted @ 2022-04-09 23:10 YangDanMua 阅读(156) 评论(0) 推荐(0) 编辑
摘要:处理逻辑在 org.springframework.context.annotation.ConfigurationClassParser#processImports。 暂时略其子接口 DeferredImportSelector 1. ImportSelector 接口 selectImport 阅读全文
posted @ 2022-04-09 22:30 YangDanMua 阅读(54) 评论(0) 推荐(0) 编辑
摘要:1. 解析逻辑 具体逻辑在 org.springframework.context.annotation.ConfigurationClassParser#processImports 中,下面的 importCandidates 即为 @Import 导入的类的列表。 最后的一个 else 即为普 阅读全文
posted @ 2022-04-09 22:24 YangDanMua 阅读(155) 评论(0) 推荐(0) 编辑
摘要:1. 概述 同样是 org.springframework.context.annotation.ConfigurationClassParser#doProcessConfigurationClass 开始 org.springframework.context.annotation.Config 阅读全文
posted @ 2022-04-09 22:15 YangDanMua 阅读(66) 评论(0) 推荐(0) 编辑
摘要:1. 概述 配置类是 ConfigurationClassPostProcessor 这个 BeanFactoryPostProcessor(BeanDefinitionRefistryPostProcessor)处理的,内部实际是使用了一个 ConfigurationClassParser进行具体 阅读全文
posted @ 2022-04-09 21:44 YangDanMua 阅读(125) 评论(0) 推荐(0) 编辑
摘要:1. 概述 当使用 spring-context 搭建简单 demo 时,调用 BeanDefinitionRegistryPostProcessor 第一个就是 ConfigurationClassPostProcessor 同时注意到它干了什么,它 getBean 立即将其转换为 Bean / 阅读全文
posted @ 2022-04-08 23:38 YangDanMua 阅读(54) 评论(0) 推荐(0) 编辑
摘要:1. 概述 前面说到 Reader 实例化时注册了一些 BD 进入容器。 在 refresh 过程中,也注入了一些 Bean 到容器,注意这里注入的不是 BD 而是直接注入 Bean。 2. prepareBeanFactory org.springframework.context.support 阅读全文
posted @ 2022-04-08 21:56 YangDanMua 阅读(56) 评论(0) 推荐(0) 编辑
摘要:1. 概述 作为AnnotationConfigApplicationContext的字段 public class AnnotationConfigApplicationContext extends GenericApplicationContext implements AnnotationC 阅读全文
posted @ 2022-04-08 21:38 YangDanMua 阅读(177) 评论(0) 推荐(0) 编辑
摘要:1. AnnotationConfigApplicationContext 的 reader 和 scanner public AnnotationConfigApplicationContext(Class<?>... componentClasses) { this(); // 注册解析这个 B 阅读全文
posted @ 2022-04-08 20:54 YangDanMua 阅读(149) 评论(0) 推荐(0) 编辑
摘要:一、Spring处理配置类大致过程 回忆一下Spring处理配置类的大致过程【ConfigurationClassPostProcessor】 【BeanFactoryPostProcessor -> BeanDefinitionRegistryPostProcessor】 Configuratio 阅读全文
posted @ 2021-10-22 20:26 YangDanMua 阅读(996) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示