[Spring] Aspect Oriented Programming with Spring | AOP | 切面 | 切点

  使用Spring面向切面编程

1.介绍

AOP是OOP的补充,提供了另一种关于程序结构的思路.

OOP的模块化的关键单位是 类 .

AOP的则是aspect切面.

AOP 将程序的逻辑分成独立的块(叫做concern 重心,关注点).

AOP是用来增加跨切重心(cross-cutting concerns)的模块化的.

A cross-cutting concern 是一个可以影响整个程序的concern ,应该尽可能地在代码的某个位置中心化.

例如:事务管理,授权,登录,日志,安全等.

2.为什么使用AOP

提供pluggable方法来动态增加附加的concern:before,after 或者around 逻辑块.

 AOP的入口在xml文件中.

3. 在哪里使用AOP

在以下场景:

  • to provide declarative enterprise services such as declarative transaction management.
  • It allows users to implement custom aspects.

4.AOP概念和术语

  • Join point
  • Advice
  • Pointcut
  • Introduction
  • Target Object
  • Aspect
  • Interceptor
  • AOP Proxy
  • Weaving

4.1 Join point

Spring只提供方法执行接入点.

4.2 Advice

猜你喜欢

转载自www.cnblogs.com/zienzir/p/9113889.html