gpt4 book ai didi

tomcat - 部署到单个 JVM 的所有应用程序的 AspectJ LTW

转载 作者:行者123 更新时间:2023-11-28 21:48:18 26 4
gpt4 key购买 nike

我已将我的 aspectJ 方面捆绑到一个 War (aspectsWar.war) 文件中,并将其部署到具有现有正在运行的应用程序的应用程序服务器,并在 tomcat 服务器上使用 LTW 编织和 javaagent。

我可以在 aspectsWar.war 上看到方面拦截调用,但在同一 jvm 上运行的其他应用程序上看不到。

有没有办法让我的 aspectj 方面识别和编织所有其他正在运行的应用程序(最好不必修改单个 war 文件),可能是通过对应用程序服务器的一些自定义类加载更改...

注意:这是在没有任何 Spring 相关集成的情况下单独使用 aspectJ。

请指教。

最佳答案

将加载时间织入限制到特定的类加载器是spring提供的一个特性。作为documentation描述:

The value-add that the Spring Framework brings to AspectJ LTW is in enabling much finer-grained control over the weaving process. 'Vanilla' AspectJ LTW is effected using a Java (5+) agent, which is switched on by specifying a VM argument when starting up a JVM. It is thus a JVM-wide setting, which may be fine in some situations, but often is a little too coarse. Spring-enabled LTW enables you to switch on LTW on a per-ClassLoader basis, which obviously is more fine-grained and which can make more sense in a 'single-JVM-multiple-application' environment (such as is found in a typical application server environment).

很抱歉引文很长,但这基本上是您问题的答案。使用 agent provided by AspectJ而不是 Spring load time weaving configuration如果您想在 JVM 范围内应用这些方面。

关于tomcat - 部署到单个 JVM 的所有应用程序的 AspectJ LTW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16594007/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com