每当调用任何AfterThrowing Aspect时都重定向到站点

时间:2018-06-26 06:31:08

标签: aop

无论何时被调用或发生任何异常,我都被写成我想要的一个方面,我们将其重定向到http://google.com

@AfterThrowing(pointcut = "execution(* com.ts.templateService.*.*(..))", throwing = "e")
public void LocalAfterThrowing(JoinPoint joinPoint, Throwable e) {

    Signature signature = joinPoint.getSignature();
    String methodName = signature.getName();
    String stuff = signature.toString();
    String arguments = Arrays.toString(joinPoint.getArgs());
    System.out.println("Got Exception in the Method: "
            + methodName + " with arguments "
            + arguments + "\nand the full toString: " + stuff + "\nthe exception is: "
            + e.getMessage());
}

0 个答案:

没有答案