spring-framework / org.springframework.context.support / AbstractXmlApplicationContext

AbstractXmlApplicationContext

abstract class AbstractXmlApplicationContext : AbstractRefreshableConfigApplicationContext

Convenient base class for org.springframework.context.ApplicationContext implementations, drawing configuration from XML documents containing bean definitions understood by an org.springframework.beans.factory.xml.XmlBeanDefinitionReader.

Subclasses just have to implement the #getConfigResources and/or the #getConfigLocations method. Furthermore, they might override the #getResourceByPath hook to interpret relative paths in an environment-specific fashion, and/or #getResourcePatternResolver for extended pattern resolution.

Author
Rod Johnson

Author
Juergen Hoeller

See Also
#getConfigResources#getConfigLocationsorg.springframework.beans.factory.xml.XmlBeanDefinitionReader

Constructors

<init>

AbstractXmlApplicationContext()

Create a new AbstractXmlApplicationContext with no parent.

AbstractXmlApplicationContext(parent: ApplicationContext)

Create a new AbstractXmlApplicationContext with the given parent context.

Functions

setValidating

open fun setValidating(validating: Boolean): Unit

Set whether to use XML validation. Default is true.

Inheritors

ClassPathXmlApplicationContext

open class ClassPathXmlApplicationContext : AbstractXmlApplicationContext

Standalone XML application context, taking the context definition files from the class path, interpreting plain paths as class path resource names that include the package path (e.g. "mypackage/myresource.txt"). Useful for test harnesses as well as for application contexts embedded within JARs.

The config location defaults can be overridden via #getConfigLocations, Config locations can either denote concrete files like "/myfiles/context.xml" or Ant-style patterns like "/myfiles/*-context.xml" (see the org.springframework.util.AntPathMatcher javadoc for pattern details).

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 via an extra XML file.

This is a simple, one-stop shop convenience ApplicationContext. Consider using the GenericApplicationContext class in combination with an org.springframework.beans.factory.xml.XmlBeanDefinitionReader for more flexible context setup.

FileSystemXmlApplicationContext

open class FileSystemXmlApplicationContext : AbstractXmlApplicationContext

Standalone XML application context, taking the context definition files from the file system or from URLs, interpreting plain paths as relative file system locations (e.g. "mydir/myfile.txt"). Useful for test harnesses as well as for standalone environments.

NOTE: Plain paths will always be interpreted as relative to the current VM working directory, even if they start with a slash. (This is consistent with the semantics in a Servlet container.) Use an explicit "file:" prefix to enforce an absolute file path.

The config location defaults can be overridden via #getConfigLocations, Config locations can either denote concrete files like "/myfiles/context.xml" or Ant-style patterns like "/myfiles/*-context.xml" (see the org.springframework.util.AntPathMatcher javadoc for pattern details).

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 via an extra XML file.

This is a simple, one-stop shop convenience ApplicationContext. Consider using the GenericApplicationContext class in combination with an org.springframework.beans.factory.xml.XmlBeanDefinitionReader for more flexible context setup.