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

支部品牌建设百度seo什么意思

支部品牌建设,百度seo什么意思,安全者 wordpress,门户网网站seo怎么做文章目录 一、Spring生命周期核心底层源码剖析—扫描1.1、Spring底层扫描机制doScan方法源码剖析 一、Spring生命周期核心底层源码剖析—扫描 1.1、Spring底层扫描机制doScan方法源码剖析 其源代码如下&#xff1a; protected Set<BeanDefinitionHolder> doScan(Strin…

文章目录

  • 一、Spring生命周期核心底层源码剖析—扫描
    • 1.1、Spring底层扫描机制doScan方法源码剖析

一、Spring生命周期核心底层源码剖析—扫描

1.1、Spring底层扫描机制doScan方法源码剖析

其源代码如下:

protected Set<BeanDefinitionHolder> doScan(String... basePackages) {Assert.notEmpty(basePackages, "At least one base package must be specified");Set<BeanDefinitionHolder> beanDefinitions = new LinkedHashSet<>();for (String basePackage : basePackages) {Set<BeanDefinition> candidates = findCandidateComponents(basePackage);//遍历其获取到的BeanDefinition对象for (BeanDefinition candidate : candidates) {//为其BeanDefinition对象进行属性赋值,例如scope,beanName等ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(candidate);candidate.setScope(scopeMetadata.getScopeName());String beanName = this.beanNameGenerator.generateBeanName(candidate, this.registry);if (candidate instanceof AbstractBeanDefinition) {postProcessBeanDefinition((AbstractBeanDefinition) candidate, beanName);}if (candidate instanceof AnnotatedBeanDefinition) {AnnotationConfigUtils.processCommonDefinitionAnnotations((AnnotatedBeanDefinition) candidate);}//判断当前的bean是否已经在Spring容器中存在,存在需封装为BeanDefinitionHolder对象if (checkCandidate(beanName, candidate)) {BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(candidate, beanName);definitionHolder =AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);beanDefinitions.add(definitionHolder);registerBeanDefinition(definitionHolder, this.registry);}}}return beanDefinitions;}

1、其主要是通过传入的包路径进行资源加载,加载时方法为上诉代码的for循环下的第一行代码的findCandidateComponents()方法,可以详细看此方法,是如何加载资源的,其方法代码如下(具体说明以及解析过程可参考注释):

public Set<BeanDefinition> findCandidateComponents(String basePackage) {//此处主要是判断项目是否配置了相关的bean文件,若有,就不需要再逐个类进行扫描+判断是否为Beanif (this.componentsIndex != null && indexSupportsIncludeFilters()) {return addCandidateComponentsFromIndex(this.componentsIndex, basePackage);}//大部分的业务都会走如下方法else {return scanCandidateComponents(basePackage);}}//scanCandidateComponents方法具体实现为
private Set<BeanDefinition> scanCandidateComponents(String basePackage) {Set<BeanDefinition> candidates = new LinkedHashSet<>();try {//1、资源路径组装解析String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +resolveBasePackage(basePackage) + '/' + this.resourcePattern;//2、利用类元数据读取器读取器路径下包含的资源数据Resource[] resources = getResourcePatternResolver().getResources(packageSearchPath);boolean traceEnabled = logger.isTraceEnabled();boolean debugEnabled = logger.isDebugEnabled();//3、遍历类元数据读取器获取到的资源数据(class资源文件数据)for (Resource resource : resources) {if (traceEnabled) {logger.trace("Scanning " + resource);}try {//4、获取当前类元数据(calss)具体资源信息MetadataReader metadataReader = getMetadataReaderFactory().getMetadataReader(resource);//5、判断当前的类(class)上包含的是否包含排除注解excludeFilters以及非排除注解includeFilters,以及是否包含相关的条件注解Conditionalif (isCandidateComponent(metadataReader)) {//6、创建一个BeanDefinition对象,用于封装其类特征信息,例如:beanClass、scope、lazyInit等属性ScannedGenericBeanDefinition sbd = new ScannedGenericBeanDefinition(metadataReader);//7、将类资源数据加入到BeanDefinition中sbd.setSource(resource);//8、判断当前的类资源是否是独立的(例如是否是内部类等),除此歪,需要判断其是否为接口或者抽象类,如果是抽象类,那类中必须有被Lookup注解的方法,否则不会被当做beanif (isCandidateComponent(sbd)) {if (debugEnabled) {logger.debug("Identified candidate component class: " + resource);}//9、将封装好的BeanDefinition对象加入到返回的集合Set中candidates.add(sbd);}else {if (debugEnabled) {logger.debug("Ignored because not a concrete top-level class: " + resource);}}}else {if (traceEnabled) {logger.trace("Ignored because not matching any filter: " + resource);}}}catch (FileNotFoundException ex) {if (traceEnabled) {logger.trace("Ignored non-readable " + resource + ": " + ex.getMessage());}}catch (Throwable ex) {throw new BeanDefinitionStoreException("Failed to read candidate component class: " + resource, ex);}}}catch (IOException ex) {throw new BeanDefinitionStoreException("I/O failure during classpath scanning", ex);}return candidates;}
http://www.yayakq.cn/news/390433/

相关文章:

  • 网站开发 php 书籍 推荐什么是营销型网站呢
  • 防伪查询网站企业建设网站需要什么资料
  • 网站文章怎么做内链南皮哪有做网站的
  • 关于网站开发的引言做汽车配件招聘网站
  • 网页设计模板免费下载网站重庆可视化网站制作
  • 莞城做网站域名解析怎么设置
  • 怎么打造自己的网站怎么做盈利的网站
  • 网赌网站怎么做的上海集团网站建设公司好
  • 在建设部网站呢李可以看出需要什么时候考试青岛网站设计品牌企业
  • 网站为什么会被挂马云搜索app官网
  • 网页制作与网站建设实战大全 光盘wordpress顶部修改
  • 内部网站搭建最近国语视频在线观看免费播放
  • 太原网站推广服务网站制做工具
  • 网站门户建网站和建网页的区别
  • 怎么做网站程序网站建设的几个要素
  • 青岛开发区网站建信建设投资有限公司网站
  • 杭州模板网站制作百度百家号官网登录
  • 宁波企业网站建设公司wordpress 教 模版
  • 国际会议网站建设新手如何学网站建设
  • 广告费内包括网站建设旅游网站建设流程步骤
  • 同一虚拟主机 2个网站上海高登联合建设网站
  • 建设公众号网站评分标准细则施工企业既搞建筑安装又搞建筑材料销售其应纳税种为
  • php网站开发教材个人做网站创业
  • 什么是网站网页主页wordpress管理页面
  • 简约式网站做三方网站多少钱
  • 企业展示网站案例必须网站的访问量
  • 网站建设题目企业名录查询器免费版
  • 视觉中国的图片可以拿来做网站上海网站建设网页制作
  • 郑州七彩网站建设站酷网素材
  • 山西科技网站建设网上暴利赚钱项目