当前位置:网站首页>0729放假自习
0729放假自习
2022-07-30 08:42:00 【生活可真难啊】
Bean的生命周期简述?
关键字:实例化--初始化
1.实例化Bean对象,通过反射的方式获取对象,在底层源码里面有一个CreatNewInstance的方法,用来创建对象;
2.创建对象后,对象的属性都是默认值,通过popluateBean来给对象填充属性;
3.给Bean对象赋予容器属性,需要通过invokeAwareMethdos方法来把容器属性注入给Bean对象;
4.通过BeanPostProcessor前置方法,来做一些扩展工作;例如ApplicationContextProxyCeartor;
5.初始化Bean对象,通过invokeinitMehods方法来初始化对象,执行之前需要判断是否实现了initalizingBean接口,然后执行afterpropertisSet方法;
6.通过BeanPostProcessor后置方法,来处理一些后置工作,aop就是在此实现的,实现的接口名称是AbstractAutoProxyCeartor;
7.拿到完整的对象后,通过getBean获取到了对象和处理;
8.对象使用完毕后,在容器关闭时,会摧毁对象,然后判断是否实现了DispoableBean接口,然后执行DestoryMethods方法;
Spring中用到了哪些设计模式?
工厂模式;
单例模式;
适配器模式;
装饰者模式:
观察者模式;
模板方法:
建造者模式;
Spring的事务是如何回滚的?
spring的事务是通过aop实现的,首先生成具体的代理对象,然后按照aop的整套流程来实现具体逻辑,一般情况下都是通过 通知 来完成核心功能,但是spring的事务不一样,他是通过TranstactionInterceptor来实现的,通过调用invoke方法来实现具体逻辑.在执行过程中,如果执行失败了,会通过completeTransactionAfterThrowing来实现回滚操作,然后会通过doRollback来实现具体逻辑,回滚也需要先获取连接对象,通过连接对象来回滚;
边栏推荐
猜你喜欢
【零基础玩转BLDC系列】以GD32F30x为例定时器相关功能详解
qsort 函数的使用及其模拟实现
Two solutions for Excel xlsx file not supported
Unreal Engine Graphic Notes: could not be compiled. Try rebuilding from source manually. Problem solving
Kotlin 值类 - value class
Golang DES 加解密如何实现?
How to implement Golang DES encryption and decryption?
电源完整性的去耦和层间耦合电容
Google Cloud Spanner的实践经验
仿牛客网项目第一章:开发社区首页(详细步骤和思路)
随机推荐
Golang DES 加解密如何实现?
Scala
20个电路能懂5个以上,足以证明你在电子行业混过!
leetcode-990:等式方程的可满足性
DDR、GDDR、QDR的区别
The FPGA based protocol 2: the I2C read and write E squared PROM
电路分析:运放和三极管组成的恒流源电路
经历了这样一个阶段的发展之后,数字零售才能有新的进化
Explain the problem of change exchange in simple terms - the shell of the backpack problem
How to run dist file on local computer
微软 SQL 服务器被黑,带宽遭到破坏
电源完整性的去耦和层间耦合电容
最远点采样 — D-FPS与F-FPS
ClickHouse
回板后,处理器不启动,怎么办?
Unity performance analysis Unity Profile performance analysis tool
反射技巧让你的性能提升 N 倍
Concise Notes on Integrals - Types of Curve Integrals of the First Kind
qsort 函数的使用及其模拟实现
Apache DolphinScheduler's new generation of distributed workflow task scheduling platform in practice - Part 1