Exclude a specific method call (inside another met

2019-08-30 08:07发布

问题:

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 proceeding if its set. pretty ugly hack.