Spring AOP Limitation when advised method calls methods on target
My use case is to log every method call on an object.
After adding a method interceptor on the 开发者_开发百科target object, I call the method Foo
. This method Foo
calls a method Bar
. Only the method Foo
will be logged.
class MyClass {
public void Foo() {Bar();}
public void Bar() {}
}
Reading the Spring documentation, I have found a sentence that explained why I cannot implement what I want. From Spring documentation (page 146):
Please note that in both cases a target method implementation that calls other methods on the target object will not be advised.
Am I missing something here? Or is this really a Spring limitation?
A start of solution...
http://www.digizenstudio.com/blog/2007/05/29/the-self-calling-limitation-in-spring-aop-and-one-unintrusive-solution/
EDIT Finally, I decided to switch to Castle AOP. They propose a class proxy that feets my needs.
You could use AspectJ weaving that will not have any such limitations.
精彩评论