本文承接前文Spring源码情操陶冶-自定义节点的解析,分析spring中的context:annotation-config节点如何被解析

源码概览

BeanDefinitionParser接口的实现方法parse代码如下

@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element); // Obtain bean definitions for all relevant BeanPostProcessors.主要的作用就是配置BeanPostProcessors
Set<BeanDefinitionHolder> processorDefinitions =
AnnotationConfigUtils.registerAnnotationConfigProcessors(parserContext.getRegistry(), source); // Register component for the surrounding <context:annotation-config> element.
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
parserContext.pushContainingComponent(compDefinition); // Nest the concrete beans in the surrounding component.
for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
parserContext.registerComponent(new BeanComponentDefinition(processorDefinition));
} // Finally register the composite component.
parserContext.popAndRegisterContainingComponent(); return null;
}

由上可述,我们明白了为什么配置了context:component-scan节点等同于不需要配置context:annotation-config节点,此处的代码类同与ComponentScanBeanDefinitionParser#registerComponents方法,所以这里就不赘述了,可见>>>Spring源码情操陶冶-ComponentScanBeanDefinitionParser文件扫描解析器ComponentScanBeanDefinitionParser#registerComponents版块

小结

注册多个BeanPostProcessor接口实现类【供后续spring调用统一接口进行解析,比如>>>Spring源码情操陶冶-AbstractApplicationContext#invokeBeanFactoryPostProcessors可会执行解析@Configuration】具体的有

  • ConfigurationClassPostProcessor解析@Configuration注解类

  • AutowiredAnnotationBeanPostProcessor解析@Autowired/@Value注解

  • RequiredAnnotationBeanPostProcessor解析@Required注解

  • CommonAnnotationBeanPostProcessor解析@Resource注解

  • PersistenceAnnotationBeanPostProcessor解析JPA注解,持久层

Spring源码情操陶冶-AnnotationConfigBeanDefinitionParser注解配置解析器的更多相关文章

  1. Spring源码情操陶冶-PropertyPlaceholderBeanDefinitionParser注解配置解析器

    本文针对spring配置的context:property-placeholder作下简单的分析,承接前文Spring源码情操陶冶-自定义节点的解析 spring配置文件应用 <context: ...

  2. Spring源码情操陶冶-ComponentScanBeanDefinitionParser文件扫描解析器

    承接前文Spring源码情操陶冶-自定义节点的解析,本文讲述spring通过context:component-scan节点干了什么事 ComponentScanBeanDefinitionParse ...

  3. Spring源码情操陶冶-AOP之ConfigBeanDefinitionParser解析器

    aop-Aspect Oriented Programming,面向切面编程.根据百度百科的解释,其通过预编译方式和运行期动态代理实现程序功能的一种技术.主要目的是为了程序间的解耦,常用于日志记录.事 ...

  4. Spring源码情操陶冶-自定义节点的解析

    本文承接前文Spring源码情操陶冶-DefaultBeanDefinitionDocumentReader#parseBeanDefinitions,特开辟出一块新地来啃啃这块有意思的骨头 自定义节 ...

  5. SpringMVC源码情操陶冶-ResourcesBeanDefinitionParser静态资源解析器

    解析mvc:resources节点,控制对静态资源的映射访问 查看官方注释 /** * {@link org.springframework.beans.factory.xml.BeanDefinit ...

  6. Spring源码情操陶冶-AOP之Advice通知类解析与使用

    阅读本文请先稍微浏览下上篇文章Spring源码情操陶冶-AOP之ConfigBeanDefinitionParser解析器,本文则对aop模式的通知类作简单的分析 入口 根据前文讲解,我们知道通知类的 ...

  7. Spring源码情操陶冶-tx:advice解析器

    承接Spring源码情操陶冶-自定义节点的解析.本节关于事务进行简单的解析 spring配置文件样例 简单的事务配置,对save/delete开头的方法加事务,get/find开头的设置为不加事务只读 ...

  8. Spring源码情操陶冶#task:executor解析器

    承接Spring源码情操陶冶-自定义节点的解析.线程池是jdk的一个很重要的概念,在很多的场景都会应用到,多用于处理多任务的并发处理,此处借由spring整合jdk的cocurrent包的方式来进行深 ...

  9. Spring源码情操陶冶-AbstractApplicationContext#finishBeanFactoryInitialization

    承接前文Spring源码情操陶冶-AbstractApplicationContext#registerListeners 约定web.xml配置的contextClass为默认值XmlWebAppl ...

随机推荐

  1. 微积分入门("SX"T版)

    哎,微积分,表示暂时并没有很深入的研究……虽然高中有教,但是好像跟小西瓜学的顺序不太一样,嗯……教微积分之前不应该把极限学下来么……不管了,本文按傻X腾的理解来搞吧. 极限……大学的东西喔,我们先来认 ...

  2. Gym 100952G&&2015 HIAST Collegiate Programming Contest G. The jar of divisors【简单博弈】

    G. The jar of divisors time limit per test:2 seconds memory limit per test:64 megabytes input:standa ...

  3. SG 函数 S-Nim

    http://poj.org/problem?id=2960 S-Nim Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 34 ...

  4. MYSQL数据库增量备份

    MySQL数据库增量备份,在这之前修改我们的数据库配置文件/etc/my.cnf开启bin-log日志功能即可.接下来是我参考了下网上的一些方法,自己写的,主要还是要能学到他的一些思路和方法. #fu ...

  5. spring自带定时器

    http://www.cnblogs.com/pengmengnan/p/6714203.html 注解模式的spring定时器1 , 首先要配置我们的spring.xmlxmlns 多加下面的内容. ...

  6. Npm vs Yarn 之备忘大全

    有则笑话,如此讲到:"老丈人爱吃核桃,昨天买了二斤陪妻子送去,老丈人年轻时练过武,用手一拍核桃就碎了,笑着对我说:你还用锤子,你看我用手就成.我嘴一抽,来了句:人和动物最大的区别就是人会使用 ...

  7. [国嵌攻略][159][SPI子系统]

    SPI 子系统架构 1.SPI core核心:用于连接SPI客户驱动和SPI主控制器驱动,并且提供了对应的注册和注销的接口. 2.SPI controller driver主控制器驱动:用来驱动SPI ...

  8. [国嵌笔记][008-009][远程登录Linux]

    [国嵌笔记][008][远程登录Linux] 1.windows与Linux能够相互ping通 2.关闭Linux防火墙 /etc/init.d/iptables stop 3.通过ssh(字符界面) ...

  9. JavaScript八张思维导图—编程实践

    JS基本概念 JS操作符 JS基本语句 JS数组用法 Date用法 JS字符串用法 JS编程风格 JS编程实践 不知不觉做前端已经五年多了,无论是从最初的jQuery还是现在火热的Angular,Vu ...

  10. HTML 5  标签

    HTML 5 标签 标签定义文档中的节(section.区段).比如章节.页眉.页脚或文档中的其他部分. E 9+.Firefox.Opera.Chrome 和 Safari 标签. 注释:IE 8 ...