Class AbstractRefreshableConfigApplicationContext

java.lang.Object
org.springframework.core.io.DefaultResourceLoader
All Implemented Interfaces:
Closeable, AutoCloseable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.InitializingBean, 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
Direct Known Subclasses:
AbstractXmlApplicationContext

public abstract class AbstractRefreshableConfigApplicationContext extends AbstractRefreshableApplicationContext implements org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean
AbstractRefreshableApplicationContext subclass that adds common handling of specified config locations. Serves as base class for XML-based application context implementations such as ClassPathXmlApplicationContext and FileSystemXmlApplicationContext, as well as org.springframework.web.context.support.XmlWebApplicationContext.
Since:
2.5.2
Author:
Juergen Hoeller
See Also:
  • Constructor Details

    • AbstractRefreshableConfigApplicationContext

      public AbstractRefreshableConfigApplicationContext()
      Create a new AbstractRefreshableConfigApplicationContext with no parent.
    • AbstractRefreshableConfigApplicationContext

      public AbstractRefreshableConfigApplicationContext(@Nullable ApplicationContext parent)
      Create a new AbstractRefreshableConfigApplicationContext with the given parent context.
      Parameters:
      parent - the parent context
  • Method Details

    • setConfigLocation

      public void setConfigLocation(String location)
      Set the config locations for this application context in init-param style, i.e. with distinct locations separated by commas, semicolons or whitespace.

      If not set, the implementation may use a default as appropriate.

    • setConfigLocations

      public void setConfigLocations(@Nullable String... locations)
      Set the config locations for this application context.

      If not set, the implementation may use a default as appropriate.

    • getConfigLocations

      @Nullable protected String[] getConfigLocations()
      Return an array of resource locations, referring to the XML bean definition files that this context should be built with. Can also include location patterns, which will get resolved via a ResourcePatternResolver.

      The default implementation returns null. Subclasses can override this to provide a set of resource locations to load bean definitions from.

      Returns:
      an array of resource locations, or null if none
      See Also:
    • getDefaultConfigLocations

      @Nullable protected String[] getDefaultConfigLocations()
      Return the default config locations to use, for the case where no explicit config locations have been specified.

      The default implementation returns null, requiring explicit config locations.

      Returns:
      an array of default config locations, if any
      See Also:
    • resolvePath

      protected String resolvePath(String path)
      Resolve the given path, replacing placeholders with corresponding environment property values if necessary. Applied to config locations.
      Parameters:
      path - the original file path
      Returns:
      the resolved file path
      See Also:
      • PropertyResolver.resolveRequiredPlaceholders(String)
    • setId

      public void setId(String id)
      Description copied from class: AbstractApplicationContext
      Set the unique id of this application context.

      Default is the object id of the context instance, or the name of the context bean if the context is itself defined as a bean.

      Specified by:
      setId in interface ConfigurableApplicationContext
      Overrides:
      setId in class AbstractApplicationContext
      Parameters:
      id - the unique id of the context
    • setBeanName

      public void setBeanName(String name)
      Sets the id of this context to the bean name by default, for cases where the context instance is itself defined as a bean.
      Specified by:
      setBeanName in interface org.springframework.beans.factory.BeanNameAware
    • afterPropertiesSet

      public void afterPropertiesSet()
      Triggers AbstractApplicationContext.refresh() if not refreshed in the concrete context's constructor already.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean