AspectJ初学者问题

发布于 2024-08-22 22:37:49 字数 117 浏览 3 评论 0原文

我开始学习AspectJ。通过阅读教程,我知道我可以将各个方面编织到已编译的类文件中。但是,我只是无法弄清楚允许我将已编译的类文件与另一个文件上写入的方面合并的命令。还有一件事,是否必须将方面写入 *.aj 文件中?谢谢

I am starting to learn AspectJ. From reading tutorials, I know that I can weave aspects into already compiled class files. However, I just cannot figure out the command that allows me to merge a compiled class file with aspects written on an another file. And one more thing, is it mandatory to have the aspects written in a *.aj file? Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

丶情人眼里出诗心の 2024-08-29 22:37:49

您必须将已编译的类添加到您的 inpath 中。命令行参数大多与 javac 类似,但有一些补充。例如-

ajc -inpath library.jar -sourceroots path/to/sources -classpath $CLASSPATH

inpath 标志可以采用 jar 文件、目录或其中之一的路径分隔列表。另请注意,inpath 上的类会重新编织,并且会在输出目录中生成新的类文件。

更多信息请参见:http://www.eclipse.org/方面j/doc/released/devguide/ajc-ref.html

至于你的第二个问题,是的。方面可以位于 .aj 文件或 .java 文件中。但是,建议使用 .aj,因为编辑器中的 AJDT 可以识别这些文件。当然,如果您使用@Aspect样式语法,即使在eclipse中也可以安全地使用.java。

You must add the compiled classes to your inpath. The command line arguments are mostly similar to javac, with some additions. Eg-

ajc -inpath library.jar -sourceroots path/to/sources -classpath $CLASSPATH

The inpath flag can take a jar file, a directory, or a path separated list of either. Also, note that the classes on the inpath are re-woven and new class files are produced in the output directory.

More information here: http://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html

As for your second question, yes. Aspects can be in either .aj files or .java files. However, .aj is recommended since these files are recognized by AJDT in the editor. Of course, if you use @Aspect style syntax, you can safely use .java even in eclipse.

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