代码示例
@Aspect
@Component
public class PayAspect {
@Before("execution(public void com.flyaction.demo.aopreview.PayServiceImpl.pay(..))")
public void beforeNotify() { System.out.println("-----@Before前置通知"); }
@After("execution(public void com.flyaction.demo.aopreview.PayServiceImpl.pay(..))")
public void afterNotify() { System.out.println("-----@After后置通知"); }
@AfterReturning("execution(public void com.flyaction.demo.aopreview.PayServiceImpl.pay(..))")
public void afterReturningNotify() { System.out.println("-----@AfterReturning返回通知"); }
@AfterThrowing("execution(public void com.flyaction.demo.aopreview.PayServiceImpl.pay(..))")
public void afterThrowingNotify() { System.out.println("-----@AfterThrowing异常通知"); }
@Around("execution(public void com.flyaction.demo.aopreview.PayServiceImpl.pay(..))")
public Object aroundNotify(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
Object retValue = null;
System.out.println("-----@Around环绕通知AAA");
retValue = proceedingJoinPoint.proceed();//放行
System.out.println("-----@Around环绕通知BBB"); return retValue;
}
}
无异常情况下


异常情况下


action
本站未注明转载的文章均为原创,并采用
CC BY-NC-SA 4.0授权协议,
转载请注明来源,谢谢!如本站内容对你有所帮助的话,欢迎订阅关注
邢栋博客,唠嗑(分享)每日的折腾经历。
已有 0 条评论