11. Aspect Oriented Programming with Spring
11.1 Introduction
Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by providing
another way of thinking about program structure. The key unit of modularity in OOP is the class, whereas
in AOP the unit of modularity is the aspect. Aspects enable the modularization of concerns such as
transaction management that cut across multiple types and objects. (Such concerns are often termed
crosscutting concerns in AOP literature.)
One of the key components of Spring is the AOP framework. While the Spring IoC container does not
depend on AOP, meaning you do not need to use AOP if you don’t want to, AOP complements Spring
11.1 Introduction
Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by providing
another way of thinking about program structure. The key unit of modularity in OOP is the class, whereas
in AOP the unit of modularity is the aspect. Aspects enable the modularization of concerns such as
transaction management that cut across multiple types and objects. (Such concerns are often termed
crosscutting concerns in AOP literature.)
One of the key components of Spring is the AOP framework. While the Spring IoC container does not
depend on AOP, meaning you do not need to use AOP if you don’t want to, AOP complements Spring
IoC to provide a very capable middleware solution.
面向切面编程(AOP)是对面向对象编程(OOP)的一种完善,提供了另一种思考程序架构的方式。OOP的核心模块单元是类,然而在AOP中核心模块单元是切面。切面可以使模块更加关注从各种类型和对象中抽取的事物管理。
AOP是Spring中关键的组件旨之一。但是Spring IOC容器不依赖于AOP,意味这如果你不想使用AOP的话可以没必要添加这个模块。AOP完善了Spring IOC提供了很好的中间件解决思路。