- Before advice – Run before the method execution
- After returning advice – Run after the method returns a result
- After throwing advice – Run after the method throws an exception
- Around advice – Run around the method execution, combine all three advices above.
1. Before advice
implements MethodBeforeAdvice
public void before(Method method, Object[] args, Object target)
id=""
class="org.springframework.aop.framework.ProxyFactoryBean">
name="target" ref="customerService" />
name="interceptorNames">
>
>interceptor name
>
>
>
>
2. After returning advice
implements AfterReturningAdvice
public void afterReturning(Object returnValue, Method method,
Object[] args, Object target) throws Throwable {
3. After throwing advice
public class HijackThrowException implements ThrowsAdvice
public void afterThrowing(IllegalArgumentException e) throws Throwable
4. Around advice
public class HijackAroundMethod implements MethodInterceptor
Object result = methodInvocation.proceed();
No comments:
Post a Comment