AspectJ: intercept method from external jar

I am using x.jar and adding it to my AspectJ project (in eclipse) I have written a pointcut and suggestion for the method mymethod () in x.jar

However, AspectJ will not intercept this method call

How can I tell AspectJ to intercept method calls from external jars? Is it impossible?

thank you

Solution

There are two options:

a) Incorporate aspects into jars b) use load time weaving (I'll go there)

These are both advanced topics. I suggest you read AspectJ in action (2nd ed) by ramnivas laddad to learn more

To clarify: there are different types of entry points If your code calls the library's methods, you can of course intercept these calls, just like in the code So call () pointcuts work, but execute () (and many others) pointcuts won't change the execution method because of them, not in your code base Therefore, you must change the bytecode of the library (option a) or change how it is loaded into the application (option B)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>