Skip to main content



      Home
Home » Language IDEs » AspectJ » How to retrieve method name in a handle clause
How to retrieve method name in a handle clause [message #60208] Fri, 06 January 2006 10:42 Go to next message
Eclipse UserFriend
Originally posted by: philippe.larouche.cardinal.com

Hi guys, I want to log some info in a file each time an exception is thrown
and one info that I'm interested in is the method's name where the exception
has been handled. The problem is that in an handle clause, I'm not able to
retrieve my method name. Here's how I defined the pointcut

pointcut logging(Exception exception) :
handler(!MyException) && args(exception);

I want to log everytime an exception (that is not a MyException instance) is
thrown.


Can someone help me please?? I tried to retrieve the info by the signature,
but it doesn't work.

Thanks,
Phil
Re: How to retrieve method name in a handle clause [message #60281 is a reply to message #60208] Mon, 09 January 2006 04:15 Go to previous messageGo to next message
Eclipse UserFriend
Philippe Larouche wrote:
> Hi guys, I want to log some info in a file each time an exception is thrown
> and one info that I'm interested in is the method's name where the exception
> has been handled. The problem is that in an handle clause, I'm not able to
> retrieve my method name. Here's how I defined the pointcut
>
> pointcut logging(Exception exception) :
> handler(!MyException) && args(exception);
>
> I want to log everytime an exception (that is not a MyException instance) is
> thrown.
>
>
> Can someone help me please?? I tried to retrieve the info by the signature,
> but it doesn't work.
>
> Thanks,
> Phil
>
>

You can use the special variable "thisEnclosingJoinPointStaticPart"
inside the body of an advice method. In the case of a handler join
point, the enclosing join point will be a method or constructor
execution join point, from which you can get the method name etc.

Regards, Adrian.
Re: How to retrieve method name in a handle clause [message #60329 is a reply to message #60281] Mon, 09 January 2006 13:26 Go to previous message
Eclipse UserFriend
Originally posted by: philippe.larouche.cardinal.com

Thx, it's exactly what I wanted to do... It works perfectly.

"Adrian Colyer" <adrian.colyer@gmail.com> wrote in message
news:dpt9ka$575$2@utils.eclipse.org...
> Philippe Larouche wrote:
>> Hi guys, I want to log some info in a file each time an exception is
>> thrown and one info that I'm interested in is the method's name where the
>> exception has been handled. The problem is that in an handle clause, I'm
>> not able to retrieve my method name. Here's how I defined the pointcut
>>
>> pointcut logging(Exception exception) :
>> handler(!MyException) && args(exception);
>>
>> I want to log everytime an exception (that is not a MyException instance)
>> is thrown.
>>
>>
>> Can someone help me please?? I tried to retrieve the info by the
>> signature, but it doesn't work.
>>
>> Thanks,
>> Phil
>
> You can use the special variable "thisEnclosingJoinPointStaticPart" inside
> the body of an advice method. In the case of a handler join point, the
> enclosing join point will be a method or constructor execution join point,
> from which you can get the method name etc.
>
> Regards, Adrian.
Re: How to retrieve method name in a handle clause [message #591641 is a reply to message #60208] Mon, 09 January 2006 04:15 Go to previous message
Eclipse UserFriend
Philippe Larouche wrote:
> Hi guys, I want to log some info in a file each time an exception is thrown
> and one info that I'm interested in is the method's name where the exception
> has been handled. The problem is that in an handle clause, I'm not able to
> retrieve my method name. Here's how I defined the pointcut
>
> pointcut logging(Exception exception) :
> handler(!MyException) && args(exception);
>
> I want to log everytime an exception (that is not a MyException instance) is
> thrown.
>
>
> Can someone help me please?? I tried to retrieve the info by the signature,
> but it doesn't work.
>
> Thanks,
> Phil
>
>

You can use the special variable "thisEnclosingJoinPointStaticPart"
inside the body of an advice method. In the case of a handler join
point, the enclosing join point will be a method or constructor
execution join point, from which you can get the method name etc.

Regards, Adrian.
Re: How to retrieve method name in a handle clause [message #591657 is a reply to message #60281] Mon, 09 January 2006 13:26 Go to previous message
Eclipse UserFriend
Thx, it's exactly what I wanted to do... It works perfectly.

"Adrian Colyer" <adrian.colyer@gmail.com> wrote in message
news:dpt9ka$575$2@utils.eclipse.org...
> Philippe Larouche wrote:
>> Hi guys, I want to log some info in a file each time an exception is
>> thrown and one info that I'm interested in is the method's name where the
>> exception has been handled. The problem is that in an handle clause, I'm
>> not able to retrieve my method name. Here's how I defined the pointcut
>>
>> pointcut logging(Exception exception) :
>> handler(!MyException) && args(exception);
>>
>> I want to log everytime an exception (that is not a MyException instance)
>> is thrown.
>>
>>
>> Can someone help me please?? I tried to retrieve the info by the
>> signature, but it doesn't work.
>>
>> Thanks,
>> Phil
>
> You can use the special variable "thisEnclosingJoinPointStaticPart" inside
> the body of an advice method. In the case of a handler join point, the
> enclosing join point will be a method or constructor execution join point,
> from which you can get the method name etc.
>
> Regards, Adrian.
Previous Topic:Eclipse AspectJ Newbie Problem
Next Topic:AJDT is slow
Goto Forum:
  


Current Time: Mon Apr 28 02:16:37 EDT 2025

Powered by FUDForum. Page generated in 0.04956 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top