Spring AOP 术语说明
标签搜索
侧边栏壁纸
  • 累计撰写 6 篇文章
  • 累计收到 75 条评论

Spring AOP 术语说明

xiaodong
2020-07-16 / 24 评论 / 905 阅读 / 正在检测是否收录...

举个例子

一个aspect切面class

public class Logging {
    /**
    * This is the method which I would like to execute
    * before a selected method execution.
    */
    public void beforeAdvice() {
        System.out.println("Going to setup student profile.");
    }

    /**
    * This is the method which I would like to execute
    * after a selected method execution.
    */
    public void afterAdvice() {
        System.out.println("Student profile has been setup.");
    }

    /**
    * This is the method which I would like to execute
    * when any method returns.
    */
    public void afterReturningAdvice(Object retVal) {
        System.out.println("Returning:" + retVal.toString());
    }

    /**
    * This is the method which I would like to execute
    * if there is an exception raised.
    */
    public void AfterThrowingAdvice(IllegalArgumentException ex) {
        System.out.println("There has been an exception: " + ex.toString());
    }
}

SpringAOP.xml配置

<bean id="student" class="com.seeyon.SpringBean.aop.Student" p:name="yangyu" p:age="27"></bean>

<bean id="logging" class="com.seeyon.SpringBean.aop.Logging"></bean>

<aop:config>
    <!-- 切面class -->
    <aop:aspect id="log" ref="logging">
        <!-- 切点 -->
        <aop:pointcut id="studentMethod" expression="execution(* com.seeyon.SpringBean.aop.Student.get*(..))"/>
        <!-- 方法执行之前触发切面class的beforeAdvice方法 -->
        <aop:before pointcut-ref="studentMethod" method="beforeAdvice"/>
        <!-- 方法执行之后触发切面class的afterAdvice方法 -->
        <aop:after pointcut-ref="studentMethod" method="afterAdvice"/>
    </aop:aspect>
</aop:config>

术语说明

术语说明
Aspect(切面)泛指交叉业务逻辑,比如日志处理、事务处理的逻辑可以理解为切面,上面xml中aop:aspect标签表示的就是一个切面。
JoinPoint(连接点)连接点指切面可以织入的位置,是一个虚拟的概念,可以理解为所有满足切点扫描条件的所有的时机。
Pointcut(切入点)切面具体切入的位置,上面aop:pointcut标签表示的就是一个切点,也就是满足条件被扫描到的目标方法。
Advice(通知/增强)切面的一种实现,可以完成切面的功能的函数,例如日志记录,权限验证,事务控制,性能检测,错误信息检测等。
Weaving(织入)指将切面的逻辑插入到目标对象中的过程。

参考:https://www.jianshu.com/p/c57a5a998c6b

1

评论 (24)

取消
  1. 头像
    vmrtvwwyey
    Windows 10 · Google Chrome

    怎么收藏这篇文章?

    回复
  2. 头像
    mtdetnholx
    Windows 10 · Google Chrome

    看的我热血沸腾啊https://www.237fa.com/

    回复
  3. 头像
    tgdqwwaiaa
    Windows 10 · Google Chrome

    不错不错,我喜欢看 https://www.237fa.com/

    回复
  4. 头像
    asabwyyrzh
    Windows 10 · Google Chrome

    看的我热血沸腾啊https://www.ea55.com/

    回复
  5. 头像
    vekebiutmo
    Windows 10 · Google Chrome

    看的我热血沸腾啊www.jiwenlaw.com

    回复
  6. 头像
    vrlefllssh
    Windows 10 · Google Chrome

    兄弟写的非常好 https://www.cscnn.com/

    回复
  7. 头像
    djmlercnzy
    Windows 10 · Google Chrome

    你的文章让我学到了很多知识,非常感谢。 https://www.yonboz.com/video/12954.html

    回复
  8. 头像
    xfgggfrjvy
    Windows 10 · Google Chrome

    你的文章让我学到了很多知识,非常感谢。 https://www.yonboz.com/video/12954.html

    回复
  9. 头像
    lftgerqoom
    Windows 10 · Google Chrome

    你的文章让我感受到了不一样的风景,谢谢分享。 http://www.55baobei.com/pQYrKbVDeM.html

    回复
  10. 头像
    tahllxxiwy
    Windows 10 · Google Chrome

    你的文章让我感受到了艺术的魅力,谢谢! http://www.55baobei.com/lBNGfIcJGV.html

    回复
  11. 头像
    nqnsowdnxx
    Windows 10 · Google Chrome

    你的文章让我学到了很多知识,非常感谢。 https://www.yonboz.com/video/12954.html

    回复
  12. 头像
    idrrqqpboq
    Windows 10 · Google Chrome

    你的文章让我感受到了不一样的风景,谢谢分享。 http://www.55baobei.com/pQYrKbVDeM.html

    回复
  13. 头像
    fyzywitepo
    Windows 10 · Google Chrome

    你的文章让我感受到了艺术的魅力,谢谢! http://www.55baobei.com/lBNGfIcJGV.html

    回复
  14. 头像
    zmannzkkzy
    Windows 10 · Google Chrome

    你的才华横溢,让人敬佩。 http://www.55baobei.com/DokKUiWuHr.html

    回复
  15. 头像
    dlmmnfseqd
    Windows 10 · Google Chrome

    你的文章内容非常用心,让人感动。 https://www.4006400989.com/qyvideo/63969.html

    回复
  16. 头像
    vpqhutsqpb
    Windows 10 · Google Chrome

    你的文章让我学到了很多技能,非常实用。 https://www.4006400989.com/qyvideo/13473.html

    回复
  17. 头像
    axanmyjivu
    Windows 10 · Google Chrome

    你的文章充满了欢乐,让人忍不住一笑。 http://www.55baobei.com/ert0vKBFFT.html

    回复
  18. 头像
    buhggfrrjz
    Windows 10 · Google Chrome

    你的文章让我学到了很多技能,非常实用。 http://www.55baobei.com/2cfkDySqyS.html

    回复
  19. 头像
    jwyxlkvhxi
    Windows 10 · Google Chrome

    你的文章让我感受到了快乐,每天都要来看一看。 https://www.4006400989.com/qyvideo/13819.html

    回复
  20. 头像
    cibgjrqqpb
    Windows 10 · Google Chrome

    你的文章让我感受到了快乐,每天都要来看一看。 https://www.4006400989.com/qyvideo/13819.html

    回复
  21. 头像
    zgmcbfdlor
    Windows 10 · Google Chrome

    选材新颖独特,通过细节描写赋予主题鲜活生命力。

    回复
  22. 头像
    nxeiqxjgus
    Windows 10 · Google Chrome

    新车新盘 嘎嘎稳 嘎嘎靠谱coinsrore.com

    回复
  23. 头像
    igmlxfdhzl
    Windows 10 · Google Chrome

    2025年10月新盘 做第一批吃螃蟹的人coinsrore.com
    新车新盘 嘎嘎稳 嘎嘎靠谱coinsrore.com
    新车首发,新的一年,只带想赚米的人coinsrore.com
    新盘 上车集合 留下 我要发发 立马进裙coinsrore.com
    做了几十年的项目 我总结了最好的一个盘(纯干货)coinsrore.com
    新车上路,只带前10个人coinsrore.com
    新盘首开 新盘首开 征召客户!!!coinsrore.com
    新项目准备上线,寻找志同道合 的合作伙伴coinsrore.com
    新车即将上线 真正的项目,期待你的参与coinsrore.com
    新盘新项目,不再等待,现在就是最佳上车机会!coinsrore.com
    新盘新盘 这个月刚上新盘 新车第一个吃螃蟹!coinsrore.com

    回复
  24. 头像

    华纳圣淘沙公司开户新手教程

    零基础学会(183-8890-9465薇-STS5099)
    华纳圣淘沙公司开户

    华纳圣淘沙公司开户保姆级教程(183-8890-9465薇-STS5099)

    一步步教你开通华纳圣淘沙公司账户(183-8890-9465薇-STS5099)

    华纳圣淘沙公司开户分步图解

    首次开户必看:(183-8890-9465薇-STS5099)
    华纳圣淘沙全攻略

    华纳圣淘沙公司开户实操手册(183-8890-9465薇-STS5099)
    华纳圣淘沙开户流程视频教程

    手把手教学:(183-8890-9465薇-STS5099)
    华纳圣淘沙公司开户

    华纳圣淘沙公司开户完全指南(183-8890-9465薇-STS5099)

    回复