Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to get caller method name, little urgent.

There is no direct way to get the name of the calling method using
AspectJ.  The best solution is to look at
thisJoinPointStaticPart.getSourceLocation() and then map the resulting
location back to a method in the original text.

As for your second question, are you asking to call aspectJLogging
instead of logData, or in addition to?

Either way, something like this should work:

void around(LogExample l, int i) : execution(public void logData(int)
&& this(l) && args(i) {
    l.aspectJLogging(i);
    proceed(i);
}

2010/6/9 Rajat Gupta <innocent_person1@xxxxxxxxx>:
> Hi all !
>
> I want to get the caller method name which calls a particular api.
> So ideally i should get "testMethod" when ever i call "logData" method.
>
> There is another question related to this after earlier part is complete I
> want to use "aspectJLogging" method when ever "logData" method is called.
> Please suggest this as well.
>
> I had attached the files.
>
> I would be very thankful for your help.
>
> Many Thanks
> Rajat
>
>
>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top