我正在尝试使用aspectj从日志文件中排除几种方法(我只使用
spring和Load-time编织).有没有办法列出aop.xml中的排除方法?我知道我可以为全班做这个,但我正在寻找具体的方法.或者我可以在方面类中列出一个列表?
谢谢
谢谢
解决方法
我不知道如何在
XML中做到这一点,但是在方面本身很容易做到这一点,因为可以使用布尔运算符组合切入点.
传统的aspectj语法:
pointcut whatIDontWantTomatch() : within(SomeClass+) || execution(* @SomeAnnotation *.*(..)); pointcut whatIWantTomatch() : execution(* some.pattern.here.*(..)); pointcut allIWantTomatch() : whatIWantTomatch() && ! whatIDontWantTomatch();
@AspectJ语法:
@pointcut("within(SomeClass+) || execution(* @SomeAnnotation *.*(..))") public void whatIDontWantTomatch(){} @pointcut("execution(* some.pattern.here.*(..))") public void whatIWantTomatch(){} @pointcut("whatIWantTomatch() && ! whatIDontWantTomatch()") public void allIWantTomatch(){}
这些当然只是样品. whatIDontWantTomatch()也可以由几个切入点等组成.