Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ajdt-dev] How to get the caller's details for a executionpointcut?

Well, it is isn't pretty. Just build a RuntimeException then take it apart.

RuntimeException re = new RuntimeException();
StackTraceElement[] trace = re.getStackTrace();

It will also severely impact performance as building stack traces within the exceptions isn't cheap.

cheers,
Andy.

2008/7/30 PATIL Arvind <Arvind_PATIL@xxxxxxxxxxxxxxxxx>

Hi Andy,

It would be helpful if you could give more details on 'how to manually inspect stack trace'?

Code snippet will be useful.

 

regards,

arvind

=========================

From: ajdt-dev-bounces@xxxxxxxxxxx [mailto:ajdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
Sent: Tuesday, July 29, 2008 9:47 PM
To: ajdt-dev@xxxxxxxxxxx
Subject: Re: [ajdt-dev] How to get the caller's details for a executionpointcut?

 

You can only get the callers information if you advise the call-site.  If you advise the execution-site then it is too late (although you *could* 'manually' inspect the stack trace at that point to determine the caller).

cheers,
Andy.

2008/7/29 PATIL Arvind <Arvind_PATIL@xxxxxxxxxxxxxxxxx>

Hi,

I have defined a pointcut of type execution for a method test() in a class ABC.

And I have defined a before-advice which is supposed to show the file name and line number of the caller programs which invoke this method ABC.test().

 

This is the advice code.

 

   static private void printParameters(JoinPoint jp) {

                   System.out.println("Source: " +jp.getSourceLocation());

}

 

However, this always displays the callee method details.

How can I get the caller's details for a execution pointcut?

 

thanks,

arvind

-------------------------------------------------------------------------------------------------------------------------------------------------------------

 


_______________________________________________
ajdt-dev mailing list
ajdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ajdt-dev

 


_______________________________________________
ajdt-dev mailing list
ajdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ajdt-dev



Back to the top