标签:
Recall that pointcuts determine join points of interest, and thus enable us to control when advice executes. Spring AOP only supports method execution join points for Spring beans, so you can think of a pointcut as matching the execution of methods on Spring beans.
A pointcut declaration has two parts: a signature comprising a name and any parameters, and a pointcut expression that determines exactly which method executions we are interested in.
Pointcut 申明有两个部分哦,一个是签名方法 包含有方法名字和参数。另外一个是切入点表达式,这个是用来申明在哪些方法上面执行切入。
In the @AspectJ annotation-style of AOP, a pointcut signature is provided by a regular method definition, and the pointcut expression is indicated using the @Pointcut
annotation (the method serving as the pointcut signature must have a void
return type).
pointcut 签名 必须是无返回值得。
下面就是一个例子:
An example will help make this distinction between a pointcut signature and a pointcut expression clear. The following example defines a pointcut named‘anyOldTransfer‘
that will match the execution of any method named ‘transfer‘
:
@Pointcut("execution(* transfer(..))")// the pointcut expression private void anyOldTransfer() {} // the pointcut signature
The pointcut expression that forms the value of the @Pointcut
annotation is a regular AspectJ 5 pointcut expression. For a full discussion of AspectJ’s pointcut language, see the AspectJ Programming Guide (and for extensions, the AspectJ 5 Developers Notebook) or one of the books on AspectJ such as "Eclipse AspectJ" by Colyer et. al. or "AspectJ in Action" by Ramnivas Laddad.
标签:
原文地址:http://my.oschina.net/u/2308739/blog/397246