摘要:
spring在初始化之后, 还调用了一次 Bean 的后置处理器. 代码片段: org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsAfterIniti 阅读全文
posted @ 2020-07-27 21:32
Sniper_ZL
阅读(1729)
评论(0)
推荐(0)
摘要:
代码片段: org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsBeforeInitialization @Override public Object 阅读全文
posted @ 2020-07-27 21:29
Sniper_ZL
阅读(2191)
评论(0)
推荐(0)
摘要:
当spring完成属性注入之后, 就要开始 bean 的初始化了 代码片段: org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#doCreateBean // Initialize the bea 阅读全文
posted @ 2020-07-27 21:28
Sniper_ZL
阅读(442)
评论(0)
推荐(0)
摘要:
示例 @Component public class IndexA { @Autowired IndexB bbb; public IndexA() { System.out.println("IndexA constructor..."); } public void printf(){ Syst 阅读全文
posted @ 2020-07-27 21:26
Sniper_ZL
阅读(3593)
评论(0)
推荐(1)
摘要:
代码片段: org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#populateBean boolean hasInstAwareBpps = hasInstantiationAwareBeanPo 阅读全文
posted @ 2020-07-27 21:25
Sniper_ZL
阅读(2063)
评论(0)
推荐(0)
摘要:
代码片段: org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#populateBean if (!mbd.isSynthetic() && hasInstantiationAwareBeanPos 阅读全文
posted @ 2020-07-27 21:24
Sniper_ZL
阅读(1488)
评论(0)
推荐(0)
摘要:
属性扫描完成之后, 就可以开始属性注入了. 代码块: org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#doCreateBean boolean earlySingletonExposure = 阅读全文
posted @ 2020-07-27 21:23
Sniper_ZL
阅读(1088)
评论(0)
推荐(0)
摘要:
创建完对象之后, 接下来, 就应该想办法对属性进行注入了, 其中就包括 @Autowired 注入 但是在注入之前, 貌似 还没有对 @Autowired 进行扫描和解析. 代码块: if (instanceWrapper == null) { /** * 创建 bean 实例,并将实例包裹在 Be 阅读全文
posted @ 2020-07-27 21:22
Sniper_ZL
阅读(7197)
评论(0)
推荐(2)
摘要:
spring在创建对象(org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#createBeanInstance)的时候, 使用了这个 构造函数后置处理器, 用来选择使用哪个构造函数的. 所以这个后 阅读全文
posted @ 2020-07-27 21:20
Sniper_ZL
阅读(1124)
评论(0)
推荐(0)
摘要:
接着前面, 看完构造函数前的后置处理器, 就到 doCreateBean 方法了. protected Object doCreateBean(final String beanName, final RootBeanDefinition mbd, final @Nullable Object[] 阅读全文
posted @ 2020-07-27 21:18
Sniper_ZL
阅读(937)
评论(0)
推荐(0)
摘要:
在 createBean 方法中, doCreateBean 方法前, 调用了这样一句代码: org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#createBean // Give BeanPos 阅读全文
posted @ 2020-07-27 21:17
Sniper_ZL
阅读(700)
评论(0)
推荐(0)
摘要:
由于 getBean 内容比较多, 所以单独出来, 接着上一篇的顺序来看. //org.springframework.beans.factory.support.AbstractBeanFactory#getBean @Override public Object getBean(String n 阅读全文
posted @ 2020-07-27 21:16
Sniper_ZL
阅读(440)
评论(0)
推荐(0)
摘要:
执行完前面的步骤后, 回到 org.springframework.context.support.AbstractApplicationContext#refresh 方法. @Override public void refresh() throws BeansException, Illega 阅读全文
posted @ 2020-07-27 21:14
Sniper_ZL
阅读(382)
评论(0)
推荐(0)
摘要:
EventListenerMethodProcessor 是 BeanFactory 的一个后置处理器, 用来对 @EventListener 提供支持. 主要是标注了 @EventListener 的方法进行解析, 然后转换为一个 ApplicationListener. 1. 在 refresh 阅读全文
posted @ 2020-07-27 21:10
Sniper_ZL
阅读(1458)
评论(0)
推荐(0)
摘要:
demo和 springIOC - ConfigurationClassPostProcessor - full / lite 里面是同一个. 暂且先不管 full , lite 有什么作用, 也不管spring是如何做到的, 如果是自己做, 怎么可以实现那种效果. demo: public cla 阅读全文
posted @ 2020-07-27 21:09
Sniper_ZL
阅读(559)
评论(0)
推荐(0)
摘要:
接 springIOC - ConfigurationClassPostProcessor - full / lite 代码块: org.springframework.context.annotation.ConfigurationClassPostProcessor#processConfigB 阅读全文
posted @ 2020-07-27 21:07
Sniper_ZL
阅读(473)
评论(0)
推荐(0)
摘要:
开始阅读 Import 源码之前, 也是需要些一些测试demo, 来帮助理解和调试 demo 建几个内容一样的类, 如: IndexDao1, IndexDao2, IndexDao3 其具体内容如下: public class IndexDao1 { public IndexDao1() { Sy 阅读全文
posted @ 2020-07-27 21:06
Sniper_ZL
阅读(396)
评论(0)
推荐(0)
摘要:
在接上一篇之前, 我想先写几个测试demo, 应该能帮助更好的理解. demo: com.study.elvinle.ioc.xml.IndexService: public class IndexService { private String name = "index";public Stri 阅读全文
posted @ 2020-07-27 21:05
Sniper_ZL
阅读(375)
评论(0)
推荐(0)
摘要:
ConfigurationClassPostProcessor 首先看看他的类的关系: public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPostProcessor, PriorityOrder 阅读全文
posted @ 2020-07-27 20:48
Sniper_ZL
阅读(545)
评论(0)
推荐(0)
摘要:
接上一篇, 看 refresh() 方法. refresh org.springframework.context.support.AbstractApplicationContext#refresh 方法, 是一个非常强大的方法@Override public void refresh() thr 阅读全文
posted @ 2020-07-27 20:47
Sniper_ZL
阅读(470)
评论(0)
推荐(0)
摘要:
接着上一篇. 这里来看一下 register(componentClasses) register @Override public void register(Class<?>... componentClasses) { Assert.notEmpty(componentClasses, "At 阅读全文
posted @ 2020-07-27 20:46
Sniper_ZL
阅读(486)
评论(0)
推荐(0)
摘要:
前言 目前接触到所有的java框架中, 或多或少, 都需要spring, 有的是基于spring, 有的是需要与spring集成使用. 对于 spring , 就像是大厦的地基. 所以不能不看看这个地基是怎么建的. 以前也时常看 spring 源码, 都是一知半解的, 不知其真解. spring 太 阅读全文
posted @ 2020-07-27 20:44
Sniper_ZL
阅读(372)
评论(0)
推荐(0)

浙公网安备 33010602011771号