Spring(八) AOP(一)spring面向切面编程--注解方式的面向切面编程

[color=red][b]注解方式的面向切面编程[/b][/color]
spring对AOP的支持(采用Annotation的方式)
1、spring依赖库
* SPRING_HOME/dist/spring.jar
* SPRING_HOME/lib/commons-logging.jar
* SPRING_HOME/lib/log4j-1.2.14.jar
* SPRING_HOME/lib/aspectj/*.jar

2、模块化横切关注点,采用@Aspect定义切面

3、在Aspect中定义Pointcut和Advice

4、启用AspectJ对Annotation的支持,参见applicationContext.xml

注意:采用Annotation定义Pointcut,Pointcut的方法是不被执行的,它存在的目的
仅仅是为了Adivce重用Pointcut的定义

AOP中的术语:
* Cross cutting concern
* Aspect--[color=red]Aspect就是要切入的类。即,SecurityHandler.java由Advice和Pointcut组成[/color]
* Advice --[color=red]切入类SecurityHandler.java中的切入方法checkSecurity()[/color]
* Pointcut --[color=red]Pointcut内容是一个表达式,来描述织入到哪些对象上的哪些方法(订阅感兴趣Joinpoint)例如:@Pointcut("execution(* add*(..)) || execution(* del*(..))")[/color]
* Jointpoint
* Weave--[color=red]应用到目标对象上的过程叫织入[/color]
* target Object --[color=red]真正的实现类UserManagerImpl.java[/color]
* Proxy --[color=red]Spring的AOP是使用JDK的动态Proxy实现的[/color]
* Introduction
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值