Advice Types in Spring

来源:互联网 发布:免费注册淘宝账号 编辑:程序博客网 时间:2024/06/07 05:00
----------------------------------------org.springframework.aop.MethodBeforeAdvice----------------------------------------org.springframework.aop.AfterReturningAdvice----------------------------------------org.aopalliance.intercept.MethodInterceptorAround advice functions like a combination of before and after advice, with one big difference—you canmodify the return value. Not only that, you can also prevent the method from actually executing.----------------------------------------org.springframework.aop.ThrowsAdvicepublic void afterThrowing(Exception ex) throws Throwable public void afterThrowing(Method method, Object[] args, Object target, IllegalArgumentException ex)Throws advice is similar to after returning advice in that it executes after the joinpoint, which is alwaysa method invocation, but throws advice only executes if the method threw an exception.org.springframework.aop.IntroductionInterceptor.ThrowsAdvice does not define any methods;instead, it is simply a marker interface used by Spring. The reason for this is that Spring allows typedthrows advice, which allows you to define exactly which Exception types your throws advice shouldcatch. Spring achieves this by detecting methods with certain signatures using reflection. Springlooks for two distinct method signatures.
原创粉丝点击