Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Instanciate an aspect for each object with specific annotation

I will probably use the following expression:

public aspect A perthis(this(@MyAnnotation *)) { ... }

I guess the following should work, too:
public aspect A perthis(@this(@MyAnnotation)) { ... }

(or if the syntax change per my email a few days back is accepted:
public aspect A perthis(@this(MyAnnotation)) { ... }
)

This will spare the nested and inner types defined within classes that carry @MyAnnotations.

Can you provide background of why you need per-instance association? In many cases, you are better of using inter-type declarations instead of perthis() and pertarget().

-Ramnivas

===

Ramnivas Laddad,
Author, AspectJ in Action
http://ramnivas.com


Rifflard Mickaël wrote:

Hi all,

I want to instanciate an aspect instance with each instance of an object with specific annotation.

Exemple :
	@MyAnnotation
	public class O { ... }

	public class Main {

		public static void main(String[] args) {
			new O();	=> New aspect instance
			new O();	=> New aspect instance
		}
	}

To express this, I write

	public aspect A perthis(within(@MyAnnotation *)) { ... }

This expression works but I wonder if this one is always the best with the addition of @this, @annotation , ...

What do you think about it ?

Regards,

Mickaël Rifflard
(Atos Origin)


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top