How exactly does an @Around advice work in Spring AOP?

依然范特西╮ 提交于 2019-12-04 04:30:28

Actually all those AOP annotations are exposed as concrete implementation of AbstractAspectJAdvice. And even if it is @AfterThrowing, its AspectJAfterThrowingAdvice is there and invoked anyway:

try {
    return mi.proceed();
}
catch (Throwable t) {
    if (shouldInvokeOnThrowing(t)) {
        invokeAdviceMethod(getJoinPointMatch(), null, t);
    }
    throw t;
}

The @Around really has more power and provides more control for end-user to get deal with ProceedingJoinPoint.

It's up to to study all those advice type, but with @Around you can reach all of them, although you shouldn't forget to call mi.proceed() from there. If need to do that by your logic, of course.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!