Spring beanDefinition载入

Spring beanDefinition载入_第1张图片

Spring beanDefinition载入_第2张图片

 

 Spring beanDefinition载入_第3张图片

 

 Spring beanDefinition载入_第4张图片

@Override
    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) {
                if (logger.isWarnEnabled()) {
                    logger.warn("Exception encountered during context initialization - " +
                            "cancelling refresh attempt: " + ex);
                }

                // Destroy already created singletons to avoid dangling resources.
                destroyBeans();

                // Reset 'active' flag.
                cancelRefresh(ex);

                // Propagate exception to caller.
                throw ex;
            }

            finally {
                // Reset common introspection caches in Spring's core, since we
                // might not ever need metadata for singleton beans anymore...
                resetCommonCaches();
            }
        }
    }

包括BeanDefinition的Resource定位,载入,注册三个基本过程

三个过程分开,并使用不同的模块来完成,如何使用相应的ResourceLoader,BeanDefinitionReader等模块,通过这样的设计方式,可以让用户更加啊灵活的对这三个过程进行剪裁或扩展

Spring beanDefinition载入_第5张图片

 

Spring beanDefinition载入_第6张图片

Spring beanDefinition载入_第7张图片

 

 Spring beanDefinition载入_第8张图片

 

 Spring beanDefinition载入_第9张图片

 

 Spring beanDefinition载入_第10张图片

 

 Spring beanDefinition载入_第11张图片

 

 Spring beanDefinition载入_第12张图片

 

Spring beanDefinition载入_第13张图片

 

 Spring beanDefinition载入_第14张图片

 

 

 Spring beanDefinition载入_第15张图片

Spring beanDefinition载入_第16张图片

Spring beanDefinition载入_第17张图片

 

 

Spring beanDefinition载入_第18张图片

你可能感兴趣的:(Spring beanDefinition载入)