注册bean的后置处理器,使得bean工厂可以修改bean的初始化过程,找到容器中所有实现BeanPostProcessor的类进行排序注册
基本逻辑和上一章差不多
先注册实现了PriorityOrdered接口的BeanPostProcessor,再注册实现了Ordered接口的的BeanPostProcessor,然后注册什么接口都没实现的BeanPostProcessor,最后注册实现了MergedBeanDefinitionPostProcessor接口的BeanPostProcessor
AbstractAutowireCapableBeanFactory initializeBean
public interface BeanPostProcessor {
Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException;
Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException;
}
postProcessBeforeInitialization:实例化之后 初始化之前执行
postProcessAfterInitialization:实例化之后 初始化之后执行的
后面我们再说说 internalAutowiredAnnotationProcessor、internalCommonAnnotationProcessor等类的实现