[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] OnType Variables For Inter-Type Declarations
|
Hi Jared,
Currently OnType must be a specific type - I have thought about
enabling it to be a type variable (declared in the aspect definition)
but haven't had the time to do anything about that yet. If you want
to ITD on a bunch of types the pattern is usually like this:
interface Marker {}
public void Marker.someMethod() { }
declare parents: (@Something *) implements Marker;
You can see that varying the declare parents pattern will cause the
ITD to apply to a number of types.
However, that doesn't address precisely what you asked - applying it
to the class(es) affected by an aspect. Right now you would have to
have some duplication because we don't have named type patterns. So
your :
> public aspect InstanceTracking pertypewithin(org.xyz..*) {
> public static final String getWithinTypeName().typeName =
> getWithinTypeName();
> }
could be:
public aspect InstanceTracking pertypewithin(org.xyz..*) {
declare parents: org.xyz..* implements Marker; // duplicating the
org.xyz..* string
interface Marker {}
public void Marker.method() {}
}
cheers
Andy
On 29 April 2011 15:13, Jared D. Cottrell <jcottr@xxxxxxxxx> wrote:
> Is it possible to use variables or wildcards in the OnType expression
> in an inter-type declaration?
>
> Modifiers Type OnType . Id [ = Expression ] ;
>
> The desire is to add a member to whichever class or classes the aspect
> is applied to. All the examples I could find, however, explicitly
> name the OnType. Perhaps this can be done in combination with
> pertypewithin as in the example below?
>
> public aspect InstanceTracking pertypewithin(org.xyz..*) {
> public static final String getWithinTypeName().typeName =
> getWithinTypeName();
> }
>
> Cheers!
>
>
> Jared
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>