Hi Dean,
The declare error doesn’t apply
because the advice is dispatched from those methods but it isn’t executed within them. You are asking for a
new pointcut, say advised, that is to adviceexecution as call is to execution (modulo
the difference between implicit and explicit dispatch).
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On
Behalf Of Dean Wampler
Sent: Tuesday, February 20, 2007
12:07 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Q
about "adviceexecution" and "declare error"
Ron Bodkin wrote:
Indeed, you would want a withinadvice pointcut, but failing
that you might just refactor to expose the relevant code as a method. Of
course, to have something like withinadvice be useful, I’d want AspectJ
to have better matching on advice signatures too (so you could say
adviceexecution(before(int, String))).
Agreed.
What I ended up doing was writing a PCD that looks something like this:
cflow(execution(* MyClass.myRestrictedMethod(..)) &&
adviceexecution() && !within(ProhibitAdvice+)
(ProhibitAdvice is the aspect...)
Then I used before advice to throw an exception. Again, my particular goal is
to prevent any advice from being invoked within the execution context of
"myRestrictedMethod()".
Here's what I find perplexing. The following does nothing:
declare error: withincode(* MyClass.myRestrictedMethod(..)) &&
adviceexecution(): "message";
Looking at the AJDT adornments, it's clear that advice is being applied within
the method, from another aspect designed to trigger the error (the adornment
doesn't have a '?' on it ;). What am I missing? I thought of precedence, but
experiments there didn't do anything.
Thanks,
dean
Thanks, Ramnivas,
I was under the mistaken impression that adviceexecution works something like a
"withincode" or "cflow", which of course it doesn't.
dean
Ramnivas Laddad wrote:
Dean,
Since adviceexecution() will match an advice join point and
criticalSectionPCD() will match a non-advice join point (in your case, I
presume you are selecting execution() or call() join point), combining the
corresponding pointcuts using && will match nothing.
-Ramnivas
On 2/20/07, Dean Wampler <dean@xxxxxxxxxxxxxxxxxxxxx>
wrote:
I'm working on idioms for defining PCDs that a class
developer can use to exclude join points from possible advices. For example,
say I want a 'critical section' to never be advised.
What I've tried is something like the following:
declare error: criticalSectionPCD() && adviceexecution(): "Can't
advise the critical section."
This compiles fine, but it has no effect. (I defined another aspect that breaks
the rule.)
Suggestions?
dean
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users