美文网首页
AspectJ 使用简介

AspectJ 使用简介

作者: Sleepeanuty | 来源:发表于2017-11-28 09:58 被阅读0次

    什么是AspectJ

    听过AspectJ的想必也是为了了解AOP才来的,AOP是什么我们就不多说了,对AspectJ的介绍我大部分就从官网翻译过来,有兴趣的也可以自己去AspectJ官网了解。

    a general-purpose aspect-oriented extension to Java  官网对他的解释就是这么简单粗暴。

    AspectJ的设计动力

    AspectJ的设计动力是我们意识到了当前的编程方法论(个人觉得是说的oop)在对某些问题或隐忧上还不能有完善的处理办法。为了解决这些问题引入的安全策略很可能会破坏代码原有的天然性,而且对以后系统引入的新的部分可能还需要特别的适配;

    AspectJ的新概念

    原文:

    join pointis a well-defined point in the program flow. A point cut picks out certain join points and values at those points. A piece ofadviceis code that is executed when a join point is reached. These are the dynamic parts of AspectJ.

    join Point 是程序流里一个定义明确的点;

    Point cut 负责筛选出合适的join points以及他们的value;

    advice是程序运行到这些点是需要执行的代码;

    使用实例

    我们这里讲到的都是最基础的method call join points,在AspectJ中join points基本都是以String的形式出现的,我们看看下面的代码

    相关文章

      网友评论

          本文标题:AspectJ 使用简介

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