[aspectc-user] inheritance of advice code

Panu Bloigu panu.bloigu at gmail.com
Thu Oct 4 12:50:38 CEST 2007


Hello.

Francisco Afonso wrote:
> Hi,
>
> I think that it is impossible to do that with "execution" advices. You have to use "call" advices.
>   
I'm starting to think that this really is the case. However, some 
developer insight to why it can't be done with execution advices, would 
be nice. Especially I'm curious about why the derived() pointcut 
function selects the base class also. In my opinion, that implies that 
the base class is derived from itself, which in turn strikes me odd 
semantic-wise. While I'm sure the developers have sound reasons for 
introducing this behavior, it would be appreciated from my part if they 
could offer a peek into the reasons affecting behind this.
>
> Francisco Afonso
> University of Minho - Portugal
>
>
> ----------------------------------------> Date: Thu, 4 Oct 2007 11:15:55 +0300> From: panu.bloigu at gmail.com> To: aspectc-user at aspectc.org> Subject: [aspectc-user] inheritance of advice code>> Hello.>> I wonder I anyone would care to suggest an approach to solve the> following problem I have.>> In short, what I want to do is to prevent an execution advice from> affecting the descendant classes. The longer version of the problem follows.>> Let's consider, for instance, that I have a class named A with a method> m() defined in it. Then I have an aspect with the following advice:>> advice execution("void A::m()") : before() {/* code here */}>> The problem here is that now, if I derive a class from the class A> without overriding the method m(), every time I call the method m() on> an instance of the derived class, the code in the above advice gets> executed. My question is that how do I prevent this from happening (or,> is it even possible) without having to override the method m() in the> descendant classes?>> I would think that using that() pointcut function would do the trick:>> advice execution("void A::m()") && that("A") : before(){/* code here */}>> but, alas, that's not the case, as that("A") selects every join point> where 'this' pointer points to an instance of the class A *or any of> it's descendants*. Also, using the pointcut function derived() doesn't work:>> advice execution("void A::m()") && that(!derived("A")) : before(){/*> code here */}>> as it considers the class A to be a descendant of itself, i.e. the above> pointcut description will exclude the execution of the method m() in the> class A too, which is not what I want. Of course this could probably be> solved by inserting some RTTI code in the execution advice to make sure> that the advice code is executed only in the (runtime) context of class> A, and none of its descendants, but I would like to know if this can be> done with AspectC++ code only.>> Thanks in advance,>> -- Panu.>>>>>> _______________________________________________> aspectc-user mailing list> aspectc-user at aspectc.org> http://www.aspectc.org/mailman/listinfo/aspectc-user
>
> _________________________________________________________________
> Peek-a-boo FREE Tricks & Treats for You!
> http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us
>   

-- Panu.






More information about the aspectc-user mailing list