• Spring2:


    二. AOP原理与应用

      面向切面编程,是OOP的扩展和延伸,是用来解决OOP遇到问题。

    1.原理:动态代理

     

    动态代理原理:(代理类就是增强后的类)

    2.术语

    l  连接点:可以被拦截的点。

    l  切入点:真正被拦截的点。

    l  通知:增强方法

    l  引介:类的增强

    l  目标:被增强的对象

    l  织入:将增强应用到目标的过程。

    l  代理:织入增强后产生的对象

    l  切面:切入点和通知的组合

    3.开发过程

    l  引入jar包

    l  编写目标类并配置

    l  编写切面类并配置

    l  进行aop的配置

    <aop:config>
              <!--配置哪些方法需要增强-->       <aop:pointcut expression=”execution(表达式)” id=”pc1”/>
              <!--配置切面-->  
          <aop:aspect >         <aop:before method=”” pointcut-ref=”pc1”/>
          </aop:aspect> </aop:config>

    4.通知类型

    5.切入点表达式

     6.基于注解的AOP开发

    1.   导包:
      1.       
    2.   配置xml
    3.   配置目标类
    4.   配置切面类
    5.   AOP增强:

    l  在配置文件中打开注解的AOP开发

     

    l  在切面类上使用注解

    基于注解的通知类型

       

    1.1.1.1   @Before  :前置通知   

    1.1.1.2   @AfterReturning     :后置通知

     

    1.1.1.3   @Around      :环绕通知

     

    1.1.1.4   @AfterThrowing      :异常抛出通知

     

    1.1.1.5   @After          :最终通知

     

    切入点

     

  • 相关阅读:
    【纪中集训2019.3.19】原样输出
    【纪中集训2019.3.11】树上四次求和
    【纪中集训2019.3.11】Cubelia
    【纪中集训2019.3.14】小凯的疑惑
    leetcode 18 4Sum
    leetcode 17 Letter Combinations of a Phone Number
    leetcode 11 Container With Most Water
    leetcode 16 3Sum Closest
    leetcode 15 3Sum
    leetcode 14 Longest Common Prefix
  • 原文地址:https://www.cnblogs.com/lvoooop/p/10798188.html
Copyright © 2020-2023  润新知