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 ..

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

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

...?


The above is definitely gonna work :-). Wondering why:

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

doesn't (I mean it is clear there is no Interface.new and most
probably Interface.new is in fact Object.new, but I am wondering if
are there any other reasons).

./alex
--
.w( the_mindstorm )p.


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

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



Back to the top