AspectJ pointcuts - get a reference to the joinpoint class and name

前端 未结 2 1588
梦谈多话
梦谈多话 2021-02-05 06:03

I am using the @AspectJ style for writing aspects, to handle logging in our application. Basically I have a pointcut set up like so:

@Pointcut(\"call(public * c         


        
2条回答
  •  逝去的感伤
    2021-02-05 06:07

        public void logBefore(JoinPoint joinPoint) {
        logger.info("###### Requested class : {} ; Method : {} ", joinPoint.getTarget().getClass().getName(), joinPoint.getSignature().getName());
        Object[] signatureArgs = joinPoint.getArgs();
        for (Object signatureArg : signatureArgs) {
            logger.info("###### Arguments: {} ", signatureArg.toString());
        }
    } 
    

    may help someone: Use above code to get the requested Class, method and args.

提交回复
热议问题