Hi there. You can get information about the calling method using thisEnclosingJoinPointStaticPart. The docs don’t say much about it although it has been elaborated on in past on this mailing list.

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Java guru
Sent: Friday, September 08, 2006 9:44 AM
To: [email protected]
Subject: [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?

 

 

_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to