您的位置:首页 > 文旅 > 美景 > spring管理bean源码解析

spring管理bean源码解析

2024/12/23 7:16:46 来源:https://blog.csdn.net/leinminna/article/details/140328235  浏览:    关键词:spring管理bean源码解析

1. 从启动类开始

public static void main(String[] args) {// Run the SpringApplication class with the Application class as the first argumentSpringApplication.run(Application.class, args);}

2. bean 实例化

// SpringAplication row=1294,1295
run()
// SpringAplication row=1035,1036
run()
// SpringAplication row=293,308
refreshContext(context);
//  SpringAplication row=404,408
refresh(context);
//  SpringAplication row=733,734
applicationContext.refresh();
//ConfigurationApplicationContext rw=201
refresh()
// AbstractApplicationContext row=545,583
finishBeanFactoryInitialization(beanFactory);
// AbstractApplicationContext row=890,918
beanFactory.preInstantiateSingletons();
// ConfigurationListableBeanFactory 160
preInstantiateSingletons();
// DefaultListableBeanFactory row=922,955
preInstantiateSingletons();
// AbstractBeanFactory row=207,208
getBean();
// AbstractBeanFactory row=248,374
goGetBean()
//AbstractBeanFactory row=2003
createBean()

3. bean 依赖注入

接上面

//AbstractBeanFactory row=2003
createBean()
//AbstractAutowireCapableBeanFactory row=503,542
createBean()
//AbstractAutowireCapableBeanFactory row=573,582
doCreateBean()
//AbstractAutowireCapableBeanFactory row=1180,1222
createBeanInstance()
//AbstractAutowireCapableBeanFactory row=1369,1372
autowireConstructor()
// ConstructorResolver row=127,181
autowireConstructor()
// ConstructorResolver row=300,311
instantiate()

4. 删除实例及其依赖实例

// DefaultSingletonBeanRegistry row=550
destroySingleton()
// DefaultSingletonBeanRegistry row=568
destroyBean()
// AbstractFactoryBean row=197
destroy()

优化中…

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com