您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“Spring源碼知識(shí)點(diǎn)分析”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“Spring源碼知識(shí)點(diǎn)分析”吧!
XmlBeanFactory核心類(lèi)解析:DefaultListableBeanFactory、XmlBeanDefinitionReader
public class XmlBeanFactory extends DefaultListableBeanFactory { private final XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this); /** * Create a new XmlBeanFactory with the given resource, * which must be parsable using DOM. * @param resource XML resource to load bean definitions from * @throws BeansException in case of loading or parsing errors */ public XmlBeanFactory(Resource resource) throws BeansException { this(resource, null); } /** * Create a new XmlBeanFactory with the given input stream, * which must be parsable using DOM. * @param resource XML resource to load bean definitions from * @param parentBeanFactory parent bean factory * @throws BeansException in case of loading or parsing errors */ public XmlBeanFactory(Resource resource, BeanFactory parentBeanFactory) throws BeansException { super(parentBeanFactory); this.reader.loadBeanDefinitions(resource); } }
DefaultListableBeanFactory
XmlBeanFactory繼承自DefaultListableBeanFactory。DefaultListableBeanFactory作用負(fù)責(zé)Spring Bean注冊(cè)以及加載的默認(rèn)實(shí)現(xiàn)。
AliasRegistry:公共的接口對(duì)別名管理
BeanDefinitionRegistry:定義對(duì)BeanDefinitionRegistry的各種管理操作
SimpleAliasRegistry:使用map作為alias的緩存,并對(duì)實(shí)現(xiàn)AliasRegistry接口實(shí)現(xiàn)
SingletonBeanRegistry:定義接口對(duì)單例的注冊(cè)和獲取
BeanFactory:定義獲取bean及bean的各種屬性
DefaultSingletonBeanRegistry:對(duì)SingletonBeanRegistry接口的默認(rèn)實(shí)現(xiàn)
HierarchicalBeanFactory:繼承BeanFactory接口的功能,增加了對(duì)parentFactoryBean的支持
ListableBeanFactory:根據(jù)各種條件獲取bean的配置清單
FactoryBeanRegistrySupport:在DefaultSingletonBeanRegistry的功能基礎(chǔ)上增加了對(duì)FactoryBean的支持
ConfigurableBeanFactory:提供BeanFactory的各種配置方法
AbstractBeanFactory:提供對(duì)FactoryBeanRegistrySupport功能支持和ConfigurableBeanFactory接口實(shí)現(xiàn)
AutowireCapableBeanFactory:定義接口創(chuàng)建bean、自動(dòng)注入、初始化以及應(yīng)用Bean的后端處理
AbstractAutowireCapableBeanFactory:繼承了AbstractBeanFactory
的功能,并實(shí)現(xiàn)AutowireCapableBeanFactory接口所有功能
ConfigurableListableBeanFactory:綜合配置大部分BeanFactory將要實(shí)現(xiàn)的接口
XmlBeanDefinitionReader
XmlBeanFactory中引用了XmlBeanDefinitionReader。XmlBeanDefinitionReader作用負(fù)責(zé) 從Resource資源文件中讀取、解析、注冊(cè)。
ResourceLoader:定義資源加載器,主要應(yīng)用于給定的資源文件地址返回對(duì)應(yīng)的的Resource
BeanDefinitionReader:定義bean接口從資源文件中讀取并轉(zhuǎn)換為BeanDefinitionReader
EnvironmentCapable:定義獲取Enviroment方法
BeanDefinitionDocumentReader:接口定義讀取Document并注冊(cè)BeanDefinition功能
BeanDefinitionParserDelegate:定義解析Element的各種方法
DocumentLoader:定義從資源文件加載到轉(zhuǎn)化為Document的功能
AbstractBeanDefinitionReader:對(duì)接口EnvironmentCapable、BeanDefinitionReader的實(shí)現(xiàn)
DefaultBeanDefinitionDocumentReader:對(duì)BeanDefinitionDocumentReader接口實(shí)現(xiàn)
到此,相信大家對(duì)“Spring源碼知識(shí)點(diǎn)分析”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢(xún),關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。