HierarchicalBeanFactory:HierarchicalBeanFactory继承BeanFactory并扩展使其支持层级结构。getParentBeanFactory()方法或者父级BeanFactory,containsLocalBean(String name)方法查看当前BeanFactory是否包含给定名字的Bean,不会递归想父级查找。


HierarchicalBeanFactory源码具体:

  1、第一个方法返回本Bean工厂的父工厂。这个方法实现了工厂的分层。

  2、第二个方法判断本地工厂是否包含这个Bean(忽略其他所有父工厂)。这也是分层思想的体现。

总结:这个工厂接口非常简单,实现了Bean工厂的分层。这个工厂接口也是继承自BeanFacotory,也是一个二级接口,相对于父接口,它只扩展了一个重要的功能——工厂分层。

/**
* Sub-interface implemented by bean factories that can be part
* of a hierarchy.
*
* <p>The corresponding {@code setParentBeanFactory} method for bean
* factories that allow setting the parent in a configurable
* fashion can be found in the ConfigurableBeanFactory interface.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @since 07.07.2003
* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory
*/
public interface HierarchicalBeanFactory extends BeanFactory { /**
* Return the parent bean factory, or {@code null} if there is none.
*/
//返回本Bean工厂的父工厂
BeanFactory getParentBeanFactory(); /**
* Return whether the local bean factory contains a bean of the given name,
* ignoring beans defined in ancestor contexts.
* <p>This is an alternative to {@code containsBean}, ignoring a bean
* of the given name from an ancestor bean factory.
* @param name the name of the bean to query
* @return whether a bean with the given name is defined in the local factory
* @see BeanFactory#containsBean
*/
//本地工厂(容器)是否包含这个Bean
boolean containsLocalBean(String name); }
 

Spring之2:HierarchicalBeanFactory接口的更多相关文章

  1. spring源码 HierarchicalBeanFactory接口

    HierarchicalBeanFactory 表示的是这些 Bean 是有继承关系的,也就是每个Bean 有可能有父 Bean. /* * Copyright 2002-2012 the origi ...

  2. Spring AOP在函数接口调用性能分析及其日志处理方面的应用

    面向切面编程可以实现在不修改原来代码的情况下,增加我们所需的业务处理逻辑,比如:添加日志.本文AOP实例是基于Aspect Around注解实现的,我们需要在调用API函数的时候,统计函数调用的具体信 ...

  3. spring中的aware接口

    1.实现了相应的aware接口,这个类就获取了相应的资源. 2.spring中有很多aware接口,包括applicationContextAware接口,和BeanNameAware接口. 实现了这 ...

  4. spring中基础核心接口总结

    spring中基础核心接口总结理解这几个接口,及其实现类就可以快速了解spring,具体的用法参考其他spring资料 1.BeanFactory最基础最核心的接口重要的实现类有:XmlBeanFac ...

  5. Spring Boot 之:接口参数校验

    Spring Boot 之:接口参数校验,学习资料 网址 SpringBoot(八) JSR-303 数据验证(写的比较好) https://qq343509740.gitee.io/2018/07/ ...

  6. 谈谈Spring中的BeanPostProcessor接口

    一.前言   这几天正在复习Spring的相关内容,在了解bean的生命周期的时候,发现其中涉及到一个特殊的接口--BeanPostProcessor接口.由于网上没有找到比较好的博客,所有最后花了好 ...

  7. Spring的三大核心接口——BeanFactory、ApplicationContext、WebApplicationContext

    之前也在用这三个接口,但是对于他们的概念还是处于朦胧状态,同时,也不知道他们之间是一个什么关系,趁着现在有点时间总结一下吧,也需要对你有所帮助.一.BeanFactory       基本认识:    ...

  8. 通过拦截器Interceptor实现Spring MVC中Controller接口访问信息的记录

    java web工程项目使用了Spring+Spring MVC+Hibernate的结构,在Controller中的方法都是用于处理前端的访问信息,Controller通过调用Service进行业务 ...

  9. Swagger+Spring mvc生成Restful接口文档

    简介 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...

随机推荐

  1. android studio 使用第三方模拟器连接方法

    安装完模拟器后,要使用adb命令Android studio才能识别出来: 打开cmd,输入:adb connect 127.0.0.1:26944.如下: 海马玩模拟器的端口号是26944. 逍遥安 ...

  2. [Shell]MySql慢查询日志GetShell

    通过开启慢查询日志,配置可解析日志文件GETSHELL. MySQL的慢查询日志是MySQL提供的一种日志记录,它用来记录在MySQL中响应时间超过阀值的语句. long_query_time的默认值 ...

  3. OSPF外部实验详解

  4. Git的使用(6) —— 自动填写远端Git用户名密码

    1. 问题描述 公司项目组用私服的Git远程版本库,每一次推送和拉取服务都需要输入用户名和密码,过于繁琐. 2. 解决方法 Windows系统提供了"管理Windows凭据"的功能 ...

  5. C#求任意两整数之和

    2019.9.11 作业要求: 求出任意两整数之和 解决方案: using System; using System.Collections.Generic; using System.Linq; u ...

  6. MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length【转】

    今天有开发反应他的建表语句错误,我看了下,提示: MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Withou ...

  7. Linux 限制IP——/etc/hosts.allow和/etc/hosts.deny文件【转】

    就像是 限制特定IP来访 想法 看起来通常的做法是利用hosts的拒绝设置,而它的设置是针对某一个具体的进程,具体的服务,在这里就是sshd了 看起来设置一个网段使用的是 x.x.x.0/24 后面加 ...

  8. elasticsearch使用BulkProcessor批量入库数据

    在解决es入库问题上,之前使用过rest方式,经过一段时间的测试发现千万级别的数据会存在10至上百条数据的丢失问题, 在需要保证数据的准确性的场景下,rest方式并不能保证结果的准确性,因此采用了el ...

  9. 大数据/NoSQL经典电子书pdf下载

    Hadoop系列 Cloudera出品的各种官方文档 入门必备 https://www.cloudera.com/documentation.html Cloudera Hadoop大数据平台实战指南 ...

  10. 用java输出杨辉三角

    杨辉三角:它的两个边都是1,内部其它都是肩上两个数的和 第一种: package aaa; public class YangHui { public static void main(String[ ...