Spring启动研究2.AbstractApplicationContext.obtainFreshBeanFactory()研究
据说这个方法里面调用了loadBeanDefinitions,据说很重要,并且跟我感兴趣的标签解析有关,所以仔细看看
obtainFreshBeanFactory()这个方法在AbstractApplicationContext中定义如下:
protected ConfigurableListableBeanFactory obtainFreshBeanFactory() {
refreshBeanFactory();
ConfigurableListableBeanFactory beanFactory = getBeanFactory();
if (logger.isDebugEnabled()) {
logger.debug("Bean factory for " + getDisplayName() + ": " + beanFactory);
}
return beanFactory;
}
其中refreshBeanFactory()方法也在这方法中,是个抽象方法,所以往回找EmbeddedWebApplicationContext的父类的父类GenericApplicationContext总找到了这个方法的实现:
@Override
protected final void refreshBeanFactory() throws IllegalStateException {
if (this.refreshed) {
throw new IllegalStateException(
"GenericApplicationContext does not support multiple refresh attempts: just call 'refresh' once");
}
this.beanFactory.setSerializationId(getId());
this.refreshed = true;
}
但是好像没有我感兴趣的部分,
那看看AbstractApplicationContext类中obtainFreshBeanFactory()方法中ConfigurableListableBeanFactory beanFactory = getBeanFactory()这一段
它也是在GenericApplicationContext实现的:
@Override
public final ConfigurableListableBeanFactory getBeanFactory() {
return this.beanFactory;
}
而这个类的构造方法中初始化了beanFactory:
public class GenericApplicationContext extends AbstractApplicationContext implements BeanDefinitionRegistry {
private final DefaultListableBeanFactory beanFactory;
private ResourceLoader resourceLoader;
private boolean refreshed = false;
/**
* Create a new GenericApplicationContext.
* @see #registerBeanDefinition
* @see #refresh
*/
public GenericApplicationContext() {
this.beanFactory = new DefaultListableBeanFactory();
}
略
感觉没什么内容,就是返回了一个new DefaultListableBeanFactory();
Spring启动研究2.AbstractApplicationContext.obtainFreshBeanFactory()研究的更多相关文章
- Spring源码情操陶冶-AbstractApplicationContext#obtainFreshBeanFactory
前言-阅读源码有利于陶冶情操,本文承接前文Spring源码情操陶冶-AbstractApplicationContext 约束: 本文指定contextClass为默认的XmlWebApplicati ...
- spring启动component-scan类扫描加载过程(转)
文章转自 http://www.it165.net/pro/html/201406/15205.html 有朋友最近问到了 spring 加载类的过程,尤其是基于 annotation 注解的加载过程 ...
- ApplicationListener<ContextRefreshedEvent>接口,Spring启动后获取所有拥有特定注解的Bean
最近项目中遇到一个业务场景,就是在Spring容器启动后获取所有的Bean中实现了一个特定接口的对象,第一个想到的是ApplicationContextAware,在setApplicationCon ...
- Spring启动后获取所有拥有特定注解的Bean,注解的属性值
最近项目中遇到一个业务场景,就是在Spring容器启动后获取所有的Bean中实现了一个特定接口的对象,第一个想到的是ApplicationContextAware,在setApplicationCon ...
- spring 启动异常Failed to read candidate component class
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: ...
- Spring启动异常: cvc-elt.1: Cannot find the declaration of element 'beans'(转)
Spring启动异常: cvc-elt.1: Cannot find the declaration of element 'beans' 2008-09-07 22:41 今天把在线聊天室代码改了下 ...
- spring扩展点之三:Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法,在spring启动后做些事情
<spring扩展点之三:Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法,在spring启动后做些事情> <服务网关zu ...
- Spring启动时获取自定义注解的属性值
1.自定义注解 @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documen ...
- spring启动异步线程
大纲: spring启动异步线程 spring配置线程池 一.spring启动异步线程 spring启动异步线程方法就是在方法上加上注解@Async,然后启动类或配置类上加上注解@EnableAsyn ...
随机推荐
- Selenium自动化Page模式(Python)
Selenium是当前主流的web自动化工具,提供了多种浏览器的支持(Chrome,Firefox, IE等等),当然大家也可以用自己喜欢的语言(Java,C#,Python等)来写用例,很容易上手. ...
- The android command is deprecated
新版的SDK tools中的android命令已经不支持 android create project,用起来很不顺手. The "android" command is depr ...
- Nginx Server 配置
http { include mime.types; // 主模块:实现对配置文件包含的文件设定,可以减少主配置文件的复杂度: default_type application/octet-strea ...
- C - Little Jumper (三分)
题目链接:https://cn.vjudge.net/contest/281961#problem/C 题目大意:青蛙能从一个点跳到第三个点,如图,需要跳两次.问整个过程的最大起跳速度中的最小的. 具 ...
- Django学习手册 - cookie / session
cookie """ cookie属性: obj.set_cookie(key,value,....) obj.set_signed_cookie(key,value,s ...
- android 面试事件分发
开始的Activity和最好的view是没有onInterceptTouchEvent方法的 不能进行对事件的拦截 总论 在我们点击屏幕时,会有下列事件发生: Activity调用dispathTou ...
- ES系列五、ES6.3常用api之搜索类api
1.搜索api 1.1.routing:路由 执行搜索时,它将广播到所有索引/索引分片(副本之间的循环).可以通过提供routing参数来控制将搜索哪些分片.例如,在索引book时,路由值可以是nam ...
- C:malloc/calloc/realloc/alloca内存分配函数
原文地址:http://www.cnblogs.com/3me-linux/p/3962152.html calloc(), malloc(), realloc(), free(),alloca() ...
- 部署vCenter Server Appliance 6.7
=============================================== 2019/4/14_第1次修改 ccb_warlock == ...
- Expm 9_3 无向图的双连通分量问题
[问题描述] 给定一个无向图,设计一个算法,判断该图中是否存在关节点,并划分双连通分量. package org.xiu68.exp.exp9; import java.util.Stack; p ...