spring复习:(19)单例bean是在哪里被加入到一级缓存的?

news/2025/3/19 22:16:41/

AbstractBeanFactorydoGetBean方法:
如果是第一次调用getBean时,会执行到下边的代码:
在这里插入图片描述
getSingleton的代码如下:

	public Object getSingleton(String beanName, ObjectFactory<?> singletonFactory) {Assert.notNull(beanName, "Bean name must not be null");synchronized (this.singletonObjects) {Object singletonObject = this.singletonObjects.get(beanName);if (singletonObject == null) {if (this.singletonsCurrentlyInDestruction) {throw new BeanCreationNotAllowedException(beanName,"Singleton bean creation not allowed while singletons of this factory are in destruction " +"(Do not request a bean from a BeanFactory in a destroy method implementation!)");}if (logger.isDebugEnabled()) {logger.debug("Creating shared instance of singleton bean '" + beanName + "'");}beforeSingletonCreation(beanName);boolean newSingleton = false;boolean recordSuppressedExceptions = (this.suppressedExceptions == null);if (recordSuppressedExceptions) {this.suppressedExceptions = new LinkedHashSet<>();}try {singletonObject = singletonFactory.getObject();newSingleton = true;}catch (IllegalStateException ex) {// Has the singleton object implicitly appeared in the meantime ->// if yes, proceed with it since the exception indicates that state.singletonObject = this.singletonObjects.get(beanName);if (singletonObject == null) {throw ex;}}catch (BeanCreationException ex) {if (recordSuppressedExceptions) {for (Exception suppressedException : this.suppressedExceptions) {ex.addRelatedCause(suppressedException);}}throw ex;}finally {if (recordSuppressedExceptions) {this.suppressedExceptions = null;}afterSingletonCreation(beanName);}if (newSingleton) {addSingleton(beanName, singletonObject);}}return singletonObject;}}

倒数第6行调用了addSingleton,
在这里插入图片描述

addSingleton代码如下:
在这里插入图片描述
可以看到向一级缓存singletonObjects Map put的代码。


http://www.ppmy.cn/news/861847.html

相关文章

FPGA读取尼康(Nicon)编码器MAR-M50AH方法(DSP+FPGA)

Nicon编码器MAR-M50AH读取方法&#xff08;DSPFPGA&#xff09; 编码器协议细节读取FPGA与编码器通讯硬件电路DSPFPGA读取编码器的整体框架FPGA中各模块主要部分的搭建DSP外部接口及其编码器数据解算DSP与FPGA之间的数据通讯读取实验结果 编码器协议细节 通讯波特率&#xff1…

colmap+openmvs生成ply文件用于eth3d评测

目录 1 将colmap的sfm文件转换成openmvs的输入格式2 scene.mvs文件run自己写的openMVS棋盘传播1 将colmap的sfm文件转换成openmvs的输入格式 在上图目录终端输入: ./InterfaceCOLMAP -i /home/xzx/code/openMVS_checkboard/run/electro/electro -o /home

乐队官网php源码,音乐家和乐队使用的 DWZ-M50数字无线音频套件

简介 包装内含 ZRX-HR50 数字无线半机架接收器和 ZTX-M01 数字无线手持式发射器 DWZ 数字无线麦克风系统的音频套件版本提供高品质 24 位/48KHz 线性 PCM 数字传输&#xff0c;而且可最多进行六个通道同时传输。采用可对音质进行自定义的 5 波段均衡器&#xff0c;提高了控制性…

沛翎个展在M50拉开帷幕

上海2018年9月20日电 /美通社/ -- 近期&#xff0c;ARTSEE旗下艺术家沛翎的第一次个展在 M50 拉开帷幕&#xff0c;为了这场展览沛翎闭关画画了一个半月&#xff0c;一个半月后展览顺利开幕&#xff0c;展览消息登上了纽约时代广场。 纽约时代广场的海报 沛翎的作品带给人自由自…

宽带常见的有20 30 50 100兆指的是什么意思???

宽带常见的有20 30 50 100兆宽带&#xff0c;那么我们需要了解到下面的: 1. 20 30 50 100“兆”是什么&#xff1f; 100M其实是100M Byte&#xff0c;我们所说的网速是指的Bit&#xff0c;而1Bit 8 Byte&#xff0c;所以100M其实是12.5M的网速&#xff0c;但实际可能达不到。…

人们日常所用的时间是

人们日常所用的时间是 C平太阳时 C平太阳时   太阳时系统包括真太阳时、平太阳时和区时   恒星时&#xff1a;是春分点距子午圈的时角。对应于地球上每一个地方子午圈存在一种地方恒星时。恒星时是世界时0时&#xff08;北京时间8时&#xff09; 的格林尼治恒星时。粗略地说…

fillcolor是什么意思_SVG fill 属性

SVG fill 属性 SVG形状的fill定义了其轮廓内的形状的颜色。换句话说,SVG形状的表面。填充是您可以为任何SVG形状设置的基本SVG CSS属性之一。 Fill示例 SVG形状的填充是形状轮廓内的填充。这是一个SVG填充示例: 示例 style="stroke: none; fill: #0000ff;" />测…

TrueNAS Enterprise是什么

TrueNAS Enterprise是专为关键存储应用程序而设计,可作为混合和全闪存存储系统使用,这些系统提供高可用性,生态系统认证(VMware,Citrix等),增强的性能以及全面的企业支持。 TrueNAS Enterprise 是专为关键存储应用程序而设计,可作为混合和全闪存存储系统使用,这些系统…