1. BeanFactoryPostProcessor调用(见AbstractApplicationContext.refresh):
>> 创建DefaultListableBeanFactory --> loadBeanDefinitions
1)BeanDefinitionRegistryPostProcessor.postProcessBeanDefinitionRegistry(编码注册)
2)BeanDefinitionRegistryPostProcessor.postProcessBeanDefinitionRegistry(配置注册):PriorityOrdered排序 --> Ordered排序 --> 无序
3)BeanFactoryPostProcessor.postProcessBeanFactory(编码注册):BeanDefinitionRegistryPostProcessor --> BeanFactoryPostProcessor
4)BeanFactoryPostProcessor.postProcessBeanFactory(配置注册):PriorityOrdered排序 --> Ordered排序 --> 无序
2. BeanPostProcessor注册:
1)PriorityOrdered排序 --> Ordered排序 --> 无序
2)MergedBeanDefinitionPostProcessor
3. BeanPostProcessor调用(见DefaultListableBeanFactory.createBean):
1)InstantiationAwareBeanPostProcessor.applyBeanPostProcessorsBeforeInstantiation(resolveBeforeInstantiation)
>> 获取bean --> 6
>> createBeanInstance(默认:CglibSubclassingInstantiationStrategy.instantiate) --> 2
2)MergedBeanDefinitionPostProcessor.postProcessMergedBeanDefinitioInstantiationAwareBeanPostProcessor
3)InstantiationAwareBeanPostProcessor.postProcessAfterInstantiation
>> autowireByName / autowireByType
4)InstantiationAwareBeanPostProcessor.postProcessPropertyValues
>> applyPropertyValues
5)BeanPostProcessor.postProcessBeforeInitialization(@postConstruct)
>> InitializingBean.afterPropertiesSet --> invokeInitMethod(init-method )
6)BeanPostProcessor.postProcessAfterInitialization
>> 单实例(容器初始化完成):SmartInitializingSingleton.afterSingletonsInstantiated
4. 应用
1)BeanFactoryPostProcessor
2)BeanPostProcessor:ApplicationContextAwareProcessor、InitDestroyAnnotationBeanPostProcessor、AutowiredAnnotationBeanPostProcessor、AOP