SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-002-AOP术语解析
一、
1.Advice
Advice是切面的要做的操作,它定义了what、when(什么时候要做什么事)
aspects have a purpose—a job they’re meant to do. In AOP terms, the job
of an aspect is called advice.
Advice defines both the what and the when of an aspect. In addition to describing
the job that an aspect will perform, advice addresses the question of when to perform
the job. Should it be applied before a method is invoked? After the method is
invoked? Both before and after method invocation? Or should it be applied only if a
method throws an exception?
Spring aspects can work with five kinds of advice:
Before—The advice functionality takes place before the advised method is
invoked.
After—The advice functionality takes place after the advised method completes,
regardless of the outcome.
After-returning—The advice functionality takes place after the advised method
successfully completes.
After-throwing—The advice functionality takes place after the advised method
throws an exception.
Around—The advice wraps the advised method, providing some functionality
before and after the advised method is invoked.
2.JOIN POINTS
一个应用程序可以有无数的点可以织入aspect,这些点就是连接点。一个连接点是描述当应用程序执行什么操作时要织入aspect。这个时机可以一个方法的被调用、抛出异常,甚至是一个类的成员变量被修改时。
The join points are all the points within the execution flow of the application that are candidates to have advice applied.
3.POINTCUTS
大多数情况下,并非所有连接点都需要aop,Pointcut就是用来缩小需要aop的连接点范围。如果说一个advice描述了切面的what和when问题,那么Pointcut就是描述了切面的where问题。A pointcut definition matches one or more join points at which advice should be woven。通常Pointcut用类名及方法名或表达式来定义。
The pointcut defines where (at what join points) that advice is applied. The key concept you should take from this is that pointcuts define which join points get advised.
4.Aspect
aspect是advice和pointcut的组合。
An aspect is the merger of advice and pointcuts. Taken together, advice and pointcuts define everything there is to know about an aspect—what it does and where and when it does it.
5.INTRODUCTIONS
An introduction allows you to add new methods or attributes to existing classes.比如在一个类中增加一个维护状态值的功能
6.Weaving
Weaving is the process of applying aspects to a target object to create a new proxied object. The aspects are woven into the target object at the specified join points. The weaving can take place at several points in the target object’s lifetime:
Compile time—Aspects are woven in when the target class is compiled. This
requires a special compiler. AspectJ’s weaving compiler weaves aspects this way.
Class load time—Aspects are woven in when the target class is loaded into the
JVM . This requires a special ClassLoader that enhances the target class’s byte-
code before the class is introduced into the application. AspectJ 5’s load-time
weaving ( LTW ) support weaves aspects this way.
Runtime—Aspects are woven in sometime during the execution of the applica-
tion. Typically, an AOP container dynamically generates a proxy object that del-
egates to the target object while weaving in the aspects. This is how Spring AOP aspects are woven.
SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-002-AOP术语解析的更多相关文章
- SPRING IN ACTION 第4版笔记-第四章Aspect-oriented Spring-001-什么是AOP
一. Aspect就是把会在应用中的不同地方重复出现的非业务功能的模块化,比如日志.事务.安全.缓存 In software development, functions that span mult ...
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-010-Introduction为类增加新方法@DeclareParents、<aop:declare-parents>
一. 1.Introduction的作用是给类动态的增加方法 When Spring discovers a bean annotated with @Aspect , it will automat ...
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-003-Spring对AOP支持情况的介绍
一. 不同的Aop框架在支持aspect何时.如何织入到目标中是不一样的.如AspectJ和Jboss支持在构造函数和field被修改时织入,但spring不支持,spring只支持一般method的 ...
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-005-定义切面使用@Aspect、@EnableAspectJAutoProxy、<aop:aspectj-autoproxy>
一. 假设有如下情况,有一个演凑者和一批观众,要实现在演凑者的演凑方法前织入观众的"坐下"."关手机方法",在演凑结束后,如果成功,则织入观众"鼓掌& ...
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-004-使用AspectJ’s pointcut expression language定义Pointcut
一. 1.在Spring中,pointcut是通过AspectJ’s pointcut expression language来定义的,但spring只支持它的一部分,如果超出范围就会报Illegal ...
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-012-AOP总结
1.AOP是面向对象编程的有力补充,它可以让你把分散在应用中的公共辅助功能抽取成模块,以灵活配置,减少了重复代码,让类更关注于自身的功能
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-011-注入AspectJ Aspect
一. 1. package concert; public interface CriticismEngine { public String getCriticism(); } 2. package ...
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-009-带参数的ADVICE2 配置文件为XML
一. 1.配置文件为xml时则切面类不用写aop的anotation package com.springinaction.springidol; public class Magician impl ...
- SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-009-带参数的ADVICE2
一. 情景:有个魔术师会读心术,常人一想一事物他就能读到.以魔术师为切面织入常人的内心. 二. 1. // <start id="mindreader_java" /> ...
随机推荐
- asp中的几个取整函数fix(),int(),round()的用法
asp中的几个取整函数是:fix(),int(),round(); Int(number).Fix(number)函数返回数字的整数部分.number 参数可以是任意有效的数值表达式.如果 numbe ...
- ASP读取RSS
<% @language="VBScript"%> <% Function readrss(xmlseed) dim xmlDoc dim http Set ht ...
- UrlOfFIle
如上,报错位置为folder.Files[],表示这里需要的是文件的Url地址,即folder.Files[文件的Url地址].
- 树莓派配置AP模式
所需硬件:树莓派.无线网卡 1.查看无线网卡是否被识别 pi@raspberrypi ~ $ sudo lsusb Bus Device : ID : Standard Microsystems Co ...
- ### MATLAB - CUDA
MATLAB下使用CUDA. #@author: gr #@date: 2014-04-08 #@email: forgerui@gmail.com 一. Matlab & C 1. 概念 M ...
- iOS创建UUID
- (NSString *)getUUID { CFUUIDRef uuidObj = CFUUIDCreate(nil); //create a new UUID NSString * uuidSt ...
- C# ACM poj1002
排序 public static void acm1002(string[] azx) { string[] a = new string[azx.Length]; ; i < azx.Leng ...
- 03_HttpClient_Post请求
[实例1.最最最简洁的POST请求] @Test public void test1() throws Exception{ //1.创建Htpclient实例(可关闭 Closeable) Clos ...
- 九度OJ 1385 重建二叉树
题目地址:http://ac.jobdu.com/problem.php?pid=1385 题目描述: 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都 ...
- CentOS7 列出服务和对应端口
列出服务和他们对应的端口: netstat -tulpn