关于Spring-AOP切入点和继承的说明 [英] Clarification around Spring-AOP pointcuts and inheritance
本文介绍了关于Spring-AOP切入点和继承的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出my.package
...
public class Foo {
public void logicNotInBar() {/*code*/}
public void logicBarOverrides() {/*code*/}
}
public class Bar extends Foo {
public void logicBarOverrides() {/*code*/}
}
以及以下Spring-AOP切入点...
and the following Spring-AOP pointcuts...
<aop:pointcut id="myPointcutAll" expression="execution(* my.package.*.*(..))" />
<aop:pointcut id="myPointcutFoo" expression="execution(* my.package.Foo.*(..))" />
<aop:pointcut id="myPointcutBar" expression="execution(* my.package.Bar.*(..))" />
对Bar实例的上述切入点应用建议的结果是什么?特别是...
What is the result of advice applied to the above pointcuts on instances of Bar? In particular...
Bar bar = new Bar();
bar.logicNotInBar(); // will myPointcutBar advice trigger?
bar.logicBarOverrides(); // is myPointcutFoo ignored here?
我认为我缺少切入点如何与继承交互的一些基本事实,因此幕后的解释/文档可能会走很长一段路.
I think I am missing some basic truth of how pointcuts interact with inheritance so an under-the-hood explanation/doc would probably go a long way.
推荐答案
查看全文