How to get the caller method information from Arou

2020-03-31 04:49发布

ThisJoinPoint can only get the current method information, anyway to get the caller method information?

标签: aspectj
2条回答
地球回转人心会变
2楼-- · 2020-03-31 05:20
@Aspect
public class LoggingAspect {

    @Before(value = "execution(public * findAll())")
    public void beforeAdvice(JoinPoint pp){
        System.out.println("before advice called ....get calling method Signature"+pp.getSignature());
        System.out.println("before advice called ....get calling method name"+pp.getSignature().getName());
    }

}
查看更多
等我变得足够好
3楼-- · 2020-03-31 05:33

You can try the special variable thisEnclosingJoinPointStaticPart which holds the static part of the enclosing JoinPoint.

Mentioned here (example) and here (docs)

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)
{
     // ...
}

Mentioned here

查看更多
登录 后发表回答