Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How to do foreach(Class x where ...) in aspectJ ?

Hi all,

Does AspectJ support a way to perform a common
operation repeately on all classes that exists with
some specific property like a specific annotation
(i.e. foreach(Class x where ...))?

For example, instead of doing the manual code below I
would like to call the "alias" method automatically
for each class that exist having a specific "alias"
annotation.

Example that I would like to rewrite with "foreach":
xstream.alias(ClzA.class.getSimpleName(),ClzA.class);
xstream.alias(ClzB.class.getSimpleName(),ClzB.class); 
     
xstream.alias(ClzC.class.getSimpleName(),ClzC.class);
...
...
...
...


I am aware of the pertypewithin Instantiation Model in
1.5, but have difficulty in understanding if it can be
used to solve this problem+ Also, plain reflection
does  not easily solve this problem as one AFAIK can't
iterate over all classes in a set of com.xxx.*
packages.

Any ideas ?

Thanks in advance ?

Sincerely,
Morten Christensen,
Demmark





Back to the top