【Spring-AOP-1】AOP相关概念





Advice

(好多中文书籍翻译为:增强处理,比如前向增强、后向增强等)
描述了Aspect类执行的具体动作。 the job of an aspect.
定义了如下两个方面:
  1. what:即Aspect类具体的功能;
  2. when:功能作用的时间点;
在spring中,when包括5个:



Join Points

A join point is a point in the execution of the application where an aspect can be plugged in.
This point could  be a method being called, an exception being thrown, or even a field being modified.
程序中可以有很多个join point,这些连接点可以是 方法调用异常抛出、以及 域修改等。这些都是在程序运行时的某个点。

Pointcuts

pointcut定义了advice需要在哪些join points进行织入。 pointcuts define which join points get advised.
可以简单理解为若干join point的集合,advice会在这些join points进行织入。
If advice defines the what and when of aspects, then pointcuts define the where。
pointcut definition matches one or more join points at which advice should be woven.

Aspect

An aspect is the merger of advice and pointcuts。
Aspect是advice和pointcuts的组合。
731047-20160613160348354-616434132.png

Introduction

An introduction allows you to add new methods or attributes to existing classes。
允许在已经存在的类中,添加新的方法和属性;

WEAVING

Weaving is the process of applying aspects to a target object to create a new proxied  object。
主要有3种织入方式:
  1. Compile time:AspectJ使用这种方式;
  2. Class load time:AspectJ使用这种方式;
  3. Runtime:Spring支持的方式;


Spring对AOP的支持


spring AOP基于动态的代理实现,局限于对 方法的拦截

  • SPRING ADVICE IS WRITTEN IN JAVA :所有的advice都使用Java编写,pointcut可使用XML或annotation;
  • SPRING ADVISES OBJECTS AT RUNTIME:在运行时织入advice;
  • SPRING ONLY SUPPORTS METHOD JOIN POINTS:仅支持方法的join point;






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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值