Any AspectJ code generation library (like Sun's codemodel for Java code generation)?
I开发者_JAVA百科s there any free library to generate AspectJ code at compile-time (at the annotation processing step for example)? I am looking for something similar to codemodel, but to generate AspectJ code.
It does not seem like such a library is available.
After doing more reading and analyzing codemodel's source code:
Generating pure AspectJ code with codemodel is not possible, since one cannot declare something like:
public aspect TransactionManager { ... }
It is not possible to twist the
JDeclaredClass
item properly to solve 1. You would have to rewrite almost everything from scratchAspectJ5 introduces annotations, meaning we can declare aspects in pure Java:
@Aspect public class TransactionManager { ... }
The only really tricky part of @AspectJ seems to be Inter-type Declarations, but a good/viable solution is provided here.
Conclusion: It does not seem like a specific library to generate AspectJ code is necessary, one can rely on codemodel only.
精彩评论