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

啥十小企业网站建设/优化分析

啥十小企业网站建设,优化分析,做网站广州,什么什么云用来做网站一、引言 上一篇Spring 源码分析(二)— IOC 根类结构图梳理了整个 Spring BeanFactory 的继承关系,对 BeanFactory 家族有了一个基本的认知。 本篇继续接着Spring 源码分析(一)— IOC demo ,来分析 ClassP…

一、引言

上一篇Spring 源码分析(二)— IOC 根类结构图梳理了整个 Spring BeanFactory 的继承关系,对 BeanFactory 家族有了一个基本的认知。
本篇继续接着Spring 源码分析(一)— IOC demo ,来分析 ClassPathXmlApplicationContext 的初始化过程。

二、初始化过程分析

ClassPathXmlApplicationContext 过程跟踪:

public class ClassPathXmlApplicationContext extends AbstractXmlApplicationContext {....../*** Create a new ClassPathXmlApplicationContext, loading the definitions* from the given XML file and automatically refreshing the context.* @param configLocation resource location* @throws BeansException if context creation failed*/public ClassPathXmlApplicationContext(String configLocation) throws BeansException {this(new String[] {configLocation}, true, null);}....../*** Create a new ClassPathXmlApplicationContext with the given parent,* loading the definitions from the given XML files.* @param configLocations array of resource locations* @param refresh whether to automatically refresh the context,* loading all bean definitions and creating all singletons.* Alternatively, call refresh manually after further configuring the context.* @param parent the parent context* @throws BeansException if context creation failed* @see #refresh()*/public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh, @Nullable ApplicationContext parent)throws BeansException {super(parent);setConfigLocations(configLocations);if (refresh) {refresh();}}......

可知:
初始化入口是 public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh, @Nullable ApplicationContext parent) 方法;
该方法做了三件事:

  1. super(parent); 设置 ApplicationContext;
  2. setConfigLocations(configLocations); 设置配置文件路径;
  3. refresh(); 加载新配置;

1.super(parent); 设置 ApplicationContext;真正执行的是 AbstractApplicationContext 类的方法:


public abstract class AbstractApplicationContext extends DefaultResourceLoaderimplements ConfigurableApplicationContext {....../*** Create a new AbstractApplicationContext with no parent.*/public AbstractApplicationContext() {this.resourcePatternResolver = getResourcePatternResolver();}/*** Create a new AbstractApplicationContext with the given parent context.* @param parent the parent context*/public AbstractApplicationContext(@Nullable ApplicationContext parent) {this();setParent(parent);}....../*** Set the parent of this application context.* <p>The parent {@linkplain ApplicationContext#getEnvironment() environment} is* {@linkplain ConfigurableEnvironment#merge(ConfigurableEnvironment) merged} with* this (child) application context environment if the parent is non-{@code null} and* its environment is an instance of {@link ConfigurableEnvironment}.* @see ConfigurableEnvironment#merge(ConfigurableEnvironment)*/@Overridepublic void setParent(@Nullable ApplicationContext parent) {this.parent = parent;if (parent != null) {Environment parentEnvironment = parent.getEnvironment();if (parentEnvironment instanceof ConfigurableEnvironment configurableEnvironment) {getEnvironment().merge(configurableEnvironment);}}}......

2.setConfigLocations(configLocations); 设置配置文件路径;真正执行的是 AbstractRefreshableConfigApplicationContext 的 public void setConfigLocations(@Nullable String… locations) 方法:

public abstract class AbstractRefreshableConfigApplicationContext extends AbstractRefreshableApplicationContextimplements BeanNameAware, InitializingBean {....../*** Set the config locations for this application context.* <p>If not set, the implementation may use a default as appropriate.*/public void setConfigLocations(@Nullable String... locations) {if (locations != null) {Assert.noNullElements(locations, "Config locations must not be null");this.configLocations = new String[locations.length];for (int i = 0; i < locations.length; i++) {this.configLocations[i] = resolvePath(locations[i]).trim();}}else {this.configLocations = null;}}......

3.refresh(); 加载新配置;真正执行的是 AbstractApplicationContext 的 refresh(…) 方法:

public abstract class AbstractApplicationContext extends DefaultResourceLoaderimplements ConfigurableApplicationContext {......@Overridepublic void refresh() throws BeansException, IllegalStateException {synchronized (this.startupShutdownMonitor) {StartupStep contextRefresh = this.applicationStartup.start("spring.context.refresh");// Prepare this context for refreshing.prepareRefresh();// Tell the subclass to refresh the internal bean factory.ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();// Prepare the bean factory for use in this context.prepareBeanFactory(beanFactory);try {// Allows post-processing of the bean factory in context subclasses.postProcessBeanFactory(beanFactory);StartupStep beanPostProcess = this.applicationStartup.start("spring.context.beans.post-process");// Invoke factory processors registered as beans in the context.invokeBeanFactoryPostProcessors(beanFactory);// Register bean processors that intercept bean creation.registerBeanPostProcessors(beanFactory);beanPostProcess.end();// Initialize message source for this context.initMessageSource();// Initialize event multicaster for this context.initApplicationEventMulticaster();// Initialize other special beans in specific context subclasses.onRefresh();// Check for listener beans and register them.registerListeners();// Instantiate all remaining (non-lazy-init) singletons.finishBeanFactoryInitialization(beanFactory);// Last step: publish corresponding event.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();contextRefresh.end();}}}......

待续

http://www.lbrq.cn/news/1613791.html

相关文章:

  • wordpress.com 域名/谷歌搜索优化
  • wordpress的网站是php的代码/最好的网站优化公司
  • 设计门户网站/南宁seo教程
  • 网站建设小工具/竞价
  • 天权网站建设/编程培训班学费一般多少钱
  • 做网站的人多吗/seo综合查询站长工具关键词
  • 石家庄网站如何制作/网络营销策划书论文
  • 免费网站app软件/中国十大经典广告
  • 一个外国人做的汉子 网站/快速建站工具
  • 做网站的销售/广州百度
  • qq临时会话网站/品牌宣传活动策划方案
  • pw网站更换域名/深圳全网营销推广平台
  • 网站建站咨询/怎么弄一个网站平台
  • 企业开源建站系统/网站seo外包
  • 红酒哪个网站做的好/熊猫关键词挖掘工具
  • 林业网站建设有哪些/公司宣传推广方案
  • 佛山做外贸网站平台/百度官网认证
  • 西安做网站哪里价格低/培训机构管理系统
  • 做网站怎么样才能赚到钱/企业关键词优化推荐
  • 合肥建网站公司/李勇seo的博客
  • 毕业设计做的网站抄袭/爱站网关键词搜索
  • 制作网站一般多少钱/市场调研方法有哪些
  • 怎么做游戏充值代理网站/如何创建一个个人网站
  • 企业公司网站制作建设/seo主要做什么工作内容
  • 在上阿里云做网站/简单网页制作成品和代码
  • 山东做网站建设的好公司哪家好/做一个自己的网站
  • 有做自由行包车的网站/全网营销代理加盟
  • 开发平台免费版/seo快速培训
  • web编程/seo怎么做优化方案
  • 购物网站的设计思路/网店培训班
  • 深入 Go 底层原理(三):Goroutine 的调度策略
  • 【数据结构初阶】--排序(二)--直接选择排序,堆排序
  • WinForm之ListBox 控件
  • MybatisPlus-逻辑删除
  • Linux用户与组管理全解析
  • 【最近公共祖先】ST表法