您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

pr128237.java 645B

1234567891011121314151617181920212223242526272829
  1. import org.aspectj.lang.JoinPoint;
  2. import org.aspectj.lang.annotation.Aspect;
  3. import org.aspectj.lang.annotation.Before;
  4. import org.aspectj.lang.annotation.Pointcut;
  5. @Aspect
  6. class AbstractTracer
  7. {
  8. @Pointcut("(execution(public * Foo.anotherMethod*(..)) || execution(public * Foo.methodA(..))) && this(obj)")
  9. protected void methodExec(Object obj){};
  10. @Before("methodExec(obj)")
  11. public void beforeMethodExec(JoinPoint thisJoinPoint, Object obj) {
  12. System.out.println("Before " + thisJoinPoint.getSignature().toString());
  13. }
  14. }
  15. class Foo {
  16. public void methodA() {
  17. }
  18. public void anotherMethod() {
  19. }
  20. }