Spring AOP(3)
来源:互联网 发布:ibm软件 编辑:程序博客网 时间:2024/06/05 08:20
Introductions
1:简介允许一个切面声明一个实现指定接口的通知对象,并且提供了一个接口实现类来代替这些对象
2:由<aop:aspect>中的<aop:declare-parents>元素声明 ,该元素用于声明所匹配的类型拥有一个新的parent(因此得名)
<aop:aspect id="myAspect" ref="aBean"
<aop:declare-parents
types-matching="com.zit.trf.*+"
implement-interface="com.dada.dada.dad.UsageTraceked"
default-impl="com.fs.fsdfdsfs.DefaultUsageTraceked" />
<aop:before
pointcut="com.asf.fdsfs.方法() and this(usageTracked)"
method="recordUsage"/>
</aop:aspect>
public void recordUsage(UsageTraceked usageTraceked){
usageTraceked.incrementUseCount();
}
强制类型转换
UsageTraceked usageTraceked=(UsageTraceked)context.getBean("myServices");
所有的这种配置的切面只支持singleton model
Advisors(看书)
1:advisor就像一个小的自包含的方面,只有一个advice
2:切面自身可以通过一个bean表示,并且必须实现某个advice接口,同时,advisior也可以很好的利用AspectJ的切入点表达式
3:Spring通过配置文件中<aop:advisor>元素支持advisior实际配合使用,大多数情况下它会和transactional advice配合使用
4:为了定义一个advisior的优先级以便让advice可以有序,可以使用order属性来定义advisior的顺序
<aop:config>
<aop:pointcut id="businessService"
expression="execution(* com.fds.fs.service..(..))"/>
<aop:advisor
pointcut-ref="businessService"
advice-ref="tx-advice"/>
</aop:config>
<tx:advice id="tx-advice"> 对于事物的相关声明
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
1:简介允许一个切面声明一个实现指定接口的通知对象,并且提供了一个接口实现类来代替这些对象
2:由<aop:aspect>中的<aop:declare-parents>元素声明 ,该元素用于声明所匹配的类型拥有一个新的parent(因此得名)
<aop:aspect id="myAspect" ref="aBean"
<aop:declare-parents
types-matching="com.zit.trf.*+"
implement-interface="com.dada.dada.dad.UsageTraceked"
default-impl="com.fs.fsdfdsfs.DefaultUsageTraceked" />
<aop:before
pointcut="com.asf.fdsfs.方法() and this(usageTracked)"
method="recordUsage"/>
</aop:aspect>
public void recordUsage(UsageTraceked usageTraceked){
usageTraceked.incrementUseCount();
}
强制类型转换
UsageTraceked usageTraceked=(UsageTraceked)context.getBean("myServices");
所有的这种配置的切面只支持singleton model
Advisors(看书)
1:advisor就像一个小的自包含的方面,只有一个advice
2:切面自身可以通过一个bean表示,并且必须实现某个advice接口,同时,advisior也可以很好的利用AspectJ的切入点表达式
3:Spring通过配置文件中<aop:advisor>元素支持advisior实际配合使用,大多数情况下它会和transactional advice配合使用
4:为了定义一个advisior的优先级以便让advice可以有序,可以使用order属性来定义advisior的顺序
<aop:config>
<aop:pointcut id="businessService"
expression="execution(* com.fds.fs.service..(..))"/>
<aop:advisor
pointcut-ref="businessService"
advice-ref="tx-advice"/>
</aop:config>
<tx:advice id="tx-advice"> 对于事物的相关声明
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
阅读全文
0 0
- spring AOP(3)
- spring基础知识3:aop
- spring学习-3-AOP
- Spring AOP (3)
- Spring AOP(3)
- Spring基础-3-AOP
- Spring 3 AOP 0 AOP基础
- Spring 3 AOP 1 简单AOP
- Spring 3 AOP实现方式
- Spring技术(3)AOP
- Spring 3 AOP 概念介绍
- Spring 3 AOP 概念介绍
- Spring总结3—AOP
- 【spring 3】AOP:静态代理
- Spring学习笔记3-AOP
- Spring Aop 初探(3)
- spring-3-xml配置AOP
- spring-6-aop-3-cglib
- ubuntu 常用命令
- OkHttp wiki官方文档翻译(一)
- Spring AOP(2)
- BZOJ 4636 蒟蒻的数列
- Java中方法的重载和重写的区别
- Spring AOP(3)
- 巴铁
- ANR
- redis总结3-持久化rdb,aof,运维命令,Sentinel监控
- Hive数据去重、多变一与一变多等实现
- Java中对象的深复制(深克隆)和浅复制(浅克隆)介绍
- 深度学习基础(三)--SVM
- jQuery--4.文档处理
- Global Jobcoin——世界上区块链上的第一个就业平台