Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] [Newbie] Pick out a call / execution only in the hierarchy leafs

Hi Petecan,

try ...

   public pointcut getOptionsPointcut() :
       call(public String[] OptionHandler.getOptions())
       && withincode(Randomizable+)
     ;

As stated in the Programming Guide
(http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/do
c/progguide/language-joinPoints.html#d0e1288) calls should not capture
super calls.

Bruno

> -----Original Message-----
> From: aspectj-users-admin@xxxxxxxxxxx 
> [mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Petecan
> Sent: Thursday, July 22, 2004 11:30
> To: aspectj-users@xxxxxxxxxxx
> Subject: [aspectj-users] [Newbie] Pick out a call / execution 
> only in the hierarchy leafs
> 
> 
> Hi all,
> 
> I have the following two interfaces:
> 
>   /*****************************/
>   public Interface OptionHandler{
>      ...
>      String[] getOptions();
>   }
> 
>   public Interface Randomizable{
>     ...
>   }
>   /*****************************/
> 
> And I want to advice all calls to the OptionHandler.getOptions method 
> within Randomizable & OptionHandler implementing classes. I use the 
> following pointcut and advice:
> 
>   /*****************************/
>   public pointcut getOptionsPointcut() :
>       execution(public String[] OptionHandler.getOptions())
>       && within(Randomizable+)
>     ;
> 
>   String[] around() : getOptionsPointcut(){
>     return Utils.appendOptions(getOption(), proceed());
>   }
>   /*****************************/
> 
> Now, given the following hierarchy:
> 
>    /*****************************/
>   class A implements  OptionHandler, Randomizable{
>       String[] getOptions(){
>          ...
>       }
>    }
> 
>    class B extends A{
>       String[] getOptions(){
>          super.getOptions();
>          ...
>       }
>    }
>   /*****************************/
> 
> The poincut captures both the getOptions() execution in A and 
> B, and I 
> want it to capture only the execution in the "leaf" class of the 
> hierarchy (class B, in this case). In other words, the 
> A.getOptions must 
> be picked out only if it is directly invoked but not if it is called 
> from a redefining method via the super reference.  How can I 
> do that?. 
> Is there a better or more elegant way of defining the pointcut to 
> capture these joint points?.
> 
> Best Regards
> 
> Santi.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx 
> http://dev.eclipse.org/mailman/listinfo/aspect> j-users
> 



Back to the top