Spring AOP

现更新地址:http://www.yiyehu.tech/archives/2019/05/23/spring-aop

首先由两个概念,AOP(Aspect Oriented Programming)面向切面编程,OOP (Object Oriented Programming)面向对象编程。

OOP引入封装、继承、多态等概念来建立一种对象层次结构,用于模拟公共行为的一个集合。不过OOP允许开发者定义纵向的关系,但并不适合定义横向的关系。正是这些分散在各处且与对象核心功能无关的代码,使得模块复用难度增加。

而AOP就是对OOP的补充,AOP将那些影响了多个类的公共行为封装到一个可重用模块,并将其命名为"Aspect",即切面(方面,不喜欢这个翻译)。“切面”,就是那些与业务无关,却为业务模块所共同调用的逻辑或责任封装起来,便于减少系统的重复代码,降低模块之间的耦合度,并有利于未来的可操作性和可维护性。

AOP实现方式

预编译:AspectJ
运行期动态代理(JDK动态代理、CGLib动态代理):SpringAOP、JbossAOP

相关点

  1. 切面(Aspect):a modularization of a concern that cuts across multiple classes. Transaction management is a good example of a crosscutting concern in enterprise Java applications.
  2. 连接点(JoinPoint):a point during the execution of a program, such as the execution of a method or the handling of an exception. In Spring AOP, a join point always represents a method execution.
  3. 通知(Advice):action taken by an aspect at a particular join point. Different types of advice include “around,” “before” and “after” advice.
  4. 切入点(Pointcut):a predicate that matches join points. The concept of join points as matched by pointcut expressions is central to AOP
  5. 引入(introduction):declaring additional methods or fields on behalf of a type.如:引入父类接口,及父类实现。
  6. 目标(target):advised object.
  7. 代理(proxy):In the Spring Framework, an AOP proxy will be a JDK dynamic proxy or a CGLIB proxy.
  8. 织入(weaving):linking aspects with other application types or objects to create an advised object.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值