22.springAOP切点表达式的抽取以及总结

public class Target implements TargetInterface
{
    @Override
    public void save()
    {
        System.out.println("save running...");
        throw new ClassCastException();
    }

    public void save2()
    {
        System.out.println("save2 running...");
    }
}

    切面:

public class MyAspect
{

    public void afterThrowing()
    {
        System.out.println("异常抛出");
    }

    public void after()
    {
        System.out.println("最终通知");
    }
}

    <!--配置织入:告诉spring 哪些方法(切入点)需要进行哪些增强(前置增强,后置增强...)-->
    <aop:config><!--配置aop-->
        <!--配置切面(切入点+通知)-->
        <aop:aspect id="myAspect" ref="myAspect"><!--声明切面-->
            <aop:pointcut id="save" expression="execution(* aop.*.save(..))"/><!--抽取切点表达式-->
            <aop:after-throwing method="afterThrowing" pointcut-ref="save"></aop:after-throwing>
            <aop:after method="after" pointcut-ref="save"></aop:after>
        </aop:aspect>
    </aop:config>

总结

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值