spring5.1.x版本源码解析
本次源码解析主要包含以下几个部分:
1.AnnotationConfigApplicationContext中根据@ComponentScan扫描解析包下的类,并封装成为BeanDefinition;
2.AnnotationConfigApplicationContext中配置类常见注解如@Import、@Bean、@Component、@Service、@ComponentScan、@ImportResource等注解的解析流程以及细节;
3.标记有@Configuration注解以及无该注解的配置类的区别,以及spring针对@Configuration注解生成CGLIB代理类的流程、方法拦截以及为什么要间接的继承BeanFactoryAware,如何使用GCLIB中的方法拦截器解决@Bean标记方法可能导致实例化多个对象的问题;
4.BeanFactoryPostProcessor与BeanDefinitionRegistryPostProcessor的执行流程、区别,着重分析ConfigurationClassPostProcessor的回调方法;
5.Bean在spring中初始化流程细节;
5.spring中的BeanPostProcessor,主要分析spring是如何使用CommonAnnotationBeanPostProcessor和AutowiredAnnotationBeanPostProcessor这两个BeanPostProcessor实现对@Resource、@Autowired、@Lookup、@Value注解的支持;
6.spring中是如何使用earlySingletonObjects、singletonFactories、singletonsCurrentlyInCreation这三个集合解决Bean的循环依赖问题;
由于分析流程较多,请移步github:https://github.com/xuchuanliang/spring-framework.git 5.1.x.20200816分支中mySpring module中包含分析所用的实例代码以及分析流程,以下为部分流程截图:
若有问题,烦请指正。
若对您有帮助,帮忙star,谢谢!