@After的AOP切入点

时间:2017-03-29 02:46:11

标签: java casting return-value spring-aop pointcut

我希望AOP记录方法的返回值

    @After("execution(* com.dbs.tup.sample.service.*.*(..))")
    public void logAfter(JoinPoint point) {
        log.info("{} is returning {}", point.getSignature().getName(), "???");
    }

1 个答案:

答案 0 :(得分:1)

我发现了这个

    @AfterReturning(pointcut = "execution(* com.dbs.tup.sample.service.*.*(..))", returning = "retValue")
    public void logAfter(JoinPoint point, Object retValue) {
        log.info("{} is returning {}", point.getSignature().getName(), (((MethodSignature) point.getSignature()).getReturnType().cast(retValue)).toString());
    }