如何从周围建议获取呼叫者方法信息 [英] How to get the caller method information from Around advise
本文介绍了如何从周围建议获取呼叫者方法信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ThisJoinPoint只能获取当前方法信息,还是要获取调用者方法信息?
ThisJoinPoint can only get the current method information, anyway to get the caller method information?
推荐答案
您可以尝试使用特殊变量thisEnclosingJoinPointStaticPart
来保存封闭的JoinPoint的静态部分.
You can try the special variable thisEnclosingJoinPointStaticPart
which holds the static part of the enclosing JoinPoint.
Mentioned here (example) and here (docs)
或者如果使用基于注释的AspectJ,则将以下内容传递给建议方法的参数,例如:
Or if using annotation-based AspectJ, pass following to the advice method's parameters, e.g.:
@Before("call( /* your pointcut definition */ )")
public void myCall(JoinPoint.EnclosingStaticPart thisEnclosingJoinPointStaticPart)
{
// ...
}
提及此处
这篇关于如何从周围建议获取呼叫者方法信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文