Exclude a specific method call (inside another method) from aspectj

谁说我不能喝 提交于 2019-12-11 18:55:24

问题


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.



来源:https://stackoverflow.com/questions/22633187/exclude-a-specific-method-call-inside-another-method-from-aspectj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!