Spring框架

作者: 洙水河边 | 来源:发表于2018-06-11 17:19 被阅读0次

    一、AOP

    Spring官方文档AOP部分:
    https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#aop-api

    1、AOP维度

    AOP是方法级的(只能控制方法前后,而不能控制方法内部执行),用到的几个概念:
    ① 切面aspect:自定义的收到通知后(满足advice)执行的操作
    ② 通知advice:定义时间点进行通知;包括(@Before,@Around,@After,@AfterReturning,@AfterThrowing)
    ③ 切点point:具体拦截的某个点

    2、同一aspect下advice执行顺序

    在一个aspect下的advice执行顺序是有要求的。
    正常情况

    即@Before>@Around(环绕在方法process前后)>@After>@AfterReturning

    异常情况

    即@Before>@Around(环绕在方法process前后)>@After>@AfterThrowing

    3、不同aspect执行顺序

    aspect可以添加@Order,值越小的越早执行

    相关文章

      网友评论

        本文标题:Spring框架

        本文链接:https://www.haomeiwen.com/subject/jcqqeftx.html