使用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

 

相关文章:

  • 2021-11-26
  • 2021-12-10
  • 2021-05-20
  • 2021-05-22
  • 2022-02-16
  • 2022-12-23
  • 2021-07-04
  • 2021-08-09
猜你喜欢
  • 2021-10-17
  • 2021-12-13
  • 2021-07-06
  • 2021-11-29
  • 2021-09-25
  • 2022-12-23
  • 2021-06-19
相关资源
相似解决方案