美文网首页
Spring hook

Spring hook

作者: 其_cd6b | 来源:发表于2018-05-07 17:17 被阅读0次

书写顺序即为调用顺序


BeanDefinitionRegistryPostProcessor   ->postProcessBeanFactory(先调用BeanDefinitionRegistry的Factory后置处理器)

BeanFactoryPostProcessor ->postProcessBeanFactory(后调用普通的Factory后置处理器)

调用入口application ->refresh:

invokeBeanFactoryPostProcessors(beanFactory);


调用入口application ->refresh:

onRefresh();

getBean():

BeanPostProcessor ->实例化前后

postProcessBeforeInitialization(The bean will already be populated with propertyvalues)

postProcessAfterInitialization(The bean will already be populated with propertyvalues)

InstantiationAwareBeanPostProcessor

postProcessBeforeInstantiation ->动态代理

postProcessAfterInstantiation (Modify the state of the bean before properties are set)-> populateBean


postProcessPropertyValues(Before the factory applies them To the given bean)->populateBean ->AutowiredAnnotationBeanPostProcessor(autowire自动注入)


SmartInitializingSingleton->afterSingletonsInstantiated (所有non-lazy 初始化之后调用)

调用入口application ->refresh:

//Instantiateallremaining(non-lazy-init)singletons.

finishBeanFactoryInitialization(beanFactory);


Spring Bean 生命周期:

相关文章

网友评论

      本文标题:Spring hook

      本文链接:https://www.haomeiwen.com/subject/osevrftx.html