Class XmlServletWebServerApplicationContext

All Implemented Interfaces:
Closeable, AutoCloseable, BeanFactory, HierarchicalBeanFactory, ListableBeanFactory, BeanDefinitionRegistry, ConfigurableWebServerApplicationContext, WebServerApplicationContext, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, AliasRegistry, EnvironmentCapable, ResourceLoader, ResourcePatternResolver, ThemeSource, ConfigurableWebApplicationContext, WebApplicationContext

public class XmlServletWebServerApplicationContext extends ServletWebServerApplicationContext
ServletWebServerApplicationContext which takes its configuration from XML documents, understood by an XmlBeanDefinitionReader.

Note: In case of multiple config locations, later bean definitions will override ones defined in earlier loaded files. This can be leveraged to deliberately override certain bean definitions through an extra XML file.

Since:
1.0.0
Author:
Phillip Webb
See Also:
  • Constructor Details

    • XmlServletWebServerApplicationContext

      public XmlServletWebServerApplicationContext()
      Create a new XmlServletWebServerApplicationContext that needs to be loaded and then manually refreshed.
    • XmlServletWebServerApplicationContext

      public XmlServletWebServerApplicationContext(Resource... resources)
      Create a new XmlServletWebServerApplicationContext, loading bean definitions from the given resources and automatically refreshing the context.
      Parameters:
      resources - the resources to load from
    • XmlServletWebServerApplicationContext

      public XmlServletWebServerApplicationContext(String... resourceLocations)
      Create a new XmlServletWebServerApplicationContext, loading bean definitions from the given resource locations and automatically refreshing the context.
      Parameters:
      resourceLocations - the resources to load from
    • XmlServletWebServerApplicationContext

      public XmlServletWebServerApplicationContext(Class<?> relativeClass, String... resourceNames)
      Create a new XmlServletWebServerApplicationContext, loading bean definitions from the given resource locations and automatically refreshing the context.
      Parameters:
      relativeClass - class whose package will be used as a prefix when loading each specified resource name
      resourceNames - relatively-qualified names of resources to load
  • Method Details

    • setValidating

      public void setValidating(boolean validating)
      Set whether to use XML validation. Default is true.
      Parameters:
      validating - if validating the XML
    • setEnvironment

      public void setEnvironment(ConfigurableEnvironment environment)

      Delegates the given environment to underlying XmlBeanDefinitionReader. Should be called before any call to load(org.springframework.core.io.Resource...).

      Specified by:
      setEnvironment in interface ConfigurableApplicationContext
      Overrides:
      setEnvironment in class AbstractApplicationContext
    • load

      public final void load(Resource... resources)
      Load bean definitions from the given XML resources.
      Parameters:
      resources - one or more resources to load from
    • load

      public final void load(String... resourceLocations)
      Load bean definitions from the given XML resources.
      Parameters:
      resourceLocations - one or more resource locations to load from
    • load

      public final void load(Class<?> relativeClass, String... resourceNames)
      Load bean definitions from the given XML resources.
      Parameters:
      relativeClass - class whose package will be used as a prefix when loading each specified resource name
      resourceNames - relatively-qualified names of resources to load