从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,除非你可以为每次调用编写两条环绕通知,你可以设置一个 Boolean>ThreadLocal
在第一个和 proceed
中,并在第二个中检查它,如果它设置了则不 proceed
ing.相当丑陋的黑客.
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屋!