Spring原始碼分析【4】-Spring掃描basePackages註解
org.springframework.beans.factory.support.DefaultListableBeanFactory
重要資料結構
/** Map of bean definition objects, keyed by bean name */
private final Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<String, BeanDefinition>(256);
RootConfig 程式碼
org.springframework.context.annotation.ComponentScanAnnotationParser.parse@Configuration @Import(MybatisConfig.class) @ComponentScan(basePackages = {"com.xxx.*"}, excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = EnableWebMvc.class)}) public class RootConfig { }
org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
org.springframework.util.ClassUtils.convertClassNameToResourcePath
getResources
getResources
findPathMatchingResources
determineRootDir
回到findPathMatchingResources
findPathMatchingResources的result
一直退回到findCandidateComponents
MetadataReader metadataReader = this.metadataReaderFactory.getMetadataReader(resource);
MetadataReader
if (isCandidateComponent(metadataReader))
ScannedGenericBeanDefinition
回到findCandidateComponents
return candidates;
返回doScan
checkCandidate
回doScan
BeanDefinitionHolder
beanDefinitions.add(definitionHolder);
registerBeanDefinition
registerBeanDefinition
oldBeanDefinition = this.beanDefinitionMap.get(beanName);
if (hasBeanCreationStarted())
this.beanDefinitionMap.put(beanName, beanDefinition);
updatedDefinitions
doScan return beanDefinitions;
org.springframework.context.annotation.ComponentScanAnnotationParser.parse
org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass
parse
org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass
this.configurationClasses.put(configClass, configClass);
回到doProcessConfigurationClass
for (SourceClass ifc : sourceClass.getInterfaces()) {
doProcessConfigurationClass
// No superclass -> processing is complete
return null;
processConfigurationClass
org.springframework.context.annotation.ConfigurationClassParser.parse
parse
org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions
alreadyParsed.addAll(configClasses);
alreadyParsedClasses
invokeBeanDefinitionRegistryPostProcessors
org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors
// Now, invoke the postProcessBeanFactory callback of all processors handled so far.
invokeBeanFactoryPostProcessors(registryPostProcessors, beanFactory);
invokeBeanFactoryPostProcessors(regularPostProcessors, beanFactory);
postProcessorNames
refresh
相關推薦
Spring原始碼分析【4】-Spring掃描basePackages註解
org.springframework.beans.factory.support.DefaultListableBeanFactory 重要資料結構 /** Map of bean definition objects, keyed by bean name */ p
Spring原始碼分析【1】-Tomcat的初始化
org.apache.catalina.startup.ContextConfig.configureStart() org.apache.catalina.startup.ContextConfig.webConfig() 進入org.apache.catali
Spring原始碼分析【2】-Tomcat和Sping的連線點
Tomcat是怎麼呼叫上Spring的呢?需要找到這個連線點。 答案就在org.apache.catalina.startup.ContextConfig的processServletContainerInitializers方法 new WebappServiceLo
Spring原始碼學習【八】SpringMVC之DispatcherServlet
目錄 一、前言 三、總結 一、前言 Web環境是Spring框架的重要應用場景,而SpringMVC又是Web開發中一個常用的框架,因此我們有必要學習一下SpringMVC的實現原理。 回到Web專案的配置檔案web.xml中,在使用SpringMV
【4】spring單元測試和ApplicationContext區別
ApplicationContext 等於直接呼叫 public ClassPathXmlApplicationContext(String[] configLocations, boolean re
Spring原始碼分析(4)---BeanFactoryPostProcessor(看見的不一定是真的)
在第二編對BeanFactory的分析中,我們老能看見BeanFactoyPostProcessor的身影,那麼在這一節中,我們來詳細的討論一下BeanFactoryPostProcessor的程式碼結構,從中學習他的優秀之處;BeanFactoryPostProcessor
spring原始碼分析系列4:ApplicationContext研究
ApplicationContext介面 首先看一下一個最基本的上下文應該是什麼樣子 ApplicationContext介面的註釋裡寫的很清楚: 一個基本applicationContext應該提供: 訪問Bean的能力 提供載入資源的能力 釋出事件的能力 解析訊息、支援國際化的能力 Abstrac
caffe 原始碼分析【三】:Euclidean loss layer
以下是Euclidean loss layer的程式碼分析,轉自: https://blog.csdn.net/seashell_9/article/details/68064294 一. 前向函式 template <typename Dtype> void Euclide
caffe 原始碼分析【二】:Layer基類
建構函式 //標頭檔案 include/caffe/layer.hpp //實現檔案 src/caffe/layer.cpp // src/caffe/layer.cu /* * 建構函式 * 子類中修改建構函式,自定義設定在SetUp()中設定
caffe 原始碼分析【一】: Blob類
Blob類的: //標頭檔案: include\caffe\blob.hpp //cpp檔案: src\caffe\blob.cpp //cu檔案: src/caffe/blob.cu //定義某layer的輸入blobs const ve
JDK1.7原始碼分析【集合】HashMap的死迴圈
前言 在JDK1.7&1.8原始碼對比分析【集合】HashMap中我們遺留了一個問題:為什麼HashMap在呼叫resize() 方法時會出現死迴圈?這篇文章就通過JDK1.7的原始碼來分析並解釋這個問題。 如下,併發場景下使用HashMap造成Race Condition
imx6ul linux4.1.15 LED驅動配置及heartbeat原始碼分析【轉】
本文轉載自:https://blog.csdn.net/u010444107/article/details/78328807 1)檢視核心配置[email protected]:~/freescale/linux-imx$ cat arch/arm/configs/imx_v7_defconfi
Spring原始碼分析(二)-Spring IoC容器的初始化No.2
Spring原始碼分析(一)-Spring IoC容器的初始化No.1中已經分析了Bean的載入過程,本章將分析Bean的例項化過程 本章圍繞refresh().finishBeanFactoryInitialization(beanFactory)方法,
Spring原始碼分析(二)-Spring IoC容器的初始化No.1
Spring IoC容器的初始化 Spring原始碼分析(一)中提到了很多類,比如BeanDefinition、BeanDefinitionReader、BeanDefintionParser、BeanWrapper等都是ApplicationContext中
spring原始碼分析,重新認識spring五(內功心法 從思想上說明 spring 常用的幾種設計模式,漫談)
動態代理:關注過程,關注的是整體的區域性,面向的切面思想。 抽象工廠:關注的是結果,隱藏實現 單例模式:整個環境內只有一個類,有餓漢和懶漢,餓漢即 類載入直接new 物件,懶漢 即使用的時候才new物件,比較有名的有 雙檢索 單例,因為直接用同步限制會導致每次取物件都是同步
vscode原始碼分析【二】程式的啟動邏輯
上一篇文章:https://www.cnblogs.com/liulun/ (小廣告:我做的開源免費的,個人知識管理及自媒體營銷工具“想學嗎”:https://github.com/xland/xiangxuema) 我們在package.json裡能找到他的入口檔案; "m
vscode原始碼分析【三】程式的啟動邏輯,效能問題的追蹤
第一篇: vscode原始碼分析【一】從原始碼執行vscode 第二篇:vscode原始碼分析【二】程式的啟動邏輯,第一個視窗是如何建立的 啟動追蹤 程式碼檔案:src\main.js 如果指定了特定的啟動引數:trace vscode會在啟動之初,執行下面的程式碼: const con
vscode原始碼分析【五】事件分發機制
第一篇: vscode原始碼分析【一】從原始碼執行vscode 第二篇:vscode原始碼分析【二】程式的啟動邏輯,第一個視窗是如何建立的 第三篇:vscode原始碼分析【三】程式的啟動邏輯,效能問題的追蹤 第四篇:vscode原始碼分析【四】程式啟動的邏輯,最初建立的服務 在上一篇中,
vscode原始碼分析【七】主程序啟動訊息通訊服務
第一篇: vscode原始碼分析【一】從原始碼執行vscode 第二篇:vscode原始碼分析【二】程式的啟動邏輯,第一個視窗是如何建立的 第三篇:vscode原始碼分析【三】程式的啟動邏輯,效能問題的追蹤 第四篇:vscode原始碼分析【四】程式啟動的邏輯,最初建立的服務 第五篇:vsco
vscode原始碼分析【八】載入第一個畫面
第一篇: vscode原始碼分析【一】從原始碼執行vscode 第二篇:vscode原始碼分析【二】程式的啟動邏輯,第一個視窗是如何建立的 第三篇:vscode原始碼分析【三】程式的啟動邏輯,效能問題的追蹤 第四篇:vscode原始碼分析【四】程式啟動的邏輯,最初建立的服務 第五篇:vsco