首页 > 编程语言 > 详细

spring aop 申明了切面类之后,如何申明切入点呢?

时间:2015-04-08 13:21:36      阅读:312      评论:0      收藏:0      [点我收藏+]

8.2.3 Declaring a pointcut

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.


spring aop 申明了切面类之后,如何申明切入点呢?

原文:http://my.oschina.net/u/2308739/blog/397246

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!