SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-004-使用AspectJ’s pointcut expression language定义Pointcut

一、

1.在Spring中,pointcut是通过AspectJ’s pointcut expression language来定义的,但spring只支持它的一部分,如果超出范围就会报IllegalArgumentException,支持的语法如下:

其实就是支持execution(),然后通过其他的标签来缩小范围

2.例子

package concert;
public interface Performance {
    public void perform();
}

(1)不限返回类型,不限函数参数原型,只要是concert.Performance执行perform(),就织入

(2)使用within限定范围包的范围

PS:对应还有||(或)、!(非),但在xml中时要用and 、or 、not

(3)在bean()中指定bean id 或name来限定bean的范围

只有id为"woodstock"的bean才会被织入

execution(* concert.Performance.perform())
and bean('woodstock')

与上面相反

execution(* concert.Performance.perform())
and !bean('woodstock')

 

posted @ 2016-03-03 15:47  shamgod  阅读(195)  评论(0编辑  收藏  举报
haha