Spring aop Introduction

Spring aop 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 is used in the Spring Framework to...

 

... provide declarative enterprise services, especially as a replacement for EJB declarative services. The most important such service is declarative transaction management.

 

 

... allow users to implement custom aspects, complementing their use of OOP with AOP.

 

If you are interested only in generic declarative services or other pre-packaged declarative middleware services such as pooling, you do not need to work directly with Spring AOP, and can skip most of this chapter.

 

Spring aop 介绍

AOP编程通过另一种关于编程架构的思考,补充了OOP的编程方式。OOP的主要元素是类,而AOP的主要元素是切面。切面将贯穿于多个类型和对象之间的事务管理等类似的问题进行了模块化。(这些问题通常在AOP的资料中定义为关注切面问题)

Spring的一个关键组件是AOP框架。但是SpringIoc容器并没有依赖于AOP,这就意味着如果你不想用AOP,那么你就不需要用AOPAOP只是为IOC提供了一种非常强大的中间件解决方案。

AOPSpring框架中有如下用途:

提供声明式企业服务,特别是替代了EJB的声明服务。最主要的就是想声明式事务管理这样的服务。

允许用户实现自定义的切面,从而通过AOP完善自己的OOP使用。

如果你只对通用的声明式服务或者其他的欲打包声明式中间件服务(如pooling),那么你不需要直接与Spring AOP产生直接关系,而且可以略过这一章的大部分内容。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值