I want to create a pointcut to target a call to a method from specific methods.take the following:class Parent { public foo() { //do something }}class Child extends Parent { public bar1() { foo(); } public bar2() { foo(); } public bar3() { foo(); }}I would like to have a point cut on the call to foo() in methods bar1() and bar3()I was thinking something likepointcut fooOperation(): call(public void Parent.foo() && (execution(* Child.bar1()) || execution(* Child.bar3()) );before() : fooOperation() { //do something else}however, that doesnt seem to work. any ideas?thanks 解决方案 Maybe withincode will work:call(public void Parent.foo()) && (withincode(* Child.bar1()) || withincode(* Child.bar3()) );Alternatively you could try the cflow pointcut:pointcut bar1(): call(* Child.bar1());pointcut bar3(): call(* Child.bar3());call(public void Parent.foo()) && (cflow(bar1()) || cflow(bar3());Look here for a pointcut reference 这篇关于AspectJ指向特定方法中的方法调用的切入点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-16 23:53