测试-spring源码摘取

首次加载idea是真的慢。。。

也许是我电脑性能太差。。。

我分析他内部有一套索引的机制,需要每次打开现建立。。。

没有固态的话,首次打开还不如eclipse

第一次使用博客园,以前都在csdn混~

所以发一段spring ioc源码,测试一下博客园的代码编辑功能是否好用~~~

此段源码为ioc中refresh起始方法中,创建beanFactory的源码,也是从refresh开始

ioc开始分3步加载

1、资源定位;

2、loadBeanDefinitions-->即将xml配置文件解析的bean及其属性在spring自己定义的数据结构中,然后存放在一个currentHashMap中以供访问。

3、最后在getBean时才是真正的依赖注入过程哈哈哈。

/**
* This implementation performs an actual refresh of this context's underlying
* bean factory, shutting down the previous bean factory (if any) and
* initializing a fresh bean factory for the next phase of the context's lifecycle.
*/
@Override
protected final void refreshBeanFactory() throws BeansException {
if (hasBeanFactory()) {
destroyBeans();
closeBeanFactory();
}
try {
DefaultListableBeanFactory beanFactory = createBeanFactory();
beanFactory.setSerializationId(getId());
customizeBeanFactory(beanFactory);
loadBeanDefinitions(beanFactory);
synchronized (this.beanFactoryMonitor) {
this.beanFactory = beanFactory;
}
}
catch (IOException ex) {
throw new ApplicationContextException("I/O error parsing bean definition source for " + getDisplayName(), ex);
}
}

 

posted @ 2017-12-21 09:28  清风小妖的天空521  阅读(465)  评论(0编辑  收藏  举报