假设有一个来自
SimplePojo
public class SimplePojo implements Pojo { public void foo() { this.bar(); } public void bar() { ... }}当我们调用方法时
foo(),它会重新调用其中的方法
bar()。即使
foo()从
AOP代理调用了该方法,AOP代理bar()也不会涵盖的内部调用。
因此,如果没有任何建议附加到该方法
bar()上,则最终将导致不被调用
解
使用
AopContext.currentProxy()要调用的方法。不幸的是,这将逻辑与AOP耦合在一起。
public void foo() { ((Pojo) AopContext.currentProxy()).bar();}


