[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] RE: [aspectj-users] Re: Why is 'if' pointcut restricted to static members of aspect?

Good answer.  Perhaps you could add it to the programming guide?  

Mik

> -----Original Message-----
> From: aspectj-users-admin@xxxxxxxxxxx [mailto:aspectj-users-
> admin@xxxxxxxxxxx] On Behalf Of Matthew Webster
> Sent: Thursday, March 25, 2004 4:44 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: [aspectj-users] Re: Why is 'if' pointcut restricted to static
> members of aspect?
> 
> 
> 
> 
> 
> An "if()" poincut can only make references to static fields and methods
> because it executes outside the context of an aspect instance. However you
> can always use the "aspectOf()" method:
> 
> public aspect Aspect {
> 
>       pointcut testIf () :
>             execution(* main(..)) && if(Aspect.aspectOf().isEnabled());
> 
>       before () : testIf () {
>             System.err.println(thisJoinPointStaticPart);
>       }
> 
>       private boolean enabled = true;
> 
>       public boolean isEnabled () {
>             return enabled;
>       }
> }
> 
> Matthew Webster
> AOSD Project
> Java Technology Centre, MP146
> IBM Hursley Park, Winchester,  SO21 2JN, England
> Telephone: +44 196 2816139 (external) 246139 (internal)
> Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
> http://w3.hursley.ibm.com/~websterm/
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users