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.

MultipleArgs.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import java.util.*;
  2. import org.aspectj.lang.annotation.*;
  3. import org.aspectj.lang.*;
  4. @Aspect
  5. public class MultipleArgs {
  6. @Around("call(* callone(..)) && !within((MultipleArgs)) && args(a,b,c)")
  7. public void a1(ProceedingJoinPoint pjp,int a,String b,List c) {
  8. System.err.println("advice running");
  9. pjp.proceed(new Object[]{a,b,c});
  10. }
  11. @Around("call(* calltwo(..)) && !within((MultipleArgs)) && args(a,b,c)")
  12. public void a2(ProceedingJoinPoint pjp,String b,List c,int a) {
  13. System.err.println("advice running");
  14. pjp.proceed(new Object[]{a,b,c});
  15. }
  16. @Around("call(* callone(..)) && !within((MultipleArgs)) && args(a,b,c) && this(o)")
  17. public void a3(ProceedingJoinPoint pjp,int a,String b,List c,Object o) {
  18. System.err.println("advice running");
  19. pjp.proceed(new Object[]{o,a,b,c});
  20. }
  21. public static void main(String []argv) {
  22. new Test().doit();
  23. }
  24. }
  25. class Test {
  26. public void doit() {
  27. List l = new ArrayList();
  28. callone(5,"hello",l);
  29. calltwo(5,"hello",l);
  30. callthree(5,"hello",l);
  31. callfour(5,"hello",l);
  32. }
  33. public void callone(int i,String s, List l) {}
  34. public void calltwo(int i,String s, List l) {}
  35. public void callthree(int i,String s, List l) {}
  36. public void callfour(int i,String s, List l) {}
  37. }