AOP:切面编程框架 : AspectJ (二)注解

AspectJ 切面编程第二栏,关于注解使用

1:@Around 环绕通知

@Around 环绕通知

1、around方法的返回值就是目标代理方法执行返回值

2、参数为ProceedingJoinPoint 可以调用拦截目标方法的执行

目标方法

 public void delete() {
        System.out.println("删除商品");
    }

切面:环绕通知

@Around(value="execution(* com.lucifer.aspectj.demo.ProductDao.delete(..))")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("环绕前通知======================");
        Object obj=joinPoint.proceed();//执行目标方法
        System.out.println("环绕后通知======================");
        return obj;
    }

切入之后看下日志打印

如果不调用ProceedingJoinPoint的proceed方法,目标方法就被拦截了

@Around(value="execution(* com.lucifer.aspectj.demo.ProductDao.delete(..))")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("环绕前通知======================");
        // Object obj=joinPoint.proceed();//执行目标方法
        System.out.println("环绕后通知======================");
        return obj;
    }

 2: @Before

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值