任何 AspectJ 代码生成库(例如 Sun 的用于 Java 代码生成的代码模型)?

发布于 2024-12-03 01:10:26 字数 191 浏览 0 评论 0原文

是否有任何免费库可以在编译时生成 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

£噩梦荏苒 2024-12-10 01:10:26

似乎没有这样的库可用。

经过更多阅读和分析 codemodel 的源代码后:

  1. 使用 codemodel 生成纯 AspectJ 代码是不可能的,因为无法声明如下内容:

    公共方面 TransactionManager { ... }

  2. 不可能扭曲JDeclaredClass 项正确地解决 1。您必须从头开始重写几乎所有内容

  3. AspectJ5 引入了注解,这意味着我们可以在纯 Java 中声明切面:

    @方面
    public class TransactionManager { ... }

  4. @AspectJ 唯一真正棘手的部分似乎是类型间声明,但提供了一个好的/可行的解决方案 此处

结论:似乎不需要特定的库来生成AspectJ代码,只需依赖codemodel即可。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文