[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] How to track a caller
|
Hi
I have a situation where I need to get the information about the calling method.
By calling method I mean, the method from which a call to another method is made, which satisfies a pointcut def. I am providing an example below
pointcut interceptGetStament(): call(public String getTest(*));
String around() : interceptGetStament(){
MethodSignature sig = (MethodSignature) thisJoinPoint.getSignature();
System.out.println(thisJoinPoint.getSignature().getName());
return thisJoinPoint.getSignature
().getName();
}
public class Test {
public String getTest(String s)
{
return s;
}
}
public class Test1 {
public static void main(String[] args) {
Test t = new Test();
System.out.println(t.getTest("hellow"));
}
}
Now when I run Test1, i need to printout the method which calls getTest(), in this case its "main".But what I am getting is "getTest" as it is the joinPoint. How do I go about it?