我使用Spring配置AspectJ,并且在"捕获"从类外调用的公共方法时它工作正常.现在我想做这样的事情:
public class SomeLogic(){
public boolean someMethod(boolean test){
if(test){
return innerA();
} else {
return innerB();
}
}
private boolean innerA() {// some logic}
private boolean innerA() {// some other logic}
}
Run Code Online (Sandbox Code Playgroud)
SomeLogic是一个SpringBean.方法innerA()和innerB()可以声明为private或public - 从Struts动作调用someMethod()方法.是否有可能从AspectJ中捕获从someMethod()调用的方法innerA()或innerB()?
我的配置(基于XML):
<aop:aspect id="innerAAspect" ref="INNER_A">
<aop:pointcut id="innerAService" expression="execution(* some.package.SomeLogic.innerA(..))"/>
</aop:aspect>
<aop:aspect id="innerAAround" ref="INNER_A">
<aop:around pointcut-ref="innerAService" method="proceed"/>
</aop:aspect>
<aop:aspect id="innerBAspect" ref="INNER_B">
<aop:pointcut id="innerBService" expression="execution(* some.package.SomeLogic.innerB(..))"/>
</aop:aspect>
<aop:aspect id="innerBAround" ref="INNER_B">
<aop:around pointcut-ref="innerBService" method="proceed"/>
</aop:aspect>
Run Code Online (Sandbox Code Playgroud)