[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] 3 PROBLEMS--how to get value of parameters of method captured, how to capture all methods, jars needed
|
1) HOW DO I GET THE VALUE OF THE PARAMETERS/ARGUMENTS OF THE METHODS CAPTURED ?
I tried doing it thisJoinPoint.getArgs() but this gave me
something else
thisJoinPoint.getArgs() should work:
public class A {
public static void main(String[]argv) {
new A().m(4);
}
public void m(int i) {}
}
aspect X {
before(): call(* m(..)) { System.out.println(thisJoinPoint.getArgs()[0]);}
}
ajc A.java
java A
4
If your parameters are primitives they will be 'boxed' into their
object equivalent - int becomes Integer for example.
2)IF I WANT TO CAPTURE ALL THE METHODS THAT ARE CALLED WHAT POINT CUT SHOULD I USE? THE ONE I HAVE USED ABOVE ASSUMES THAT THERE ARE 1 OR 2
ARGUMENTS BUT THAT MAY NOT BE TRUE! SO HOW SO I CAPTURE ALL CALLS
IRRESPECTIVE OF NO. OF PARAMETERS.
call(* *(..))
'..' meaning any number of parameters
3)WHICH JARS CONTAIN THE DEFINATION OF thisJoinPoint ... APART FROM
ASPECTJRT.JAR ASPECTJLIB.JAR ASPECTJTOOLS.JAR ASPECTJWEAVER.JAR
aspectjrt.jar (the runtime jar) is the jar that should be on your path
when executing woven code, it contains the implementation of
thisJoinPoint. The 'construct' thisJoinPoint that you use in an
aspect is handled directly by the compiler.