I have bundled my aspectJ aspects into a single War (aspectsWar.war) file and deployed it to an application server with existing running applications and used LTW weaving with a javaagent on tomcat server.
I can see the aspect intercepting calls on the aspectsWar.war but not on the other applications running on the same jvm.
Is there a way to have my aspectj aspect to recognize and weave all the other running applications (preferably without having to modify the individual war files), probably through some custom classloading changes to app server...
Note: this is using aspectJ by itself without any Spring related integration.
Please advice.
The restriction of load time weaving to specific class loaders is a feature provided by spring. As the documentation describes:
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).
Sorry for the long quote, but it's basically the answer for your question. Use the agent provided by AspectJ instead of the Spring load time weaving configuration in case you want to apply the aspects JVM wide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With