当前位置:网站首页>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.
边栏推荐
- 美国爱荷华州立大学| Improving Distantly Supervised Relation Extraction by Natural Language Inference(通过自然语言推理改进远程监督关系提取)
- APP自动化uiautomator2获取toast
- Likou Question of the Day - Day 46 - 344. Reverse Strings
- 什么是 IDE
- 4 kmiles join YiSheng group, with more strong ability of digital business, accelerate China's cross-border electricity full domain full growth
- pytorch的tensor创建和操作记录
- 遇上Mysql亿级优化,怎么办
- 信息学奥赛一本通(1258:【例9.2】数字金字塔)
- LeetCode 622 设计循环队列[数组 队列] HERODING的LeetCode之路
- PyTorch分布式backends
猜你喜欢
OpenCV开发中的内存管理问题
特拉维夫大学 | Efficient Long-Text Understanding with Short-Text Models(使用短文本模型进行高效的长文本理解)
56.【全局变量和局部变量专题】
iframe------------frame-
SQL 嵌套 N 层太长太难写怎么办?
Translate My Wonderful | July Moli Translation Program Winners Announced
4 kmiles join YiSheng group, with more strong ability of digital business, accelerate China's cross-border electricity full domain full growth
开关、电机、断路器、电热偶、电表接线图大全
TPAMI2022 | TransCL: based on the study the compression of the Transformer, more flexible and more powerful
.NET如何快速比较两个byte数组是否相等
随机推荐
牛客题目——滑动窗口的最大值、矩阵最长递增路径、顺时针旋转矩阵、接雨水问题
Introduction of uncommon interfaces of openlayers
Qt提升自定义控件,找不到头文件
GNN教程:图神经网络基础知识!
setup syntax sugar defineProps defineEmits defineExpose
Fiddle设置接口数据用指定工具查看;Sublime Text设置json数据格式化转换
SQL 嵌套 N 层太长太难写怎么办?
「每周译Go」这次我们来点不一样的!--《How to Code in Go》系列上线
李沐动手学深度学习V2-BERT预训练和代码实现
信息学奥赛一本通(1257:Knight Moves)
9,共模抑制比一-不受输入信号中共模波动的影响。【如何分析共模CM抑制比。】
网上那么多教人赚钱的方法,但是你实际上是靠什么赚钱的呢?
二丙二醇甲醚醋酸酯
【SLAM】DM-VIO(ros版)安装和论文解读
训练双塔检索模型,可以不用query-doc样本了?明星机构联合发文
【LeetCode】1161. 最大层内元素和
Wintun:一款惊艳的 WireGuard 虚拟网卡接口驱动
[AnXun cup 2019] easy_web
OP-5,输入/输出信号范围-一信号处理能力
Xcode13.1运行工程报错fatal error: ‘IFlyMSC/IFly.h‘ file not found的问题