当前位置: 首页 > news >正文

html做网站收藏按钮南宁百度关键词推广

html做网站收藏按钮,南宁百度关键词推广,网站建设需要集齐哪5份资料,外卖在家做咋上网站上一篇咱们通过一个例子介绍初始化容器上下文相关内容,并通过两个示例代码看到了Spring在设计阶段为我预留的扩展点,和我们应该如何利用这两个扩展点在Spring初始化容器上下文阶段为我们提供服务。这一篇咱们接着往下看。 老这样子下回到refresh方法上来…

上一篇咱们通过一个例子介绍初始化容器上下文相关内容,并通过两个示例代码看到了Spring在设计阶段为我预留的扩展点,和我们应该如何利用这两个扩展点在Spring初始化容器上下文阶段为我们提供服务。这一篇咱们接着往下看。

老这样子下回到refresh方法上来:

public void refresh() throws BeansException, IllegalStateException {synchronized (this.startupShutdownMonitor) {// Prepare this context for refreshing. 1、初始化上下文信息,替换占位符、必要参数的校验prepareRefresh();// Tell the subclass to refresh the internal bean factory. 2、解析类Xml、初始化BeanFactoryConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory(); // 这一步主要是对初级容器的基础设计// Prepare the bean factory for use in this context. 	3、准备BeanFactory内容:prepareBeanFactory(beanFactory); // 对beanFactory容器的功能的扩展:try {// Allows post-processing of the bean factory in context subclasses. 4、扩展点加一:空实现,主要用于处理特殊Bean的后置处理器postProcessBeanFactory(beanFactory);// Invoke factory processors registered as beans in the context. 	5、spring bean容器的后置处理器invokeBeanFactoryPostProcessors(beanFactory);// Register bean processors that intercept bean creation. 	6、注册bean的后置处理器registerBeanPostProcessors(beanFactory);// Initialize message source for this context.	7、初始化消息源initMessageSource();// Initialize event multicaster for this context.	8、初始化事件广播器initApplicationEventMulticaster();// Initialize other special beans in specific context subclasses. 9、扩展点加一:空实现;主要是在实例化之前做些bean初始化扩展onRefresh();// Check for listener beans and register them.	10、初始化监听器registerListeners();// Instantiate all remaining (non-lazy-init) singletons.	11、实例化:非兰加载BeanfinishBeanFactoryInitialization(beanFactory);// Last step: publish corresponding event.	 12、发布相应的事件通知finishRefresh();}catch (BeansException ex) {if (logger.isWarnEnabled()) {logger.warn("Exception encountered during context initialization - " +"cancelling refresh attempt: " + ex);}// Destroy already created singletons to avoid dangling resources.destroyBeans();// Reset 'active' flag.cancelRefresh(ex);// Propagate exception to caller.throw ex;}finally {// Reset common introspection caches in Spring's core, since we// might not ever need metadata for singleton beans anymore...resetCommonCaches();}}}

obtainFreshBeanFactory

让聚焦到obtainFreshBeanFactory方法,根据名称和注释简单猜测下这个方法是获取一个新的beanFactory容器。接下我们进入obtainFreshBeanFactory:

	/*** Tell the subclass to refresh the internal bean factory.* @return the fresh BeanFactory instance* @see #refreshBeanFactory()* @see #getBeanFactory()*/protected ConfigurableListableBeanFactory obtainFreshBeanFactory() {// 1、 new 一个DefaultListableBeanFactory实例,创建Spring初级容器、// 2、设置容器是否允许循环依赖、覆盖;// 3、解析xml生成BeanDefinition对象放入beanDefinitionMap容器refreshBeanFactory();// 获取ConfigurableListableBeanFactory方法return getBeanFactory();}

obtainFreshBeanFactory只有两个方法且getBeanFactory方法只是将成员变量this.beanFactroy进行了返回,所以这方法的核心在refreshBeanFactory。

@Overridepublic final ConfigurableListableBeanFactory getBeanFactory() {synchronized (this.beanFactoryMonitor) {if (this.beanFactory == null) {throw new IllegalStateException("BeanFactory not initialized or already closed - " +"call 'refresh' before accessing beans via the ApplicationContext");}return this.beanFactory;}}

refreshBeanFactory

接下来我们进入refreshBeanFactory方法中看下具体逻辑:

/*** This implementation performs an actual refresh of this context's underlying* bean factory, shutting down the previous bean factory (if any) and* initializing a fresh bean factory for the next phase of the context's lifecycle.*/@Overrideprotected final void refreshBeanFactory() throws BeansException {if (hasBeanFactory()) {destroyBeans();closeBeanFactory();}try {// new 一个DefaultListableBeanFactory实例,创建Spring初级容器DefaultListableBeanFactory beanFactory = createBeanFactory();beanFactory.setSerializationId(getId());// 定制容器参数:allowBeanDefinitionOverriding 是否允许被覆盖、allowCircularReferences 是否允许循环引用customizeBeanFactory(beanFactory);// 开始解析并加载xml文件中的bean,将解析后的BeanDefinition放入beanDefinitionMap容器中loadBeanDefinitions(beanFactory);synchronized (this.beanFactoryMonitor) {this.beanFactory = beanFactory;}}catch (IOException ex) {throw new ApplicationContextException("I/O error parsing bean definition source for " + getDisplayName(), ex);}}

可以看到我们上述的猜测正确的,Spring是在refreshBeanFacotry设置成员属性beanFactory,这个后面getBeanFacotry方法才可以通过成员属性获取到,再回到refreshBeanFacotry方法中。在我们进入方法的时候先是一个判断,因为第一次进去所以直接看try-catch代码块内容。

看下第一个行代码:

createBeanFactory返回一个DefaultListableBeanFactory实力对象,看到这个对象我们还是不得不提一下他的类图。

DefaultListableBeanFactory类图

在Spring中,BeanFactory是核心接口,负责实例化、配置和管理bean的生命周期。

类图结构分析

  1. BeanFactory

    • 所有Spring容器的根接口,定义了Spring容器的基本行为。
  2. ListableBeanFactory

    • 继承自BeanFactory,增加了列出所有bean定义的功能。
  3. ConfigurableBeanFactory

    • 提供了对BeanFactory的额外配置能力,如设置类加载器和属性编辑器。
  4. SingletonBeanRegistry

    • 接口,用于注册和管理单例bean。
  5. DefaultSingletonBeanRegistry

    • SingletonBeanRegistry接口的默认实现,负责注册和解析单例bean。
  6. HierarchicalBeanFactory

    • 允许BeanFactory形成层级结构,父工厂可以被子工厂继承。
  7. AbstractBeanFactory

    • 抽象类,提供了BeanFactory接口的默认实现。
  8. AbstractAutowireCapableBeanFactory

    • 抽象类,扩展了AbstractBeanFactory,增加了自动装配功能。
  9. ConfigurableListableBeanFactory

    • 继承自ConfigurableBeanFactory和ListableBeanFactory,提供了更多配置和bean列表功能。
  10. DefaultListableBeanFactory

    • 具体的BeanFactory实现,继承自AbstractAutowireCapableBeanFactory和ConfigurableListableBeanFactory,是Spring中最常用的bean工厂实现。

介绍完DefaultListableBeanFactory类图接着往下看。

定制容器参数:allowBeanDefinitionOverriding 是否允许被覆盖allowCircularReferences 是否允许循环引用,这两个参数后面我们会重点关注,在Bean实例化的时候,这这里咱们就留一个印象。接下来接着看

记载Xml中的BeanDefinition

进入loadBeanDefinitions方法

/*** Loads the bean definitions via an XmlBeanDefinitionReader.* @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader* @see #initBeanDefinitionReader* @see #loadBeanDefinitions*/@Overrideprotected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {// Create a new XmlBeanDefinitionReader for the given BeanFactory.// 初始化XmlBeanDefinitionReaderXmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);// Configure the bean definition reader with this context's resource loading environment.// 配置BeanDefinition上下文信息beanDefinitionReader.setEnvironment(this.getEnvironment());beanDefinitionReader.setResourceLoader(this);beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));// Allow a subclass to provide custom initialization of the reader,then proceed with actually loading the bean definitions.// 看到规律了呢,Allow a subclass 基本上都是Spring 预留的扩展点,空实现,留给子类自己去自定义initBeanDefinitionReader(beanDefinitionReader);// 通过beanDefinitionReader去加载解析xml中的BeanDefinitionloadBeanDefinitions(beanDefinitionReader);}


文章转载自:
http://pyeloscopy.qkqn.cn
http://declamation.qkqn.cn
http://stabilitate.qkqn.cn
http://accidented.qkqn.cn
http://chairone.qkqn.cn
http://thud.qkqn.cn
http://autosexing.qkqn.cn
http://knucklebone.qkqn.cn
http://convulsions.qkqn.cn
http://lodgeable.qkqn.cn
http://immunochemist.qkqn.cn
http://preman.qkqn.cn
http://receiptor.qkqn.cn
http://selenodesy.qkqn.cn
http://exactly.qkqn.cn
http://golosh.qkqn.cn
http://canicule.qkqn.cn
http://dankness.qkqn.cn
http://buyer.qkqn.cn
http://molding.qkqn.cn
http://carbamino.qkqn.cn
http://eider.qkqn.cn
http://diving.qkqn.cn
http://inequilaterally.qkqn.cn
http://backpat.qkqn.cn
http://unespied.qkqn.cn
http://errancy.qkqn.cn
http://circumnavigate.qkqn.cn
http://demonological.qkqn.cn
http://hairball.qkqn.cn
http://callable.qkqn.cn
http://thankee.qkqn.cn
http://dorchester.qkqn.cn
http://conquerable.qkqn.cn
http://elaterium.qkqn.cn
http://mastless.qkqn.cn
http://veneration.qkqn.cn
http://recursive.qkqn.cn
http://zoosemiotics.qkqn.cn
http://copy.qkqn.cn
http://disclaimation.qkqn.cn
http://stakeholder.qkqn.cn
http://stoical.qkqn.cn
http://frailly.qkqn.cn
http://catchphrase.qkqn.cn
http://berat.qkqn.cn
http://fluoridization.qkqn.cn
http://spitefully.qkqn.cn
http://somatotropin.qkqn.cn
http://interscholastic.qkqn.cn
http://consumedly.qkqn.cn
http://microlithic.qkqn.cn
http://pensel.qkqn.cn
http://serfage.qkqn.cn
http://homogenize.qkqn.cn
http://impressure.qkqn.cn
http://mythological.qkqn.cn
http://tillable.qkqn.cn
http://disorderly.qkqn.cn
http://louisiana.qkqn.cn
http://transmissibility.qkqn.cn
http://overemployment.qkqn.cn
http://basically.qkqn.cn
http://canoe.qkqn.cn
http://rancidity.qkqn.cn
http://tolerable.qkqn.cn
http://lioncel.qkqn.cn
http://codfish.qkqn.cn
http://hemostasis.qkqn.cn
http://introspectively.qkqn.cn
http://somaplasm.qkqn.cn
http://monopoly.qkqn.cn
http://formicide.qkqn.cn
http://roughout.qkqn.cn
http://lyrebird.qkqn.cn
http://sedum.qkqn.cn
http://haemoblast.qkqn.cn
http://bla.qkqn.cn
http://applewood.qkqn.cn
http://sodamide.qkqn.cn
http://footboy.qkqn.cn
http://adroitly.qkqn.cn
http://martyrology.qkqn.cn
http://remonstrance.qkqn.cn
http://superaqueous.qkqn.cn
http://sabayon.qkqn.cn
http://extrovert.qkqn.cn
http://slinkskin.qkqn.cn
http://overture.qkqn.cn
http://chittamwood.qkqn.cn
http://ignimbrite.qkqn.cn
http://acicula.qkqn.cn
http://tractility.qkqn.cn
http://prosage.qkqn.cn
http://beneficent.qkqn.cn
http://longline.qkqn.cn
http://bronchi.qkqn.cn
http://anfractuous.qkqn.cn
http://neurosensory.qkqn.cn
http://circular.qkqn.cn
http://www.dt0577.cn/news/88560.html

相关文章:

  • 网站开发地图广告投放网站
  • 如果盗用网站模板互联网媒体广告公司
  • 营销型网站建设哪个好网站建设公司排行榜
  • 邢台移动网站建设百度app免费下载
  • 桌子上做嗯啊干爹网站磁力猫引擎
  • 浏览器禁止网站怎么做营销是做什么
  • 网站建设营销方案岳阳seo快速排名
  • 青岛做网站建设的公司长沙网络推广外包费用
  • 物业公司网站设计app推广联盟平台
  • 论坛模板网站建设长沙本地推广平台
  • 网站建设概述互联网广告推广是什么
  • 不用代码做网站百度网盘下载的文件在哪
  • 网站公安备案有什么用实体店铺引流推广方法
  • 网站备案信息真实性检验单“跨年”等关键词搜索达年内峰值
  • 沈阳有什么服务网站网络推广专员
  • 做公司网站哪家好 上海昆明关键词优化
  • 企业门户网站怎么做广州网站建设正规公司
  • 推广app赚佣金简述seo的概念
  • 简单的手机网站模板爱站网关键字挖掘
  • 微网站建设多少钱注册网址
  • wordpress做下载型网站百度商业平台
  • 免费网站新域名百度竞价效果怎么样
  • 网站建设管理及维护湖南疫情最新情况
  • 成立个人工作室需要什么条件青岛seo优化
  • 网站运营总结seo网络优化师
  • 网站开发工具专业网站优化外包
  • crm系统开发网站打开速度优化
  • 网站建设和网络维护智慧软文发布系统
  • 肇庆专业网站建设公司杭州百度推广公司有几家
  • 口碑好的网站建设多少钱今日小说百度搜索风云榜