SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-003-Spring对AOP支持情况的介绍
2016-03-03 15:08
751 查看
一、
不同的Aop框架在支持aspect何时、如何织入到目标中是不一样的。如AspectJ和Jboss支持在构造函数和field被修改时织入,但spring不支持,spring只支持一般method的织入。spring通过以下四种方式支持AOP:
Classic Spring proxy-based AOP
Pure- POJO aspects
@AspectJ annotation-driven aspects
Injected AspectJ aspects (available in all versions of Spring)
前三种是Spring自己的对AOP的实现,即运行时织入,第四种是直接调用AspectJ。
二、Sping的AOP的几个特点
1.Advice都是写在java中
2.SPRING ADVISES OBJECTS AT RUNTIME
In Spring, aspects are woven into Spring-managed beans at runtime by wrapping them with a proxy class. As illustrated in figure 4.3, the proxy class poses as the target bean,intercepting advised method calls and forwarding those calls to the target bean.Between the time when the proxy intercepts the method call and the time when it invokes the target bean’s method, the proxy performs the aspect logic.
Spring doesn’t create a proxied object until that proxied bean is needed by the application. If you’re using an ApplicationContext , the proxied objects will be created when it loads all the beans from the BeanFactory . Because Spring creates proxies at runtime, you don’t need a special compiler to weave aspects in Spring’s AOP
3.SPRING ONLY SUPPORTS METHOD JOIN POINTS
Because it’s based on dynamic proxies, Spring only supports method join points.If you find yourself in need of more than method interception, you’ll want to complement Spring AOP with AspectJ.
不同的Aop框架在支持aspect何时、如何织入到目标中是不一样的。如AspectJ和Jboss支持在构造函数和field被修改时织入,但spring不支持,spring只支持一般method的织入。spring通过以下四种方式支持AOP:
Classic Spring proxy-based AOP
Pure- POJO aspects
@AspectJ annotation-driven aspects
Injected AspectJ aspects (available in all versions of Spring)
前三种是Spring自己的对AOP的实现,即运行时织入,第四种是直接调用AspectJ。
二、Sping的AOP的几个特点
1.Advice都是写在java中
2.SPRING ADVISES OBJECTS AT RUNTIME
In Spring, aspects are woven into Spring-managed beans at runtime by wrapping them with a proxy class. As illustrated in figure 4.3, the proxy class poses as the target bean,intercepting advised method calls and forwarding those calls to the target bean.Between the time when the proxy intercepts the method call and the time when it invokes the target bean’s method, the proxy performs the aspect logic.
Spring doesn’t create a proxied object until that proxied bean is needed by the application. If you’re using an ApplicationContext , the proxied objects will be created when it loads all the beans from the BeanFactory . Because Spring creates proxies at runtime, you don’t need a special compiler to weave aspects in Spring’s AOP
3.SPRING ONLY SUPPORTS METHOD JOIN POINTS
Because it’s based on dynamic proxies, Spring only supports method join points.If you find yourself in need of more than method interception, you’ll want to complement Spring AOP with AspectJ.
相关文章推荐
- Asp.net MVC Session过期异常的处理
- IIS是如何处理ASP.NET请求的
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-002-AOP术语解析
- SPRING IN ACTION 第4版笔记-第四章Aspect-oriented Spring-001-什么是AOP
- 在ASP.NET中如何输出日志
- 【ASP.NET】六大内置对象
- ASP.NET MVC- DropDownList绑定
- ASP.NET 使用Ajax
- asp.net mvc4使用log4.net 日志功能
- [DevExpress]ASP.NET動態設定XtraReport報表參數的方式 5715 ASP.NET 檢舉文章 在ASP.NET中要如何動態設定XtraReport報表參數,或
- ASP.NET数据绑定GridView控件使用技巧
- asp.net 接口函数
- 7天 搞定 ASP.NET MVC - 第3天
- ASP.NET MVC 多语言实现技巧 最简、最易维护和最快速开发
- ASP.NET MVC中viewData、viewBag和templateData的使用与区别
- ASP.NET 4 视频教程 风云之旅系列课程
- Asp.Net MVC anti-forgery token的问题:nameidentifier or identityprovider not present
- ASP.NET MVC ActionResult的其它返回值
- ASP.Net MVC开发基础学习笔记(2):HtmlHelper与扩展方法
- 细说 ASP.NET Cache 及其高级用法