haixiang

&nbsp:

1. AOP 关键词

  1. target:目标类,需要被代理的类。例如:ArithmeticCalculator

  2.Joinpoint(连接点):所谓连接点是指那些可能被拦截到的方法。例如:所有的方法

  3. PointCut 切入点:已经被增强的连接点。例如:add()

  4. advice 通知/增强,增强代码。例如:showRaram、showResult

   5. Weaving(织入):是指把增强advice应用到目标对象target来创建新的代理对象proxy的过程.

  6. proxy 代理类:通知+切入点

   7. Aspect(切面): 是切入点 pointcut 和通知advice的结合

&nbsp:

6. AOP 的通知类型

 Spring按照通知Advice在目标类方法的连接点位置,可以分为5类

  • 前置通知 org.springframework.aop.MethodBeforeAdvice
    • 在目标方法执行前实施增强,比如上面例子的 before()方法
  • 后置通知 org.springframework.aop.AfterReturningAdvice
    • 在目标方法执行后实施增强,比如上面例子的 after()方法
  • 环绕通知 org.aopalliance.intercept.MethodInterceptor
    • 在目标方法执行前后实施增强
  • 异常抛出通知 org.springframework.aop.ThrowsAdvice
    • 在方法抛出异常后实施增强
  • 引介通知 org.springframework.aop.IntroductionInterceptor
    • 在目标类中添加一些新的方法和属性

相关文章:

  • 2021-04-29
  • 2018-05-06
  • 2020-09-24
  • 2021-05-06
  • 2021-04-24
  • 2019-10-29
  • 2021-09-20
  • 2021-11-17
猜你喜欢
  • 2019-01-03
  • 2021-08-06
  • 2021-12-03
  • 2020-07-23
  • 2019-10-28
  • 2021-07-04
  • 2021-07-30
相关资源
相似解决方案