Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] static crosscutting and type patterns

> unfortunatelly, though, the [OnType] identifier otherPackage.* does not
> work for me :-(
> 
> has this changed?

AspectJ 1.1 permits only one target for inter-type declarations.

http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/README-11.html#SINGLE_INTERCLASS_TARGET

(The documentation examples have not been updated for 1.1.)

> I have three classes foo.A,foo.B,foo.C and an Interface I.

Do you want declare on the interface?

  aspect A {
      public void I.doIt( ) {
          System.out.println("this will compile");
      }
  }

Wes

Jakob Praher wrote:
> 
> hi everybody,
> 
> I have a question concerning static crosscutting and type patterns.
> in the docu there is an example which is what I want to achieve:
> 
> aspect A {
>     private Registry otherPackage.*.r;
>     public void otherPackage.*.register(Registry r) {
>         r.register(this);
>         this.r = r;
>     }
> }
> 
> unfortunatelly, though, the [OnType] identifier otherPackage.* does not
> work for me :-(
> 
> has this changed?
> 
> perhaps there is another way to achieve:
> 
> I have three classes foo.A,foo.B,foo.C and an Interface I.
> The interface implementation is generic, but I don't want to write an
> abstract base class, since there is already a base class.
> 
> so I wanted to do the following (which when hard coding the identifier
> "OnType" works well )
> 
> interface I {
> 
>    public void doIt( );
> }
> 
> aspect {
> 
>   declare parents: foo.* implements I;  /* this works perfectly ! */
> 
>   /* but now I want to crosscut the methods, which work, if */
>   public void foo.A.doIt( ) {
>      System.out.println( "finished!" );
>   }
> 
>   /* but not when I do : */
>   public void foo.*.doIt( ) {
>      System.out.println( "this won't compile :-(" );
>   }
> 
> }
> 
> is there a new, or other way to achieve it?
> is there a way to externalize the type declarations (like load type
> names from a list, so you don't have to change the aspect, when a new
> package, or class is added ) ?
> 
> thank you in advance
> 
> -- Jakob
> btw: i am using aspectj 1.1
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top