Spring AOP简介
AOP简述
AOP的概念早在上个世纪九十年代初就已经出现了,当时的研究人员通过对面向对象思想局限性的分析研究出了一种新的编程思想来帮助开发者减少代码重复提高开发效率,那就是AOP,Aspect-Oriented Programming。AOP是OOP的补充,是GOF的延续。我们知道设计模式是对于面向对象设计中经验的总结,它孜孜不断追求的就是调用者与被调用者之间的解耦。有了设计模式我们可以更有效的利用面向对象的特性,使得整个软件设计更加灵活、优雅。但是设计模式是基于面向对象的思想而形成的,更多的时候关注的是对象层次的东西,在解决对象行为内部问题方面却有些不足。AOP的出现恰恰就是对面向对象思想做出了完美的补充。

上图显示了软件的纵向和横向结构,从纵向结构来看就是我们软件系统的各个模块,它主要负责处理我们的核心业务(例如商品订购、购物车查看);而从横向结构来看,我们几乎每个系统又包含一些公共模块(例如权限、日志模块等)。这些公共模块分布于我们各个核心业务之中(例如订购和查看商品明细的过程都需要检查用户权限、记录系统日志等)。这样一来不仅在开发过程中要处处关注公共模块的处理而且开发后维护起来也是十分麻烦。而有了AOP之后将应用程序中的商业逻辑同对其提供支持的通用服务进行分离,使得开发人员可以更多的关注核心业务开发。
基本概念:
Let us begin by defining some central AOP concepts and terminology. These terms are not Spring-specific… unfortunately, AOP terminology is not particularly intuitive; however, it would be even more confusing if Spring used its own terminology.
- Aspect: a modularization of a concern that cuts across multiple classes. Transaction management is a good example of a crosscutting concern in enterprise Java applications. In Spring AOP, aspects are implemented using regular   classes (the schema-based approach) or regular classes annotated with the 
@Aspectannotation (the@AspectJstyle). 
- Join point: a point during the execution of a program, such as the execution of a method or the handling of an exception. In Spring AOP, a join point alwaysrepresents a method execution.
 
- Advice: action taken by an aspect at a particular join point. Different types of advice include "around," "before" and "after" advice. (Advice types are discussed below.) Many AOP frameworks, including Spring, model an advice as an interceptor, maintaining a chain of interceptors around the join point.
 
- Pointcut: a predicate that matches join points. Advice is associated with a pointcut expression and runs at any join point matched by the pointcut (for example, the execution of a method with a certain name). The concept of join points as matched by pointcut expressions is central to AOP, and Spring uses the AspectJ pointcut expression language by default.
 
- Introduction: declaring additional methods or fields on behalf of a type. Spring AOP allows you to introduce new interfaces (and a corresponding implementation) to any advised object. For example, you could use an introduction to make a bean implement an 
IsModifiedinterface, to simplify caching. (An introduction is known as an inter-type declaration in the AspectJ community.) 
- Target object: object being advised by one or more aspects. Also referred to as the advised object. Since Spring AOP is implemented using runtime proxies, this object will always be a proxied object.
 
- AOP proxy: an object created by the AOP framework in order to implement the aspect contracts (advise method executions and so on). In the Spring Framework, an AOP proxy will be a JDK dynamic proxy or a CGLIB proxy.
 
- Weaving: linking aspects with other application types or objects to create an advised object. This can be done at compile time (using the AspectJ compiler, for example), load time, or at runtime. Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime.
 
Spring AOP简介的更多相关文章
- Spring AOP 简介
		
Spring AOP 简介 如果说 IoC 是 Spring 的核心,那么面向切面编程就是 Spring 最为重要的功能之一了,在数据库事务中切面编程被广泛使用. AOP 即 Aspect Orien ...
 - Spring AOP 简介(三)
		
Spring AOP 简介 如果说 IoC 是 Spring 的核心,那么面向切面编程就是 Spring 最为重要的功能之一了,在数据库事务中切面编程被广泛使用. AOP 即 Aspect Orien ...
 - Spring AOP简介与底层实现机制——动态代理
		
AOP简介 AOP (Aspect Oriented Programing) 称为:面向切面编程,它是一种编程思想.AOP 是 OOP(面向对象编程 Object Oriented Programmi ...
 - Spring - AOP简介与图示
		
[1]AOP (Aspect-Oriented Programming, 面向切面编程),是一种新的方法论, 是对传统 OOP(Object-Oriented Programming, 面向对象编程) ...
 - Spring学习(三)Spring AOP 简介
		
一.简介 定义 aop就是面向切面编程,在数据库事务中切面编程被广泛使用. 在面向切面编程的思想里面,把功能分为核心业务功能,和周边功能. 核心业务:比如登陆,增加数据,删除数据都叫核心业务 周边功能 ...
 - Spring中的面向切面编程(AOP)简介
		
一.什么是AOP AOP(Aspect-Oriented Programming, 面向切面编程): 是一种新的方法论, 是对传统 OOP(Object-Oriented Programming, 面 ...
 - Spring aop与HibernateTemplate——session管理(每事务一次 Session)
		
一.HibernateTemplate与Spring aop简介 参见http://bbs.csdn.net/topics/340207475中网友blueram的发言.(感谢blueram) 二.在 ...
 - Spring AOP With AspectJ
		
一.AOP和拦截器 某些情况下,AOP和拦截器包括Filter能够实现同样的功能,一般都是请求即controller层的操作,这三个执行顺序为Filter>Interceptor>AOP, ...
 - springmvc 运行原理   Spring ioc的实现原理   Mybatis工作流程  spring  AOP实现原理
		
SpringMVC的工作原理图: SpringMVC流程 . 用户发送请求至前端控制器DispatcherServlet. . DispatcherServlet收到请求调用HandlerMappin ...
 
随机推荐
- asp.net网站中添加百度地图功能
			
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...
 - 深入浅出ES6(十六):模块 Modules
			
作者 Jason Orendorff github主页 https://github.com/jorendorff 早在2007年我刚加入Mozilla的JavaScript团队的时候广为流传一个 ...
 - (转)Android学习进阶路线导航线路(Android源码分享)
			
转载请注明出处:http://blog.csdn.net/qinjuning 前言:公司最近来了很多应届实习生,看着他们充满信心但略带稚气的脸庞上,想到了去年的自己,那是的我是不是也和 现在的他们一 ...
 - editplus bat语法高亮
			
editplus bat语法高亮 今天需要在Windows上写批处理,因为没写过,避免关键字错误,就需要语法高亮了,editplus默认没有bat语法文件,赶紧解决. 1:到 http://www.e ...
 - ***Jquery下Ajax与PHP数据交换
			
一.前台传递字符串变量,后台返回字符串变量(非json格式) Javascript代码: 这里,为了解决Ajax数据传递出现的汉字乱码,在字符串传递之前,使用javascript函数escape()对 ...
 - Zen Coding 用法
			
html:5 或者 ! 生成 HTML5 结构html:xt 生成 HTML4 过渡型html:4s 生成 HTML4 严格型 E 元素名 (div, p);E#id 带id的元素 (div#cont ...
 - C#之你懂得的反射
			
前言:反射在C#中虽然不常用(如果不需要动态加载xx.dll),但是有时候却是设计某个程序或者完成某类功能比较好用的技术.比如:一个支持动态扩展的程序,这样就需要动态加载dll,动态创建加载dll的程 ...
 - MyBatis学习总结_07_Mybatis缓存
			
一.MyBatis缓存介绍 正如大多数持久层框架一样,MyBatis 同样提供了一级缓存和二级缓存的支持 一级缓存: 基于PerpetualCache 的 HashMap本地缓存,其存储作用域为 Se ...
 - WebBrowser控件应用:弹出新窗体和关闭窗口
			
缘起:上次写了一个<WebBrowser控件的简单应用2>,提到了在NewWindow事件中打开新窗口的例子.有网友“队长 ”提出那个事件得到的参数是本页面的,而不是新页面的,经过测试,果 ...
 - Index & Statistics ->> Rebuild Index会不会覆盖原先Index的WITH选项设置
			
昨天因为工作中遇到要对某个数据库的表通通启用data_compression,突然有个念头,就是如果我当初用"ALTER INDEX XXX ON YYY REBUILD WITH (DAT ...