org.springframework.context.support

## 类 AbstractRefreshableApplicationContext

- java.lang.Object
- - org.springframework.core.io.DefaultResourceLoader
  - - org.springframework.context.support.AbstractApplicationContext
    - - org.springframework.context.support.AbstractRefreshableApplicationContext

- 所有已实现的接口:
    Closeable, AutoCloseable, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.ListableBeanFactory, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, org.springframework.core.env.EnvironmentCapable, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver
  直接已知子类:
    AbstractRefreshableConfigApplicationContext

      public abstract class AbstractRefreshableApplicationContext
      extends AbstractApplicationContext

  Base class for `ApplicationContext` implementations which are supposed to support multiple calls to `AbstractApplicationContext.refresh()`, creating a new internal bean factory instance every time. Typically (but not necessarily), such a context will be driven by a set of config locations to load bean definitions from.

  The only method to be implemented by subclasses is `loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)`, which gets invoked on each refresh. A concrete implementation is supposed to load bean definitions into the given `DefaultListableBeanFactory`, typically delegating to one or more specific bean definition readers.

  Note that there is a similar base class for WebApplicationContexts. `org.springframework.web.context.support.AbstractRefreshableWebApplicationContext` provides the same subclassing strategy, but additionally pre-implements all context functionality for web environments. There is also a pre-defined way to receive config locations for a web context.

  Concrete standalone subclasses of this base class, reading in a specific bean definition format, are `ClassPathXmlApplicationContext` and `FileSystemXmlApplicationContext`, which both derive from the common `AbstractXmlApplicationContext` base class; `AnnotationConfigApplicationContext` supports `@Configuration`-annotated classes as a source of bean definitions.

  从以下版本开始:
    1.1.3
  作者:
    Juergen Hoeller, Chris Beams
  另请参阅:
    `loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)`, `DefaultListableBeanFactory`, `org.springframework.web.context.support.AbstractRefreshableWebApplicationContext`, `AbstractXmlApplicationContext`, `ClassPathXmlApplicationContext`, `FileSystemXmlApplicationContext`, `AnnotationConfigApplicationContext`

- - ### 嵌套类概要

    - ### 从类继承的嵌套类/接口 org.springframework.core.io.DefaultResourceLoader

      `org.springframework.core.io.DefaultResourceLoader.ClassPathContextResource`

  - ### 字段概要

    - ### 从类继承的字段 org.springframework.context.support.AbstractApplicationContext

      `APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME`

    - ### 从接口继承的字段 org.springframework.context.ConfigurableApplicationContext

      `CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME`

    - ### 从接口继承的字段 org.springframework.beans.factory.BeanFactory

      `FACTORY_BEAN_PREFIX`

    - ### 从接口继承的字段 org.springframework.core.io.support.ResourcePatternResolver

      `CLASSPATH_ALL_URL_PREFIX`

    - ### 从接口继承的字段 org.springframework.core.io.ResourceLoader

      `CLASSPATH_URL_PREFIX`

  - ### 构造器概要

    构造器
    构造器和说明
    `AbstractRefreshableApplicationContext()` Create a new AbstractRefreshableApplicationContext with no parent.
    `AbstractRefreshableApplicationContext(ApplicationContext parent)` Create a new AbstractRefreshableApplicationContext with the given parent context.

  - ### 方法概要

    所有方法 实例方法 抽象方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected void` | `assertBeanFactoryActive()` Overridden to turn it into a no-op: With AbstractRefreshableApplicationContext, `getBeanFactory()` serves a strong assertion for an active context anyway.
    `protected void` | `cancelRefresh(org.springframework.beans.BeansException ex)` Cancel this context's refresh attempt, resetting the `active` flag after an exception got thrown.
    `protected void` | `closeBeanFactory()` Subclasses must implement this method to release their internal bean factory.
    `protected org.springframework.beans.factory.support.DefaultListableBeanFactory` | `createBeanFactory()` 方法实现说明:为我们的spring 上下文创建我们的内置的beanFactory
    `protected void` | `customizeBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)` Customize the internal bean factory used by this context.
    `org.springframework.beans.factory.config.ConfigurableListableBeanFactory` | `getBeanFactory()` Subclasses must return their internal bean factory here.
    `protected boolean` | `hasBeanFactory()` Determine whether this context currently holds a bean factory, i.e. has been refreshed at least once and not been closed yet.
    `protected abstract void` | `loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)` Load bean definitions into the given bean factory, typically through delegating to one or more bean definition readers.
    `protected void` | `refreshBeanFactory()` 方法实现说明:是AbstractApplicationContext对象的子类,用于springmvc来刷新容器调用
    `void` | `setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding)` Set whether it should be allowed to override bean definitions by registering a different definition with the same name, automatically replacing the former.
    `void` | `setAllowCircularReferences(boolean allowCircularReferences)` Set whether to allow circular references between beans - and automatically try to resolve them.

    - ### 从类继承的方法 org.springframework.context.support.AbstractApplicationContext

      `addApplicationListener, addBeanFactoryPostProcessor, close, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroy, destroyBeans, doClose, findAnnotationOnBean, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getApplicationName, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResourcePatternResolver, getResources, getStartupDate, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, initPropertySources, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, postProcessBeanFactory, prepareBeanFactory, prepareRefresh, publishEvent, publishEvent, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, resetCommonCaches, setDisplayName, setEnvironment, setId, setParent, start, stop, toString`

    - ### 从类继承的方法 org.springframework.core.io.DefaultResourceLoader

      `addProtocolResolver, clearResourceCaches, getClassLoader, getProtocolResolvers, getResource, getResourceByPath, getResourceCache, setClassLoader`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### 从接口继承的方法 org.springframework.context.ConfigurableApplicationContext

      `addProtocolResolver`

    - ### 从接口继承的方法 org.springframework.core.io.ResourceLoader

      `getClassLoader, getResource`

- - ### 构造器详细资料

    - #### AbstractRefreshableApplicationContext

          public AbstractRefreshableApplicationContext()

      Create a new AbstractRefreshableApplicationContext with no parent.

    - #### AbstractRefreshableApplicationContext

          public AbstractRefreshableApplicationContext(@Nullable
                                                       ApplicationContext parent)

      Create a new AbstractRefreshableApplicationContext with the given parent context.
      参数:
        `parent` - the parent context

  - ### 方法详细资料

    - #### setAllowBeanDefinitionOverriding

          public void setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding)

      Set whether it should be allowed to override bean definitions by registering a different definition with the same name, automatically replacing the former. If not, an exception will be thrown. Default is "true".
      另请参阅:
        `DefaultListableBeanFactory.setAllowBeanDefinitionOverriding(boolean)`

    - #### setAllowCircularReferences

          public void setAllowCircularReferences(boolean allowCircularReferences)

      Set whether to allow circular references between beans - and automatically try to resolve them.

      Default is "true". Turn this off to throw an exception when encountering a circular reference, disallowing them completely.

      另请参阅:
        `AbstractAutowireCapableBeanFactory.setAllowCircularReferences(boolean)`

    - #### refreshBeanFactory

          protected final void refreshBeanFactory()
                                           throws org.springframework.beans.BeansException

      方法实现说明:是AbstractApplicationContext对象的子类,用于springmvc来刷新容器调用
      指定者:
        `refreshBeanFactory` 在类中 `AbstractApplicationContext`
      抛出:
        `org.springframework.beans.BeansException` - if initialization of the bean factory failed

    - #### cancelRefresh

          protected void cancelRefresh(org.springframework.beans.BeansException ex)

      从类复制的说明: `AbstractApplicationContext`
      Cancel this context's refresh attempt, resetting the `active` flag after an exception got thrown.
      覆盖:
        `cancelRefresh` 在类中 `AbstractApplicationContext`
      参数:
        `ex` - the exception that led to the cancellation

    - #### closeBeanFactory

          protected final void closeBeanFactory()

      从类复制的说明: `AbstractApplicationContext`
      Subclasses must implement this method to release their internal bean factory. This method gets invoked by `AbstractApplicationContext.close()` after all other shutdown work.

      Should never throw an exception but rather log shutdown failures.

      指定者:
        `closeBeanFactory` 在类中 `AbstractApplicationContext`

    - #### hasBeanFactory

          protected final boolean hasBeanFactory()

      Determine whether this context currently holds a bean factory, i.e. has been refreshed at least once and not been closed yet.

    - #### getBeanFactory

          public final org.springframework.beans.factory.config.ConfigurableListableBeanFactory getBeanFactory()

      从类复制的说明: `AbstractApplicationContext`
      Subclasses must return their internal bean factory here. They should implement the lookup efficiently, so that it can be called repeatedly without a performance penalty.

      Note: Subclasses should check whether the context is still active before returning the internal bean factory. The internal factory should generally be considered unavailable once the context has been closed.

      指定者:
        `getBeanFactory` 在接口中 `ConfigurableApplicationContext`
      指定者:
        `getBeanFactory` 在类中 `AbstractApplicationContext`
      返回:
        this application context's internal bean factory (never `null`)
      另请参阅:
        `AbstractApplicationContext.refreshBeanFactory()`, `AbstractApplicationContext.closeBeanFactory()`

    - #### assertBeanFactoryActive

          protected void assertBeanFactoryActive()

      Overridden to turn it into a no-op: With AbstractRefreshableApplicationContext, `getBeanFactory()` serves a strong assertion for an active context anyway.
      覆盖:
        `assertBeanFactoryActive` 在类中 `AbstractApplicationContext`

    - #### createBeanFactory

          protected org.springframework.beans.factory.support.DefaultListableBeanFactory createBeanFactory()

      方法实现说明:为我们的spring 上下文创建我们的内置的beanFactory

    - #### customizeBeanFactory

          protected void customizeBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)

      Customize the internal bean factory used by this context. Called for each `AbstractApplicationContext.refresh()` attempt.

      The default implementation applies this context's "allowBeanDefinitionOverriding" and "allowCircularReferences" settings, if specified. Can be overridden in subclasses to customize any of `DefaultListableBeanFactory`'s settings.

      参数:
        `beanFactory` - the newly created bean factory for this context
      另请参阅:
        `DefaultListableBeanFactory.setAllowBeanDefinitionOverriding(boolean)`, `AbstractAutowireCapableBeanFactory.setAllowCircularReferences(boolean)`, `AbstractAutowireCapableBeanFactory.setAllowRawInjectionDespiteWrapping(boolean)`, `DefaultListableBeanFactory.setAllowEagerClassLoading(boolean)`

    - #### loadBeanDefinitions

          protected abstract void loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
                                               throws org.springframework.beans.BeansException,
                                                      IOException

      Load bean definitions into the given bean factory, typically through delegating to one or more bean definition readers.
      参数:
        `beanFactory` - the bean factory to load bean definitions into
      抛出:
        `org.springframework.beans.BeansException` - if parsing of the bean definitions failed
        `IOException` - if loading of bean definition files failed
      另请参阅:
        `PropertiesBeanDefinitionReader`, `XmlBeanDefinitionReader`