怎么使用DeBug深入源码

使用DeBug深入Spring-IOC容器的创建过程


1.写出测试程序并打上断点

2.进入Debug模式

怎么使用DeBug深入源码_第1张图片

3.Debug界面认识

4.享受Debug模式,若没有源码,自行导入


IOC容器初始化的核心代码


AbstractApplicationContext

public   void   refresh()   throws   BeansException, IllegalStateException {
         synchronized   ( this . startupShutdownMonitor ) {
             // Prepare this context for refreshing.
            prepareRefresh();
             // Tell the subclass to refresh the internal bean factory.
            ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();
             // Prepare the bean factory for use in this context.
            prepareBeanFactory(beanFactory);
             try   {
                 // Allows post-processing of the bean factory in context subclasses.
                postProcessBeanFactory(beanFactory);
                 // Invoke factory processors registered as beans in the context.
                invokeBeanFactoryPostProcessors(beanFactory);
                 // Register bean processors that intercept bean creation.
                registerBeanPostProcessors(beanFactory);
                 // Initialize message source for this context.
                initMessageSource();
                 // Initialize event multicaster for this context.
                initApplicationEventMulticaster();
                 // Initialize other special beans in specific context subclasses.
                onRefresh();
                 // Check for listener beans and register them.
                registerListeners();
                 // Instantiate all remaining (non-lazy-init) singletons.
                finishBeanFactoryInitialization(beanFactory);
                 // Last step: publish corresponding event.
                finishRefresh();
            }
             catch   (BeansException ex) {
                 // Destroy already created singletons to avoid dangling resources.
                destroyBeans();
                 // Reset 'active' flag.
                cancelRefresh(ex);
                 // Propagate exception to caller.
                 throw   ex;
            }
        }
    }


你可能感兴趣的:(IOC容器初始化Debug,IOC初始化核心代码)