Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Initialization Join Points for Interfaces ..

Thanks .. works like a charm ..

On 12/3/06, Eric Bodden <eric.bodden@xxxxxxxxxxxxxx> wrote:
Did you try...

initialization(Interface+.new(..)) && !initialization(Interface.new (..))

...?


Eric

> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-
> bounces@xxxxxxxxxxx] On Behalf Of Debasish Ghosh
> Sent: Saturday, December 02, 2006 3:32 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: [aspectj-users] Initialization Join Points for Interfaces ..
>
> Hi -
>
> I have a question regarding initialization pointcuts for interfaces.
>
> Suppose I have an initialization pointcut as :
>
> initialization(Interface+.new(..)), where Interface is a Java
interface
> and I have a class as :
>
> public class Implementation implements Interface {
>     // ...
> }
>
> In this case I get 2 initialization joinpoints - one for the interface
> and the other for the implementation. In case, in the after-returning
> advice, I would like to ignore the interface specific one, what is the
> best practice for doing this ? I do not want to introduce the
> implementation class within the advice, since I can have multiple
> implementations of this interface. I came up with the following ..
>
> after(Interface client) returning :
>         clientCreation(client) {
>         if ("org.dg.biz.Interface".equals(
>                 thisJoinPoint.getSignature().getDeclaringTypeName()))
{
>             return;
>         }
>         // .. rest of the advice
> }
>
> However, I do not like this string comparison. Is there a better way
to
> achieve this ?
>
> Thanks.
> - Debasish



Back to the top