spring aop学习

1.aop和spring aop的关系?
aop是一种思想,spring aop是aop的一种实现。

2.Spring aop和AspectJ的关系?
这两种都是实现aop的,spring借助AspectJ的语法实现aop的功能

3.@AspectJ support和Schema-based AOP Support两种语法实现aop
@AspectJ注解方式使用aop
    @Configuration
    @EnableAspectJAutoProxy (开启AspectJ语法对spring aop的支持)
    public class AppConfig {
    
    }
    
    // 声明一个Aspect切面
    @Component
    @Aspect
    public class MyAspect {
        
        // 声明一个pointcut切点,execution连接点 
        @Pointcut("execution(* com.xyz.someapp..service.*.*(..))")// the pointcut expression
        public void pointcut() {}// the pointcut signature
        
        // 声明一个Advice通知
        @Before("pointcut()")
        public void myBefore() {
            // ...
        }
    }
xml方式使用aop
    <aop:aspectj-autoproxy/>
    
    <bean id="myAspect" class="xxx.xxx.MyAspect">
        <!-- configure properties of the aspect here -->
    </bean>
4.代理技术
spring的代理技术:jdk动态代理,cglib代理

5.spring aop的代理实现。
AopProxy 接口
CglibAopProxy(cglib)实现
ObjenesisCglibAopProxy(cglib)实现
JdkDynamicAopProxy(jdk)实现


6.spring aop什么时候使用jdk,cglib代理?
proxyTargetClass = true ==> 使用cglib代理
proxyTargetClass = false ==> 有接口,使用jdk动态代理;没有,使用cglib
 

转载于:https://my.oschina.net/llsydn/blog/3013848

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值