首页  

spring aop 与 aspectj的区别和联系     所属分类 spring 浏览量 1123
AspectJ是一个面向切面的框架,它扩展了Java语言。
AspectJ定义了AOP语法,有一个专门的编译器用来生成遵守Java字节编码规范的Class文件。


spring借鉴AspectJ切面,实现注解驱动的AOP
@Aspect 注解
需要 aspectjweaver.jar
spring 只使用了其注解功能 ,底层实现依然是 Jdk动态代理 和 Cglib 代理




spring aop 几种方式

经典的SpringAOP 
纯POJO切面 
@ASpectJ注解驱动的切面 


经典的SpringAop

使用ProxyFactoryBean创建: 
增强(通知)的类型  
前置通知 org.springframework.aop.MethodBeforeAdvice 
后置通知 org.springframework.aop.AfterReturningAdvice 
环绕通知 org.aopalliance.intercept.MethodInterceptor 
异常通知 org.springframework.aop.ThrowsAdvice


常用 MethodInterceptor

org.springframework.aop.framework.ProxyFactoryBean
target proxyInterfaces interceptorNames


使用RegexMethodPointcutAdvisor 拦截特定的方法

org.springframework.aop.support.RegexpMethodPointcutAdvisor
patterns advice

自动代理 
BeanNameAutoProxyCreator

DefaultAdvisorAutoProxyCreator



纯POJO切面,使用XML配置

上一篇     下一篇
.profile 与 .bash_profile

spring5配置属性读取机制

spring5模块介绍

基于Aspect注解的spring aop 实例

AOP知识点

spring aop 内部方法调用拦截说明