Spring源码解析 - ListableBeanFactory

IPD(集成产品开发)管理之道 IPD,是集成产品开发(Integrated Product Development)的缩写,它是集成了众多管理模型和理论、众多企业最佳管理实践的一整套体系,可以帮助企业快速响应市场变化、缩短产品上市时间、减少资源浪费、提高生产力,最终取得商业成功。IPD的思想最早来源于美国PRTM公司出版的《产品及生命周期优化法》一书中,该书详细描述了IPD模式所包含的各个方面。但IPD在中国的普及,源于IBM和华为的推行使用。IPD作为一套先进的产品研发管理模式,其成功的基础是功能部门和各团队之间的密切配合。 阅读详情

Spring源码解析 - ListableBeanFactory

 

Extension of the {@link BeanFactory} interface to be implemented by bean factories
that can enumerate all their bean instances, rather than attempting bean lookup
by name one by one as requested by clients. BeanFactory implementations that
preload all their bean definitions (such as XML-based factories) may implement
this interface.

扩展BeanFactory接口,提供所有bean 实例的枚举,不再需要客户端通过一个个bean name查找.BeanFactory实现类预加载bean定义(如通过实现xml的工厂)需要实现这个接口.

If this is a {@link HierarchicalBeanFactory}, the return values will <i>not</i>
take any BeanFactory hierarchy into account, but will relate only to the beans
defined in the current factory. Use the {@link BeanFactoryUtils} helper class
to consider beans in ancestor factories too.
如果一样实现了HierarchicalBeanFactory,返回值不会考虑父类BeanFactory,只考虑当前factory定义的类.当然也可以使用BeanFactoryUtils辅助类来查找祖先工厂中的类.

The methods in this interface will just respect bean definitions of this factory.
They will ignore any singleton beans that have been registered by other means like
{@link org.springframework.beans.factory.config.ConfigurableBeanFactory}'s
{@code registerSingleton} method, with the exception of
{@code getBeanNamesOfType} and {@code getBeansOfType} which will check
such manually registered singletons too. Of course, BeanFactory's {@code getBean}
does allow transparent access to such special beans as well. However, in typical
scenarios, all beans will be defined by external bean definitions anyway, so most
applications don't need to worry about this differentation.

这个接口中的方法只会考虑本factory定义的bean.这些方法会忽略ConfigurableBeanFactory的registerSingleton注册的单例bean,getBeanNamesOfType和getBeansOfType是例外,一样会考虑手动注册的单例.当然BeanFactory的getBean一样可以透明访问这些特殊bean.当然在典型情况下,所有的bean都是由external bean定义,所以应用不需要顾虑这些差别.
<b>NOTE:</b> With the exception of {@code getBeanDefinitionCount}
and {@code containsBeanDefinition}, the methods in this interface
are not designed for frequent invocation. Implementations may be slow.

注意:getBeanDefinitionCount和containsBeanDefinition的实现方法因为效率比较低,并不是供频繁调用的.

 

 

复制代码
  1 package org.springframework.beans.factory;
  2 public interface ListableBeanFactory extends BeanFactory {
  3 
  4     /**
  5      * 检查bean factory是否含有给定name的bean定义.
  6      * 忽略父factory和其他factory注册的单例bean
  7      * @param beanName the name of the bean to look for
  8      * @return if this bean factory contains a bean definition with the given name
  9      * @see #containsBean
 10      */
 11     boolean containsBeanDefinition(String beanName);
 12 
 13     /**
 14      * factory中定义的bean数量
 15      * 一样不考虑父factory和其他factory注册的单例bean
 16      * @return the number of beans defined in the factory
 17      */
 18     int getBeanDefinitionCount();
 19 
 20     /**
 21      * 获取工厂中定义的所有bean 的name
 22      * 一样不考虑父factory和其他factory注册的单例bean
 23      * @return the names of all beans defined in this factory,
 24      * or an empty array if none defined
 25      */
 26     String[] getBeanDefinitionNames();
 27 
 28     /**
 29      * 获取给定类型的bean names(包括子类),通过bean 定义或者FactoryBean的getObjectType判断.
 30      * 注意:这个方法仅检查顶级bean.它不会检查嵌套的bean.
 31      * FactoryBean创建的bean会匹配为FactoryBean而不是原始类型.
 32      * 一样不会考虑父factory中的bean,可以使用BeanFactoryUtils中的beanNamesForTypeIncludingAncestors.
 33      * 其他方式注册的单例这边会纳入判断.
 34      * 这个版本的getBeanNamesForType会匹配所有类型的bean,包括单例,原型,FactoryBean.在大多数实现中返回结果跟getBeanNamesOfType(type,true,true)一样.
 35      * 返回的bean names会根据backend 配置的进行排序.
 36      * @param type the class or interface to match, or {@code null} for all bean names
 37      * @return the names of beans (or objects created by FactoryBeans) matching
 38      * the given object type (including subclasses), or an empty array if none
 39      * @see FactoryBean#getObjectType
 40      * @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class)
 41      */
 42     String[] getBeanNamesForType(Class<?> type);
 43 
 44     /**
 45      * 
 46      * @param type the class or interface to match, or {@code null} for all bean names
 47      * @param includeNonSingletons是否只要单例(包括BeanFactory),还是原型或其他作用域的bean一样包括
 48      * @param allowEagerInit 是否初始化懒加载的单例,FactoryBean初始化的类和工厂方法初始化的类.就是说执行这个方法会执行对应的初始化.
 49      * @return the names of beans (or objects created by FactoryBeans) matching
 50      * the given object type (including subclasses), or an empty array if none
 51      * @see FactoryBean#getObjectType
 52      * @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean)
 53      */
 54     String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit);
 55 
 56     /**
 57      * 
 58      * @param type the class or interface to match, or {@code null} for all concrete beans
 59      * @return a Map with the matching beans, containing the bean names as
 60      * keys and the corresponding bean instances as values
 61      * @throws BeansException if a bean could not be created
 62      * @since 1.1.2
 63      * @see FactoryBean#getObjectType
 64      * @see BeanFactoryUtils#beansOfTypeIncludingAncestors(ListableBeanFactory, Class)
 65      */
 66     <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException;
 67 
 68     /**
 69      * 
 70      * @param type the class or interface to match, or {@code null} for all concrete beans
 71      * @param includeNonSingletons whether to include prototype or scoped beans too
 72      * or just singletons (also applies to FactoryBeans)
 73      * @param allowEagerInit whether to initialize <i>lazy-init singletons</i> and
 74      * <i>objects created by FactoryBeans</i> (or by factory methods with a
 75      * "factory-bean" reference) for the type check. Note that FactoryBeans need to be
 76      * eagerly initialized to determine their type: So be aware that passing in "true"
 77      * for this flag will initialize FactoryBeans and "factory-bean" references.
 78      * @return a Map with the matching beans, containing the bean names as
 79      * keys and the corresponding bean instances as values
 80      * @throws BeansException if a bean could not be created
 81      * @see FactoryBean#getObjectType
 82      * @see BeanFactoryUtils#beansOfTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean)
 83      */
 84     <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
 85             throws BeansException;
 86 
 87     /**
 88      * 找到使用注解的类.
 89      * @param annotationType the type of annotation to look for
 90      * @return a Map with the matching beans, containing the bean names as
 91      * keys and the corresponding bean instances as values
 92      * @throws BeansException if a bean could not be created
 93      */
 94     Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType)
 95             throws BeansException;
 96 
 97     /**
 98      * 查找一个类上的注解,如果找不到,父类,接口使用注解也算.
 99      * @param beanName the name of the bean to look for annotations on
100      * @param annotationType the annotation class to look for
101      * @return the annotation of the given type found, or {@code null}
102      */
103     <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType);
104 
105 }
复制代码

 

分类:  spring
【Matlab】matlab代码实现sph溃坝模拟 本文介绍了一个基于MATLAB的SPH溃坝模拟实现。代码使用平滑粒子流体动力学方法,通过建立1000个随机分布的粒子,计算粒子间的相互作用力来模拟流体运动。模拟过程包括初始化参数、粒子创建、密度压力更新、速度位置计算以及可视化展示。核心算法采用poly6Kernel和spikyKernelGradient函数处理粒子间作用力。该示例为二维简化模型,仅包含基本物理参数和计算流程,实际应用需进一步优化扩展。 阅读详情

相关推荐

zemax混合式非序列模拟

注意不要点击左侧的非序列模式,那个时纯粹的非序列,会清除序列模式的数据。第2、4、6透镜材质为空气,是为了让光线进入到多重透镜内部。这时普通的优化方式会失败。平行光束经过多焦透镜时,会汇聚在不同焦距处。所以还需要控制能量的大小,进行优化。接下来用非序列模式设计一个多焦透镜。像面的孔径为圆形通光孔:0-1.2。透镜不同位置处有不同的聚焦位置。透镜的z轴位置相同,重合。

fendoudecheng的博客 3067

spring组件之BeanFactory

从名称上来看,它的意思是bean 工厂,它是生产 bean与保存 bean (针对单例 bean)的地方。我们先来看看/*** factoryBean使用*//*** 根据名称获取bean*//*** 根据名称获取bean*//*** 根据名称获取bean*//*** 根据类型获取bean*//*** 根据类型获取bean*//*** 获取BeanProvider*//*** 获取BeanProvider*//*** 是否包含bean。

Huangjiazhen711的博客 435

R语言实战:5分钟搞定GEO单细胞数据(scRNA-seq)下载与整理(附完整代码)

本文详细介绍了如何使用R语言快速下载和整理GEO单细胞数据(scRNA-seq),提供完整的自动化处理代码。从环境准备、数据获取到文件整理和质量检查,涵盖10X Genomics标准格式及非标准数据的处理技巧,帮助生物信息学研究者高效完成数据预处理工作。

weixin_29054399的博客 604

ESP32-S3 Mini vs ESP32-C3 Mini 采购指南:PSRAM、USB OTG 与选型要点

在嵌入式开发中,MCU 选型直接影响项目成败。ESP32 系列芯片凭借 WiFi 和蓝牙集成,成为物联网设备首选。其核心原理是通过双核或单核架构,配合 PSRAM 扩展内存,解决图像、语音等大数据处理瓶颈。技术价值在于平衡性能与成本,例如 ESP32-S3 Mini 支持 USB OTG 和 PSRAM,适合摄像头、屏幕等场景;而 ESP32-C3 Mini 以轻量联网见长。应用场景涵盖智能家居、传感器节点和 USB 设备。采购时需关注 PSRAM 容量、USB 类型和天线形式,避免常见坑点。

weixin_34319817的博客 400

基于小波变换的信号降噪处理及仿真研究_信号处理方法推荐--1(转载自用,侵删)...

综述作者:aresmiki链接:https://www.zhihu.com/question/23701194/answer/167005497来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。非平稳信号处理应该是现在信号处理技术最新的也是最热的研究方向了,信号处理方法从最早的时域统计到傅里叶变换的频域分析,是人们认识信号本质的一次巨大飞跃,给了分析人员换个角度看世界的...

weixin_32144483的博客 1249

[pytorch] MedicalNet 3D Resnet预训练模型迁移学习实战:从分割到分类的代码改造

本文详细介绍了如何利用PyTorch对MedicalNet 3D ResNet预训练模型进行迁移学习,从分割任务改造为分类任务。通过解析模型结构、调整分类头、加载预训练权重及优化训练策略,帮助开发者在医疗影像领域快速实现高效模型部署。文章还涵盖了数据预处理、增强技巧及模型轻量化等实用内容。

kmeans3miner的博客 246

ListableBeanFactory

ListableBeanFactory接口是BeanFactory接口的一个扩展,所有能列举其包含的所有Bean而非容器都应该实现此接口。/** * Extension of the {@link BeanFactory} interface to be implemented by bean factories * that can enumerate all their bean insta

树上骑个猴 3856

android 运动目标检测_MindSpore应用案例:AI对篮球运动员目标的检测

MindSpore作为一个端边云协同的开源的全场景AI框架,今年3月份开源以来,受到了业界的广泛关注和应用,欢迎大家参与开源贡献、模型众智合作、行业创新与应用、学术合作等,贡献您在云侧、端侧 (HiMindSpore 应用程序)、边侧以及安全领域的应用案例。MindSpore与您在AI领域共同成长,让AI使能千行百业,释放出强大的生产力。本文讲述的是MindSpore对篮球运动员目标的检测应用,通...

weixin_33603813的博客 835

Spring IoC 容器(四)ListableBeanFactory

ListableBeanFactory ListableBeanFactory是beanFactory接口的扩展接口,它可以枚举所有的bean实例,而不是客户端通过名称一个一个的查询得出所有的实例。要预加载所有的bean定义的beanfactory可以实现这个接口来。该 接口定义了访问容器中Bean基本信息的若干方法,如查看Bean的个数、获取某一类型Bean的配置名、查看容器中是否包括某一Bean等方法。 public interface ListableBeanFactory extends BeanF

wumenghao的博客 770

Android音频输出流实战:从AudioFlinger到HAL层的完整调用链解析

本文深入解析了Android音频输出流的完整调用链,从应用层的AudioTrack和AAudio API,到系统服务AudioFlinger的混音调度,最终抵达硬件抽象层(HAL)。文章结合实战经验,探讨了如何利用底层机制优化音频延迟、处理设备切换,并提供了性能调优与问题排查的具体方法,是开发高性能音频应用的实用指南。

weixin_29208327的博客 252

C# 上位机 YOLO 实战:从数据采集到目标识别的全流程拆解

本文以工业螺栓缺陷检测为例,完整拆解了C#上位机+YOLO从数据采集到目标识别的全流程。数据采集:保证图像质量,线程安全采集,必要时归档数据;预处理:适配YOLO模型输入格式,复用对象减少内存开销;推理解析:正确解析张量结果,过滤低置信度目标;落地环节:可视化展示结果,实现工业交互和日志记录。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 1454

ListableBeanFactory学习

Spring之ListableBeanFactory

weixin_44877172的博客 808

科研级YOLOv8 Neck革新:BiFPN双向特征金字塔赋能,让多尺度融合更高效的实战指南

在文件夹下新建BiFPN.py,将上述BiFPNLayer和BiFPN类的代码写入其中。这一步是为了让YOLOv8的代码架构能识别我们的自定义Neck模块。

m0_64661770的博客 153

Spring BeanFactory源码学习

一.BeanFactory   BeanFactory是Spring IOC容器的基础,是IOC容器的基础接口,所有的容器都是从它这里继承实现而来。BeanFactory提供了最基本的IOC容器的功能,即所有的容器至少需要实现的标准。BeanFactory体系结构是典型的工厂方法模式,即什么样的工厂生产什么样的产品。BeanFactory是最基本的抽象工厂,而其他的IOC容器只不过是具体的工厂,对...

weixin_33832340的博客 106

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

Spring IOC源码之容器的体系结构

​本文是以spring5.0.2.RELEASE版本说明spring源码,以xml配置的方式来说明IOC容器原理,将bean信息注册到容器当中,再对容器中的bean进行实例化,本文主要介绍bean注册到容器的过程。在阅读spring源码之前建议先阅读下JSR规范,这样更容易理解源码. 一,beanFactory体系结构 BeanFactory是所有bean工厂的顶级接口,ListableB...

hansmall的博客 264

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Spring源码解析之DefaultListableBeanFactory

spring Ioc容器的实现,从根源上是beanfactory,但真正可以作为一个可以独立使用的ioc容器还是DefaultListableBeanFactory,因此可以这么说, DefaultListableBeanFactory 是整个spring ioc的始祖,研究透它的前生今世对我们理解spring ioc的概念有着重要的作用。 1.DefaultListableBeanFa...

欧阳俞峰的个人博客 576

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

ApplicationContext接口解读

在使用Spring的时候,我们经常需要先得到一个ApplicationContext对象,然后从该上下文中获取我们配置的Bean对象。我们知道ApplicationContext是一个接口,实现了改接口的实现类都可以看作一个IOC容器,我们可以从ApplicationContext中拿到注册的Beans。ApplicationContext隶属于org.springframework.context,是SpringFramework中Bean的管理者,为SpringFramework的诸多功能提供支撑作用。

qq_43203949的博客 1512

spring4.2源码分析(一)组件-BeanFactory系列(2-ListableBeanFactory)

(2)ListableBeanFactory extends BeanFactory功能说明       总结:提供获取满足条件的bean对象列表和bean相关属性列表;       ----扩展BeanFactory接口功能     (1)实现可枚举所有bean实例,而不是根据客户端请求通过beanname一个一个查找实例;     (2)BeanFactory实现预加载所有bean定义(如基于...

long_long3的博客 436

spring源码分析————ListableBeanFactory

本文介绍了Spring框架中的ListableBeanFactory接口,该接口扩展了BeanFactory,提供了以列表形式获取bean定义的功能。文章从基本描述、主要功能、接口源码、实现类、最佳实践等多个维度展开,重点讲解了该接口的核心方法如获取bean数量、名称、按类型/注解过滤等能力。通过示例代码展示了如何在实际开发中使用这些功能进行bean的动态管理和处理。同时,文章还分析了ListableBeanFactory与其他Spring组件的关系,并总结了常见问题及解决方案。该接口为Spring容器提供

hi 1075

Spring源码学习--ListableBeanFactory接口

文章引用: https://www.cnblogs.com/leftthen/p/5261837.html ListableBeanFactory获取bean时,Spring 鼓励使用这个接口定义的api. 还有个Beanfactory方便使用.其他的4个接口都是不鼓励使用的. 提供容器中bean迭代的功能,不再需要一个个bean地查找.比如可以一次获取全部的bean(太暴力了)...

DemoTransfer 9275

重看Spring聚焦BeanFactory分析

本文探讨了 Spring 框架中的 BeanFactory 接口及其实现,强调其在对象创建和依赖注入中的关键作用。通过分析 XmlBeanFactory、DefaultListableBeanFactory 和 AbstractApplicationContext 等不同实现,文章展示了它们在资源管理和对象生命周期控制中的应用。理解 BeanFactory 的工作原理有助于开发者构建高效、可扩展的 Java 应用,推动现代软件开发的创新。

曾经“等你生日那天”都遥远得像未来,如今却可欢愉的挥手说“下个十年见” 10万+

Spring源码分析之BeanFactory接口的解析

在我们的前两篇文章当中我们看完之后其实我们都会发现当我们进行相关的重要的行为的时候如我们看到的GetBean或者在Register方法的时候会出现BeanFactroy进行调用那么这个时候我们就会产生一个疑惑这个到底是什么为什么这么重要,在我没有说的时候我们从字面上进行一个简单的分析就是说这个是一个Bean工厂那么工厂不就是用来进行加工的那么加工肯定是需要原料以及加工流程的这么想的话其实已经把这个功能基本上都全部进行概括了,那么下面的话我们就来进行解说。

2201_75397629的博客 1511

Spring源码阅读-BeanFactory子接口ListableBeanFactory

package org.springframework.beans.factory;import java.lang.annotation.Annotation; import java.util.Map;import org.springframework.beans.BeansException; import org.springframework.core.ResolvableType;/*

iycynna_123的博客 3712

Spring源码解析

综上所述,我们的IOC容器既是bean工厂、资源加载器、又是bean档案馆,同时又实现了bean定义信息的注册如下图在这里插入图片描述。

weixin_50835044的博客 856

BeanFactory容器之AutowireCapableBeanFactory、HierarchicalBeanFactory、ListableBeanFactory

一、AutowireCapableBeanFactory:提供了自动装配Bean的实现,提供bean创建(带有构造函数解析)、属性填充、连接(包括自动装配)和初始化。处理运行时bean引用、解析托管集合、调用初始化方法等。支持自动装配构造函数、按名称的属性和按类型的属性。 其通过实现类AbstractAutowireCapableBeanFactory 实现bean的创建,对应源码: ...

冷月的编程学习 1111

spring源码--BeanFactory、AutowireCapableBeanFactory、HierarchicalBeanFactory、ListableBeanFactory...

spring源码解读-----基础的接口 BeanFactory、AutowireCapableBeanFactory、HierarchicalBeanFactory、ListableBeanFactory、ConfigurableBeanFactory、ConfigurableListableBeanFactory 1. BeanFactory BeanFactory是Spring be...

少健终望成,波中取千金----张少波 2177
上一篇: ApplicationContext介绍
下一篇: HierarchicalBeanFactory
javaPie
博客等级 码龄16年 1171粉丝 43原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值