- 前言
- 第一部分 核心实现
- 第 1 章 Spring 整体架构和环境搭建
- 第 2 章 容器的基本实现
- 第 3 章 默认标签的解析
- 第 4 章 自定义标签的解析
- 第 5 章 bean 的加载
- 第 6 章 容器的功能扩展
- 第 7 章 AOP
- 第二部分 企业应用
- 第 8 章 数据库连接 JDBC
- 第 9 章 整合 MyBatis
- 第 10 章 事务
- 第 11 章 SpringMVC
- 第 12 章 远程服务
- 第 13 章 Spring 消息
7.2 动态 AOP 自定义标签
之前讲过 Spring 中的自定义注解,如果声明了自定义的注解,那么就一定会在程序中的某个地方注册了对应的解析器。我们搜索整个代码,尝试找到注册的地方,全局搜索后我们发现了在 AopNamespaceHandler 中对应着这样一段函数:
public void init() {
// In 2.0 XSD as well as in 2.1 XSD.
registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());
registerBeanDefinitionParser("aspectj-autoproxy", new AspectJAutoProxyBean
DefinitionParser());
registerBeanDefinitionDecorator("scoped-proxy", new ScopedProxyBeanDefinition
Decorator());
// Only in 2.0 XSD: moved to context namespace as of 2.1
registerBeanDefinitionParser("Spring-configured", new SpringConfiguredBean
DefinitionParser());
}
此处不再对 Spring 中的自定义注解方式进行讨论。有兴趣的读者可以回顾之前的内容。
我们可以得知,在解析配置文件的时候,一旦遇到 aspectj-autoproxy 注解时就会使用解析器 AspectJAutoProxyBeanDefinitionParser 进行解析,那么我们来看一看 AspectJAutoProxyBean DefinitionParser 的内部实现。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论