- XML 解析封装BeanDefinition
断点在 DefaultListableBeanFacy, registerBeanDefinition()
二 如果给属性赋值
三 各种postprocessor
## 2、Spring套路点
- 1、AbstractBeanDefinition 看看何时给容器中注入了什么组件
- 2、BeanFactory让初始化完,监控里面多了哪些后置处理器
- 3、分析后置处理器什么时候调用,做了什么功能
> 以上所有的前提,理解**容器刷新12大步**与**getBean流程**,防止混乱
>
> 1、工厂后置处理器执行
>
> 2、bean后置处理器执行&bean的生命周期(后置处理器+InitializingBean)
1、这个新功能一般都是由 **bean的生命周期**机制增强出来的;
2、这个功能加入了哪些组件,这些组件在生命周期期间做了什么?
--------------------------------------------IOC--------------------------------------------
defautllistableBeanfactory 实现 beanfactory
beanDefinitionMap;
beanDefinitionName;
AbstractBeanFactory{
BeanFactory parentBeanFactory
List<BeanPostProcessor> beanPostProcessors
}
DefaultSingletonBeanRegistry
singletonObject
earlysingletonObject
singletonFactory
BeanDefinitionregister {
registerBeanDefinition(String beanName, BeanDefinition beanDefinition)
}
AbstractApplicationContext{
private ApplicationContext parent;
private final List<BeanFactoryPostProcessor> beanFactoryPostProcessors
}
ConfigurationClassPostProcessor
BeanDefinitionRegistryPostProcessor
BeanFactoryPostProcessor
BeanPostProcessor
InstantiationAwareBeanPostProcessor
SmartInstantiationAwareBeanPostProcessor
MergedBeanDefinitionPostProcessor
AutowiredAnnotationBeanPostProcessor
AnnotationAwareAspectJAutoProxyCreator
EventListenerMethodProcessor
DefaultEventListenerFactory
SmartInitializingSingleton
// 把每一个bean定义成beandefinition 放在defaultlistablebeanfactory
obtainFreshBeanFactory();
-------------------------------------------AOP-----------------------------------------------------
AnnotationAwareAspectJAutoProxyCreator implement beanfactoryaware
AspectJAdvisorFactory
BeanFactoryAspectJAdvisorsBuilder
//拿到工厂bean defaultlistablebeanfactory
setBeanFactory()
(2) registerBeanpostProcessor 是 getbean 会执行实例化之前的方法
implement AbstractAutoProxyCreator
Map<Object, Boolean> advisedBeans
Map<Object, Class<?>> proxyTypes
BeanFactoryAspectJAdvisorsBuilder
private final Map<String, List<Advisor>> advisorsCache
List<String> aspectBeanNames; 切面类名字
标签:xml,后置,private,bean,源码,处理器,解析,BeanDefinition From: https://www.cnblogs.com/ou-pc/p/15783300.html