SPRING IN ACTION 第4版笔记-第四章Aspect-oriented Spring-001-什么是AOP
2016-03-03 13:41
771 查看
一、
Aspect就是把会在应用中的不同地方重复出现的非业务功能的模块化,比如日志、事务、安全、缓存
In software development, functions that span multiple points of an application are
called cross-cutting concerns. Typically, these cross-cutting concerns are conceptually
separate from (but often embedded directly within) the application’s business logic.
Separating these cross-cutting concerns from the business logic is where aspect-
oriented programming ( AOP ) goes to work.
DI helps you decouple application objects from
each other, AOP helps you decouple cross-cutting concerns from the objects they
affect.
Logging is a common example of the application of aspects, but it’s not the only
thing aspects are good for. Throughout this book, you’ll see several practical applica-
tions of aspects, including declarative transactions, security, and caching.
aspects help to modularize cross-cutting concerns. In short, a cross-
cutting concern can be described as any functionality that affects multiple points of an
application. Security, for example, is a cross-cutting concern, in that many methods in
an application can have security rules applied to them. Figure 4.1 gives a visual depic-
tion of cross-cutting concerns.
This figure represents a typical application that’s broken down into modules.
Each module’s main concern is to provide services for its particular domain. But each
module also requires similar ancillary functionality, such as security and transaction
management.
A common object-oriented technique
for reusing common functionality is to
apply inheritance or delegation. But inheri-
tance can lead to a brittle object hierarchy
if the same base class is used throughout an
application, and delegation can be cumber-
some because complicated calls to the dele-
gate object may be required.
Aspects offer an alternative to inheri-
tance and delegation that can be cleaner in
many circumstances. With AOP , you still
define the common functionality in one
place, but you can declaratively define how and where this functionality is applied
without having to modify the class to which you’re applying the new feature. Cross-
cutting concerns can now be modularized into special classes called aspects. This has
two benefits. First, the logic for each concern is in one place, as opposed to being scat-
tered all over the code base. Second, your service modules are cleaner because they
only contain code for their primary concern (or core functionality), and secondary
concerns have been moved to aspects.
Aspect就是把会在应用中的不同地方重复出现的非业务功能的模块化,比如日志、事务、安全、缓存
In software development, functions that span multiple points of an application are
called cross-cutting concerns. Typically, these cross-cutting concerns are conceptually
separate from (but often embedded directly within) the application’s business logic.
Separating these cross-cutting concerns from the business logic is where aspect-
oriented programming ( AOP ) goes to work.
DI helps you decouple application objects from
each other, AOP helps you decouple cross-cutting concerns from the objects they
affect.
Logging is a common example of the application of aspects, but it’s not the only
thing aspects are good for. Throughout this book, you’ll see several practical applica-
tions of aspects, including declarative transactions, security, and caching.
aspects help to modularize cross-cutting concerns. In short, a cross-
cutting concern can be described as any functionality that affects multiple points of an
application. Security, for example, is a cross-cutting concern, in that many methods in
an application can have security rules applied to them. Figure 4.1 gives a visual depic-
tion of cross-cutting concerns.
This figure represents a typical application that’s broken down into modules.
Each module’s main concern is to provide services for its particular domain. But each
module also requires similar ancillary functionality, such as security and transaction
management.
A common object-oriented technique
for reusing common functionality is to
apply inheritance or delegation. But inheri-
tance can lead to a brittle object hierarchy
if the same base class is used throughout an
application, and delegation can be cumber-
some because complicated calls to the dele-
gate object may be required.
Aspects offer an alternative to inheri-
tance and delegation that can be cleaner in
many circumstances. With AOP , you still
define the common functionality in one
place, but you can declaratively define how and where this functionality is applied
without having to modify the class to which you’re applying the new feature. Cross-
cutting concerns can now be modularized into special classes called aspects. This has
two benefits. First, the logic for each concern is in one place, as opposed to being scat-
tered all over the code base. Second, your service modules are cleaner because they
only contain code for their primary concern (or core functionality), and secondary
concerns have been moved to aspects.
相关文章推荐
- 在ASP.NET中如何输出日志
- 【ASP.NET】六大内置对象
- ASP.NET MVC- DropDownList绑定
- ASP.NET 使用Ajax
- asp.net mvc4使用log4.net 日志功能
- [DevExpress]ASP.NET動態設定XtraReport報表參數的方式 5715 ASP.NET 檢舉文章 在ASP.NET中要如何動態設定XtraReport報表參數,或
- ASP.NET数据绑定GridView控件使用技巧
- asp.net 接口函数
- 7天 搞定 ASP.NET MVC - 第3天
- ASP.NET MVC 多语言实现技巧 最简、最易维护和最快速开发
- ASP.NET MVC中viewData、viewBag和templateData的使用与区别
- ASP.NET 4 视频教程 风云之旅系列课程
- Asp.Net MVC anti-forgery token的问题:nameidentifier or identityprovider not present
- ASP.NET MVC ActionResult的其它返回值
- ASP.Net MVC开发基础学习笔记(2):HtmlHelper与扩展方法
- 细说 ASP.NET Cache 及其高级用法
- ASP.NET MVC Html.BeginForm用法1
- ASP.NET Mvc开发之删除修改数据
- ASP.NET Web API 简介
- ASP.NET MVC NonActionAttribute使用说明