简体   繁体   English

AspectJ:注入方面以作为第三方库进行项目

[英]AspectJ: Injecting aspects to project as a third party library

There are 2 projects: 有2个项目:

  • Test project A (contain a simple class with the main method with the output of the message " It's A project" ); 测试项目A (使用main方法包含一个简单的类,并输出消息“ It's A project” );
  • Project B contain aspects (*.aj) for processing the message output to the console (eq displaying the " It's aspect from B project " message before every message output to the console in project A ), + additional classes. 项目B包含方面(* .aj),用于处理向控制台输出的消息(在项目A中向控制台输出的每条消息之前,均显示“ 来自B项目的方面 ”消息),以及其他类。

Projects A and B are based on the Spring Framework . 项目AB基于Spring框架 Project B contains aspects that used the percflow model, which is currently not supported by Spring. 项目B包含使用percflow模型的方面,Spring 目前不支持该模型。

Can I compile aspects using the AspectJ compiler without using the project A (hence without compile-time / post-compile weaving) and then, on the basis of project B build a jar file that I can add to A project dependencies for further usage? 是否可以在不使用项目A的情况下使用AspectJ编译器来编译方面(因此无需进行compile-time / post-compile编织),然后在项目B的基础上构建一个jar文件,可以将其添加到A项目依赖项中以供进一步使用?

That is at a stage of assembly of the jar-file the project B knows nothing of the project A . 那就是在jar文件的汇编阶段,项目B对项目A一无所知。

It will probably be necessary to use load-time weaving. 可能有必要使用load-time编织。 How exactly should Spring be configured to automatically pick up aspects from the B project's jar file when it is added to project A ? 当将Spring项目添加到项目A中时,如何正确配置Spring自动从B项目的jar文件中拾取方面?

Thank you. 谢谢。

What you want is possible: 您想要的是可能的:

Sorry for not answering in more detail, but your question is also quite theoretical, you neither show any code or build information nor do you share a link to a sample project on GitHub. 抱歉,我没有回答更多细节,但是您的问题也是理论上的,您既不显示任何代码也不构建信息,也不共享GitHub上示例项目的链接。 Creating an MCVE would help the community to write better answers. 创建MCVE将有助于社区写出更好的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM