我的应用程序中有一个方面拦截系统上的每个建议执行。我希望能够通过我的建议执行切入点识别哪些建议被“拦截”,如此
// ... AdviceInspector.aj中的一些代码
before(): adviceexecution() && !within(AdviceInspector) {
System.out.println("advice execution being intercepted");
// TODO : get a way to know which advice execution has been intercepted
}
// ...进一步的代码
提前致谢
答案 0 :(得分:0)
您可以从joinPoint获取建议的签名。签名有各种方法来描述它。如果只是用于调试,toString()方法很好地描述了
before(): adviceexecution() && !within(AdviceInspector) {
org.aspectj.lang.Signature sig = thisJoinPoint.getStaticPart().getSignature();
//It is also valid to do
//Signature sig = thisJoinPointStaticPart.getSignature();
System.out.println(sig);
}