I believe the benefit of using
if(false)
or
pointcut none();
is that the compiler/weaver prunes any && branch with that when
the
pointcut is simplified internally. By contrast,
within(no.such.type)
is not simplified but checked against every class (if it doesn't gack on
there being no such type).
Wes
------------Original Message------------
From: Bo Yi <boyi@xxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Cc: aspectj-users@xxxxxxxxxxx, aspectj-users-bounces@xxxxxxxxxxx
Date: Fri, Oct-21-2005 6:25 AM
Subject: Re: [aspectj-users] Implementing abstract pointcut that includes
nojoinpoints I use abstract pointcut and
suggest that each concrete aspect implement all abstract pointcuts. If a
specific abstract pointcut need to be empty I use the following to express my
intention:
pointcut
loggingSubsystem() : within(no.logging.subsystem);
You may add an annotation to override warning.
Or you may try to override it with an
empty pointcut (I have not tried this yet, so let me know whether it
works)
pointcut
loggingSubsystem();
Bo ---------------------------------------------------------- Dr.
Bo Yi WebSphere Development & Testing IBM Toronto Lab
A2-713/Q2Z/8200/MKM 8200 Warden Ave. Markham ONT. L6G
1C7 Phone: 905-413-4819 Tie Line: 969-4819 E-Mail:
boyi@xxxxxxxxxx
Ken Pelletier
<ken@xxxxxxxx> Sent
by: aspectj-users-bounces@xxxxxxxxxxx
10/21/2005 09:04 AM
Please respond
to aspectj-users |
|
To
| aspectj-users@xxxxxxxxxxx
|
cc
|
|
Subject
| Re: [aspectj-users]
Implementing abstract pointcut that includes
nojoinpoints |
|
Thanks for all the quick replies.
Oddly, I did try the
pointcut with not spec:
protected pointcut
overriddenAbstractPointcut();
But because I'd missed on the parameter
matching (the abstract decl captures the target for around advice
which I'd left off in the sub), I mistakenly thought that the syntax
was generally incorrect.
So, it's actually the first thing that came to
mind, which is always a good feeling.
It's also good to see
that this can be done in the base aspect; sort of a parallel with
the template method pattern, only for pointcuts and advice.
Good stuff.
Thanks,
- Ken
On Oct 21, 2005, at 12:24
AM, Ron Bodkin wrote:
> Ken, > > This syntax will do it,
although it is a little counterintuitive > when you > first
encounter it: > > protected pointcut
overriddenAbstractPointcut(); > > You can also define a default
empty value in a concrete pointcut > (like this) > in an
abstract aspect and then override it with a non-empty >
definition in > some concrete aspects. E.g., > > abstract
aspect Base { > protected pointcut optionalPoint(); //
empty > } > > aspect Derived1 extends Base { >
protected pointcut optionalPoint() : within(foo..*); // defines
> for this > } > > aspect Derived2 extends Base
{ > // optional is empty for this concrete aspect >
} > > -----Original Message----- > From:
aspectj-users-bounces@xxxxxxxxxxx >
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Ken Pelletier >
Sent: Thursday, October 20, 2005 10:06 PM > To:
aspectj-users@xxxxxxxxxxx > Subject: [aspectj-users] Implementing
abstract pointcut that includes > nojoinpoints > > I have an
abstract aspect that declares a couple of abstract > pointcuts to be
overridden in concrete subclasses. > > In a particular subclass,
however I want to nullify one of those > pointcuts; include no
joinpoints at all. > > Is there a common idiom for implementing a
concrete pointcut that > explicitly includes no
joinpoints? > > I know I can nullify with && if(false),
but it smells funny to > declare any advice type at all if really none
applies. > > Eg: > > protected
overriddenAbstractPointcut() : > <what_would_advice_spec_be_here>
&& if(false; > > Regards, > > -
Ken > > PS: it's probably a design smell in the first place to
have abstract > pointcuts that sometimes have no applicable concrete
implementation, > but that's another matter. :-) >
_______________________________________________ > aspectj-users mailing
list > aspectj-users@xxxxxxxxxxx >
https://dev.eclipse.org/mailman/listinfo/aspectj-users > >
_______________________________________________ > aspectj-users mailing
list > aspectj-users@xxxxxxxxxxx >
https://dev.eclipse.org/mailman/listinfo/aspectj-users >
_______________________________________________ aspectj-users
mailing
list aspectj-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list aspectj-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/aspectj-users
|