Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] declare parents syntax

That's a good clarification, thanks. Often this pattern is adequate when
working in application code where you expect to have subtypes in the same
packages (and the warning is a good enforcement/reminder tool).

However, these caveats just further remind me of the improved value that
having a named reusable type pattern would provide. I think a reusable type
pattern is what Eugene wants also. And named type patterns (and method
signatures too) would also allow more readable versions of complex
expressions through composition of named parts.

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Wes Isberg
Sent: Saturday, September 30, 2006 12:19 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] declare parents syntax

Just remember that 

  within(XyzType+)

can pick out subtypes outside com.xyz..* that extend
a type in com.xyz..*

You can name the pointcut to reuse it:

  pointcut inScope() : within(com.xyz..*);

then
  before(): something() && inScope() {..}

To address the problem of typo's (i.e., redundancy across
type patterns and pointcuts), try something like

  declare parents : com.xyz..* : implements X;

  declare warning : staticinitialization(X+)
     && !inScope() : "X not in scope";

The latter would also pick out those types not in
com.xyz..*
i.e., the subtypes outside the package.

Wes

On Fri, 29 Sep 2006 11:14:00 -0700
 "Ron Bodkin" <rbodkin@xxxxxxxxxxxxxx> wrote:
> Hi Eugene,
> 
> It would be great to have a way to reuse type patterns in
> AspectJ... that's
> something I've advocated for a while. That's how I'd
> improve on redundancy.
> 
> But if you are using declare parents you could use the
> new type in your
> pointcut, i.e., use this pointcut execution(* *(..)) &&
> within(XyzType+)
> instead of execution(* *(..)) && within(com.xyz..*)
> 
> 
> 
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of
> Eugene Kuleshov
> Sent: Friday, September 29, 2006 11:04 AM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] declare parents syntax
> 
> 
>   Thanks Ron, I know that. But the thing is that the same
> pattern is 
> used in pointcuts to apply additional aspects to the very
> same classes. 
> Hence a duplication that may lead to some unexpected
> typos.
> 
>   regards,
>   Eugene
> 
> 
> Ron Bodkin wrote:
> > Hi Eugene,
> >
> > declare parents accepts a type pattern, not a pointcut.
> A type pattern
> picks
> > out types, whereas a pointcut picks out join points.
> The expression inside
> a
> > within pointcut are is a type pattern.
> >
> > Here's an example of using declare parents to match a
> type pattern, which
> is
> > surely what you wanted to do with within:
> >
> > declare parents: com.xyz..* implements XyzType;
> >
> >
> > -----Original Message-----
> > From: aspectj-users-bounces@xxxxxxxxxxx
> > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of
> Eugene Kuleshov
> > Sent: Thursday, September 28, 2006 12:06 PM
> > To: aspectj-users@xxxxxxxxxxx
> > Subject: [aspectj-users] declare parents syntax
> >
> > Hi,
> >
> >   I wonder why "declare parents" introduction syntax
> does not allow to 
> > use within(*) pointcut expression?
> >
> >   This limitation lead to significant amount of
> duplication in the 
> > aspect code and/or makes xml-based aspect definitions
> more verbose. The 
> > only workaround I know is to "bridge" trough annotation
> introduction, 
> > but that approach does not work on 1.4 and looks like a
> hack.
> >
> >   I thought I saw that it was possible to use within
> pointcuts for this 
> > in some old version of AspectJ but it was removed. I
> might be mistaken 
> > though...
> >
> >   Thanks
> >
> >   Eugene
> >
> >
> >   
> 
> _______________________________________________
> 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



Back to the top