码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2015-04-08 13:21:58      阅读:198      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!