I have a Java class which is something like the following:
public class Foo{
public void doSomething(){
StageA a = new StageA();
StageB b = new StageB();
StageC c = new StageC();
a.execute();
b.execute();
c.execute();
}
}
Now, assuming I can't really edit this class itself, could I still use spring AOP to apply logging around the execute methods? (presumably without using aspect4j)
Well you can log method and it's required time(for performance) but I don't think you would be able to log what method is doing.
From Spring Docs :
Around advice: Advice that surrounds a join point such as a method invocation. This is the most powerful kind of advice. Around advice can perform custom behavior before and after the method invocation. It is also responsible for choosing whether to proceed to the join point or to shortcut the advised method execution by returning its own return value or throwing an exception.
If you are using log4j loggers internally in your methods you can log what method is doing by configuring log4j.
(presumably without using aspect4j)
--> Spring internally uses aspectJ
Check here for reference and example
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