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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[quote Rifflard Mickaël::on 2/4/2005 7:40 PM]
| 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)
|

As you said it by yourself you want an instance of aspect for each object instance, so you should
probably have something like:

pointcut pc(): your pointcut here

and a per clause as perthis(pc()).

- --
:alex |.::the_mindstorm::.|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCA7eSTTDTje0R2dgRApfTAJ0bk6+N1Kqu1AAMDWw9WSER4ylAdACghXh/
GoEhmCp+BGfo/4bdVOmBe7k=
=XDBJ
-----END PGP SIGNATURE-----


Back to the top