spring 源码阅读: getBean 0.1
20:08 2010-5-21
1、核心方法:getBean
a)流程
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:489)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:565)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:873)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:424)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at ch02.sample2.WeatherServiceTest.testSample2(WeatherServiceTest.java:18)
b) 对外提供的方法:
org.springframework.beans.factory.support.AbstractBeanFactory.getBean
c) 核心接口:
org\springframework\beans\BeanWrapper.java
(The central interface of Spring's low-level JavaBeans infrastructure.)
d)实现类:
org.springframework.beans.BeanWrapperImpl
e)/org.springframework.beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
489 行加入如下信息,进行调试:
Throwable t = new Throwable();
t.printStackTrace();
logger.debug("***** instanceWrapper:" + instanceWrapper);