任何 AspectJ 代码生成库(例如 Sun 的用于 Java 代码生成的代码模型)?
是否有任何免费库可以在编译时生成 AspectJ 代码(例如在注释处理步骤中)?我正在寻找类似于 codemodel,而是生成AspectJ代码。
Is 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎没有这样的库可用。
经过更多阅读和分析 codemodel 的源代码后:
使用 codemodel 生成纯 AspectJ 代码是不可能的,因为无法声明如下内容:
公共方面 TransactionManager { ... }
不可能扭曲
JDeclaredClass
项正确地解决 1。您必须从头开始重写几乎所有内容AspectJ5 引入了注解,这意味着我们可以在纯 Java 中声明切面:
@方面
public class TransactionManager { ... }
@AspectJ 唯一真正棘手的部分似乎是类型间声明,但提供了一个好的/可行的解决方案 此处。
结论:似乎不需要特定的库来生成AspectJ代码,只需依赖codemodel即可。
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.