Advice
(好多中文书籍翻译为:增强处理,比如前向增强、后向增强等)
描述了Aspect类执行的具体动作。the job of an aspect.
定义了如下两个方面:
- what:即Aspect类具体的功能;
- when:功能作用的时间点;
在spring中,when包括5个:
Join Points
A join point is a point in the execution of the application where an aspect can be plugged in.
This point could be a method being called, an exception being thrown, or even a field being modified.
程序中可以有很多个join point,这些连接点可以是方法调用、异常抛出、以及域修改等。这些都是在程序运行时的某个点。
Pointcuts
pointcut定义了advice需要在哪些join points进行织入。pointcuts define which join points get advised.
可以简单理解为若干join point的集合,advice会在这些join points进行织入。
If advice defines the what and when of aspects, then pointcuts define the where。
A pointcut definition matches one or more join points at which advice should be woven.
Aspect
An aspect is the merger of advice and pointcuts。
Aspect是advice和pointcuts的组合。
Introduction
An introduction allows you to add new methods or attributes to existing classes。
允许在已经存在的类中,添加新的方法和属性;
WEAVING
Weaving is the process of applying aspects to a target object to create a new proxied object。
主要有3种织入方式:
- Compile time:AspectJ使用这种方式;
- Class load time:AspectJ使用这种方式;
- Runtime:Spring支持的方式;
Spring对AOP的支持
spring AOP基于动态的代理实现,局限于对方法的拦截。
- SPRING ADVICE IS WRITTEN IN JAVA :所有的advice都使用Java编写,pointcut可使用XML或annotation;
- SPRING ADVISES OBJECTS AT RUNTIME:在运行时织入advice;
- SPRING ONLY SUPPORTS METHOD JOIN POINTS:仅支持方法的join point;
转载请标明出处:http://www.cnblogs.com/ssslinppp/