开发者

Any AspectJ code generation library (like Sun's codemodel for Java code generation)?

开发者 https://www.devze.com 2023-04-02 12:00 出处:网络
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 Aspe

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:

  1. Generating pure AspectJ code with codemodel is not possible, since one cannot declare something like:

    public aspect TransactionManager { ... }

  2. It is not possible to twist the JDeclaredClass item properly to solve 1. You would have to rewrite almost everything from scratch

  3. AspectJ5 introduces annotations, meaning we can declare aspects in pure Java:

    @Aspect public class TransactionManager { ... }

  4. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消