You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServiceInterceptor.java 946B

1234567891011121314151617181920212223242526
  1. package test;
  2. import org.aspectj.lang.ProceedingJoinPoint;
  3. import org.aspectj.lang.annotation.Around;
  4. import org.aspectj.lang.annotation.Aspect;
  5. @Aspect public class ServiceInterceptor {
  6. //public aspect ServiceInterceptor {
  7. // void around(): execution(void test.Service.method(long)) {
  8. // Object[] args = thisJoinPoint.getArgs();
  9. // long id = (Long) args[0];
  10. // System.out.println("in advice, arg = " + id + " (before proceed)");
  11. // proceed();
  12. // System.out.println("in advice (after proceed)");
  13. // }
  14. @Around("execution(void test.Service.method(long))")
  15. public void method(ProceedingJoinPoint pjp) throws Throwable {
  16. Object[] args = pjp.getArgs();
  17. long id = (Long) args[0];
  18. System.out.println("in advice, arg = " + id + " (before proceed)");
  19. pjp.proceed(pjp.getArgs());
  20. System.out.println("in advice (after proceed)");
  21. }
  22. }