lio*_*ior 6 aop aspectj spring-aop
我正在尝试使用aspectj从日志文件中排除几种方法(我只使用spring和Load-time编织).有没有办法列出aop.xml中的排除方法?我知道我可以为全班做这个,但我正在寻找具体的方法.或者我可以在方面类中列出一个列表?谢谢
Sea*_*oyd 13
我不知道如何在XML中做到这一点,但是在方面本身很容易做到这一点,因为可以使用布尔运算符组合切入点.
传统的aspectj语法:
pointcut whatIDontWantToMatch() : within(SomeClass+) || execution(* @SomeAnnotation *.*(..));
pointcut whatIWantToMatch() : execution(* some.pattern.here.*(..));
pointcut allIWantToMatch() : whatIWantToMatch() && ! whatIDontWantToMatch();
Run Code Online (Sandbox Code Playgroud)
@AspectJ语法:
@Pointcut("within(SomeClass+) || execution(* @SomeAnnotation *.*(..))")
public void whatIDontWantToMatch(){}
@Pointcut("execution(* some.pattern.here.*(..))")
public void whatIWantToMatch(){}
@Pointcut("whatIWantToMatch() && ! whatIDontWantToMatch()")
public void allIWantToMatch(){}
Run Code Online (Sandbox Code Playgroud)
这些当然只是样品.whatIDontWantToMatch()也可以由几个切入点等组成.
| 归档时间: |
|
| 查看次数: |
8752 次 |
| 最近记录: |