问题
I'm trying to exclude a specific method call inside another method from being intercepted:
public Class A {
public void foo1() {...}
public void foo2() {
foo1();
}
}
I only want to exclude the foo1 calls made from foo2, and not the other calls: someAObject.foo1() & someAobject.foo2() should be included.
Does anyone know how to do this using spring aop? Thanks!
回答1:
This should work:
execution(* A.*(..)) && !execution(* A.foo2(..))
回答2:
I would recommend you stop using spring, barring that, if you can write two pieces of around advice for each call, you can set a ThreadLocal<Boolean>
in the first and proceed
, and check it in the second, not proceed
ing if its set. pretty ugly hack.
来源:https://stackoverflow.com/questions/22633187/exclude-a-specific-method-call-inside-another-method-from-aspectj