对于Spring JoinPoint Pointcut Advice Advisor定义的理解

对于一个开发人员学习一个框架没有必要去抠其中的概念的命名定义,但是对于其中一些主要的核心概念理解的比较好的话对开发是绝对有好处的,在Spring的AOP编程中,最基本的几个概念就是Pointcut Joinpoint Advice Advisor ,我在一些视频和书籍都见过了相关的定义讲解,但是都觉得讲得不太清楚,既冗长又晦涩,所以结合多个方面的资料写一下自己的理解,希望能给有这方面困扰的朋友一些启示,同时也为自己坐下笔记。

在Spring官网关于AOP的视频教程中,是这样定义的:

     ·Join point

             -A point in the execution of a program such as a method call or field assigment

     ·Pointcut

            -An expresion that selects one or more in Join point

     ·Adivce

            -Code to be executed at a Join Point that has been selected by a Pointcut

     ·Aspect

           -A module that encapsulates pointcut and Adivce

我的理解大概是这个意思:

      Join point:一个要被拦截的方法(在spring里面我们主要做的就是拦截方法,所以对于属性的AOP就先不理会了)

      Pointcut:在execution表达式里面声明的一个或多个方法被拦截方法的集合

  

      advice    :应用在被拦截方法中的代码或者说函数,如,切面类中被@before(....)等注释了的成员函数

     

      advisor:负责声明“建议”在什么时候被执行,比如说,在被拦截方法执行前@before(...) ,@afterReturnning(...)等

      Aspect   :一个封装了切入面和切入点的模块

下面是一个例子:

      @Aspect

     public class PropertyChangerTracker{

             @before("execution(* com.demo.Target.set*(..))")

             public void changeTracker(){

                     System.out.println("The Target Object's Property changes.......");

              }

    }

    Join Point :如,void com.demo.Target.setName();

    Pointcut:  * com.demo.Target.set*(..)

   

    advice:public void changeTracker(){........}

    advisor: @before("execution(* com.demo.Target.set*(..))")

以上纯属个人理解,若有理解差错,望各位指正!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值