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)