当前位置:网站首页>Bena's life cycle
Bena's life cycle
2022-08-02 23:33:00 【blanceage】
Bean's Lifecycle
- Prepare to create
- Create instantiation
- Dependency Injection
- Container cache
- Destroy the instance
The life cycle of a bean can be divided into five stages, namely preparation before creation, creation and instantiation, dependency injection, container cache, and instance destruction.
Preparation before creation
The main function of this stage is to parse and find Bean-related extension implementations from the context and some configurations before the Bean starts to load.For example, like init-method, a method that the container will call when initializing a bean; destroy-method, a method that the container will call when destroying a bean; and BeanFactoryPostProcessor(), an extension class method provided by spring.Some pre- and post-processing extensions in this type of bean loading process are implemented. These classes or configurations are actually provided by Spring for us to implement some extensions in the bean loading process. In the middle of many integrations with Springitems are also relatively common.
Create instantiation
The second stage is to create an instance. The main function of this stage is to create an instance object of the Bean through reflection.And will scan and parse some properties of the Bean name.When this step is completed, the Bean object has been created, but the Spring Bean is not used externally.
Dependency injection
The third stage is the dependency injection stage. If the instantiated bean depends on other beans, object injection needs to be performed on these dependent beans.For example, some configuration forms such as common @Autowired annotation injection or setter() injection in xml files.At the same time, some extension calls will be triggered at this stage, for example, the common extension class BeanPostProcessors post-processor is used to implement extension callbacks before and after Bean initialization, as well as BeanFactoryAware, etc.
Container cache
The fourth stage is the container cache stage. The main function of this stage is to save the beans in the container and Spring's cache.At this stage, the Bean can actually be called by the developer.The operations involved in this stage are common such as init-method, some methods configured by this property will be called in this stage; and post-processor methods like BeanPostProcessoes will also be triggered in this stage.
Destroy the instance
The fifth stage is to destroy the instance. When the Spring application context is closed, all the beans in the context will be destroyed. If there is a bean configurationThese methods of destroy-method will be called at this stage.
边栏推荐
- 信息学奥赛一本通(1260:【例9.4】拦截导弹(Noip1999))
- [21 Days Learning Challenge] Bubble Sort and Insertion Sort
- The time series database has been developed for 5 years. What problem does it need to solve?
- 你是几星测试/开发程序员?技术型选手王大拿......
- .NET性能优化-你应该为集合类型设置初始大小
- 太魔人招新啦|快来加入我们吧!
- PyTorch分布式backends
- 美国爱荷华州立大学| Improving Distantly Supervised Relation Extraction by Natural Language Inference(通过自然语言推理改进远程监督关系提取)
- golang源码分析之geoip2-golang
- 引用类型 ,值类型 ,小坑。
猜你喜欢
Parse the commonly used methods in the List interface that are overridden by subclasses
TPAMI2022 | TransCL: based on the study the compression of the Transformer, more flexible and more powerful
广东省数字经济发展指引 1.0之建成数据安全保障体系
OP-5,输入/输出信号范围-一信号处理能力
OP analysis and design
unittest自动化测试框架总结
接口测试常用工具及测试方法(入门篇)
LeetCode:622. 设计循环队列【模拟循环队列】
J9 digital theory: the Internet across chain bridge has what effect?
Triacetin是什么化学材料
随机推荐
J9 Digital Currency Theory: Identifying Web3's New Scarcity: Open Source Developers
五大维度解读软件测试分类
Leetcode刷题——23. 合并K个升序链表
如何解决图像分类中的类别不均衡问题?不妨试试分开学习表征和分类器
Introduction of uncommon interfaces of openlayers
【 LeetCode 】 1374. Generate each character string is an odd number
SQL Server实现group_concat功能
二丙二醇甲醚醋酸酯
Bena的生命周期
SQL Server数据类型转换函数cast()和convert()详解
云平台简介
EasyExcel实现动态列解析和存表
网上那么多教人赚钱的方法,但是你实际上是靠什么赚钱的呢?
Parse the commonly used methods in the List interface that are overridden by subclasses
unittest自动化测试框架总结
4 kmiles join YiSheng group, with more strong ability of digital business, accelerate China's cross-border electricity full domain full growth
浅议.NET遗留应用改造
你所不知道的C#中的细节
Parse common methods in the Collection interface that are overridden by subclasses
Informatics Olympiad All-in-One (1259: [Example 9.3] Find the longest non-descending sequence)