【Spring-Framework】积累与发现

Spring-framework 核心

Spring容器启动流程(源码解读)

AOP

细说Spring——AOP详解(AOP概览)
切入点表达式需要一个aspectjweaver
Spring AOP 笔记三(引入Introductions)
Spring-AOP @AspectJ切点函数之target()和this()
Spring AOP target() vs this()
spring里多数情况下这俩东西没区别,不过Stack Overflow里的回答说的很好,首先target指的是被代理的按个对象,而this实际上指的是代理对象proxytarget(clazz)表示的是被代理对象是clazz这个类的话会触发aopthis(class)表示的是proxyclazz这个类的话会触发aop

AOP API

深入理解Spring AOP-基于API编程
Spring AOP的Advice接口设计
Spring源码:Advice接口

class SimplePojo implements Pojo{
   }

ProxyFactory factory = new ProxyFactory(new SimplePojo());
factory.addInterface(Pojo.class);
factory.addAdvice(new MyAdvice());
Pojo pojo=(Pojo)factory.getProxy();
pojo.foo();

【框架】[Spring]纯Java方式实现AOP拦截-详解ThrowsAdvice异常通知
Note that this means that the org.springframework.aop.ThrowsAdvice interface does not contain any methods. It is a tag interface identifying that the given object implements one or more typed throws advice methods.

Bean Overview——IoC注册bean

spring中factory-method使用
关于spring配置文件中读取${username}为系统当前用户名的问题
Spring的Bean加载流程
Spring 是如何解决循环依赖的?

Bean Scope——Bean的作用范围

关于registerSingleton()方法的缺点
Spring-AOP标签scoped-proxy
Spring当中aop:scoped-proxy 的用法
Spring——<aop:scoped-proxy/>理解
当向长生命周期的bean(假如说singleton-scoped的对象A)注入一个短生命周期的bean(假如说session-scoped的对象B)的时候,如下所示

<bean id="controller" class="controller.Controller" scope="session">
    </bean>
    <bean id="singletonController" class="controller.SingletonController">
        <property name="controller" ref="controller"/>
    </bean>

这会引出一个问题,容器创建的时候,没有用户访问网页,对象B并没有创建,那么对于对象A的依赖注入会失败,所以会报错:consider defining a scoped proxy for this bean if you intend to refer to it from a singleton,改成下面的方式即可。所以说<aop:scoped-proxy />的功能就是让容器生成一个controller的代理对象,这个代理对象能够配合singleController的生命周期完成注入,当调用其方法的时候,实际调用的是真实的controller自己的方法

<bean id="controller" class="controller.Controller" scope="session">
	<aop:scoped-proxy />
</bean>
<bean id="singletonController" class="controller.SingletonController">
	<property name="controller
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值