Spring中Bean生命周期时序图
2021-12-30 17:35:48 12 举报
Spring中Bean生命周期时序图
作者其他创作
大纲/内容
invokeBeanFactoryPostProcessors
postProcessAfterInstantiation
doGetBean
postProcessAfterInitialization
init-method配置的方法
Bean实例化阶段
调用构造方法
getBean(name)
AbstractBeanFactory
返回false则直接返回,不再执行依赖注入等操作
createBean
BeanFactoryPostProcessor实现类
容器初始化阶段
AbstractApplicationContext
BeanClassLoaderAware
返回对象实例不为空,则调用applyBeanPostProcessorsAfterInitialization方法
执行postProcessBeanFactory方法
applyBeanPostProcessorsBeforeInstantiation
applyBeanPostProcessorsBeforeInitialization
registerBeanPostProcessors
Bean对象
postProcessProperties
postProcessBeforeInstantiation
resolveBeforeInstantiation
返回true,继续执行
obtainFreshBeanFactory
setBeanFactory
populateBean
Bean初始化阶段
BeanDefinition在此步骤进行封装
doCreateBean
postProcessBeforeInitialization
Bean的依赖注入步骤
对象实例不为空,直接返回
InitializingBean实现类
BeanPostProcessor实现类
BeanNameAware
afterPropertiesSet
setBeanName
BeanPostProcessors实现类
initializeBean
applyBeanPostProcessorsAfterInitialization
setBeanClassLoader
InstantiationAwareBeanPostProcessor实现类
refresh()
AbstractAutowireCapableBeanFactory
BeanFactoryAware
invokeInitMethods
invokeAwareMethods
0 条评论
下一页