public class

GenericXmlApplicationContext

extends GenericApplicationContext
java.lang.Object
   ↳ org.springframework.core.io.DefaultResourceLoader
     ↳ org.springframework.context.support.AbstractApplicationContext
       ↳ org.springframework.context.support.GenericApplicationContext
         ↳ org.springframework.context.support.GenericXmlApplicationContext

Class Overview

Convenient application context with built-in XML support. This is a flexible alternative to ClassPathXmlApplicationContext and FileSystemXmlApplicationContext, to be configured via setters, with an eventual refresh() call activating the context.

In case of multiple configuration files, bean definitions in later files will override those defined in earlier files. This can be leveraged to deliberately override certain bean definitions via an extra configuration file.

Summary

[Expand]
Inherited Constants
From class org.springframework.context.support.AbstractApplicationContext
From interface org.springframework.beans.factory.BeanFactory
From interface org.springframework.context.ConfigurableApplicationContext
From interface org.springframework.core.io.ResourceLoader
From interface org.springframework.core.io.support.ResourcePatternResolver
[Expand]
Inherited Fields
From class org.springframework.context.support.AbstractApplicationContext
Public Constructors
GenericXmlApplicationContext()
Create a new GenericXmlApplicationContext that needs to be loaded and then manually refreshed.
GenericXmlApplicationContext(Resource... resources)
Create a new GenericXmlApplicationContext, loading bean definitions from the given resources and automatically refreshing the context.
GenericXmlApplicationContext(String... resourceLocations)
Create a new GenericXmlApplicationContext, loading bean definitions from the given resource locations and automatically refreshing the context.
GenericXmlApplicationContext(Class<?> relativeClass, String... resourceNames)
Create a new GenericXmlApplicationContext, loading bean definitions from the given resource locations and automatically refreshing the context.
Public Methods
void load(Resource... resources)
Load bean definitions from the given XML resources.
void load(Class<?> relativeClass, String... resourceNames)
Load bean definitions from the given XML resources.
void load(String... resourceLocations)
Load bean definitions from the given XML resources.
void setEnvironment(ConfigurableEnvironment environment)
Set the Environment for this application context.

Default value is determined by createEnvironment().

Delegates the given environment to underlying XmlBeanDefinitionReader.

void setValidating(boolean validating)
Set whether to use XML validation.
[Expand]
Inherited Methods
From class org.springframework.context.support.GenericApplicationContext
From class org.springframework.context.support.AbstractApplicationContext
From class org.springframework.core.io.DefaultResourceLoader
From class java.lang.Object
From interface org.springframework.beans.factory.BeanFactory
From interface org.springframework.beans.factory.DisposableBean
From interface org.springframework.beans.factory.HierarchicalBeanFactory
From interface org.springframework.beans.factory.ListableBeanFactory
From interface org.springframework.beans.factory.support.BeanDefinitionRegistry
From interface org.springframework.context.ApplicationContext
From interface org.springframework.context.ApplicationEventPublisher
From interface org.springframework.context.ConfigurableApplicationContext
From interface org.springframework.context.Lifecycle
From interface org.springframework.context.MessageSource
From interface org.springframework.core.AliasRegistry
From interface org.springframework.core.env.EnvironmentCapable
From interface org.springframework.core.io.ResourceLoader
From interface org.springframework.core.io.support.ResourcePatternResolver

Public Constructors

public GenericXmlApplicationContext ()

Create a new GenericXmlApplicationContext that needs to be loaded and then manually refreshed.

public GenericXmlApplicationContext (Resource... resources)

Create a new GenericXmlApplicationContext, loading bean definitions from the given resources and automatically refreshing the context.

Parameters
resources the resources to load from

public GenericXmlApplicationContext (String... resourceLocations)

Create a new GenericXmlApplicationContext, loading bean definitions from the given resource locations and automatically refreshing the context.

Parameters
resourceLocations the resources to load from

public GenericXmlApplicationContext (Class<?> relativeClass, String... resourceNames)

Create a new GenericXmlApplicationContext, 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

Public Methods

public void load (Resource... resources)

Load bean definitions from the given XML resources.

Parameters
resources one or more resources to load from

public 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

public void load (String... resourceLocations)

Load bean definitions from the given XML resources.

Parameters
resourceLocations one or more resource locations to load from

public void setEnvironment (ConfigurableEnvironment environment)

Set the Environment for this application context.

Default value is determined by createEnvironment(). Replacing the default with this method is one option but configuration through getEnvironment() should also be considered. In either case, such modifications should be performed before refresh().

Delegates the given environment to underlying XmlBeanDefinitionReader. Should be called before any call to load(Class, String...).

Parameters
environment the new environment

public void setValidating (boolean validating)

Set whether to use XML validation. Default is true.