从Aspectj中排除特定的方法调用(在另一个方法内部) [英] Exclude a specific method call (inside another method) from aspectj
问题描述
我正试图从另一个方法中排除特定的方法调用:
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();
}
}
我只想排除由foo2进行的foo1调用,而不要排除其他调用:someAObject.foo1()&应该包含someAobject.foo2().
I only want to exclude the foo1 calls made from foo2, and not the other calls: someAObject.foo1() & someAobject.foo2() should be included.
有人知道如何使用spring aop来做到这一点吗? 谢谢!
Does anyone know how to do this using spring aop? Thanks!
推荐答案
我建议您停止使用spring,除非您可以为每个调用编写两条环绕建议,否则可以在首先是proceed
,然后在第二个中进行检查,而不检查proceed
是否已设置.非常难看的骇客.
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.
这篇关于从Aspectj中排除特定的方法调用(在另一个方法内部)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!