Top Description Fields Constructors Methods
org.springframework.context.support

public Class GenericXmlApplicationContext

extends GenericApplicationContext
Class Inheritance
Imports
org.springframework.beans.factory.xml.XmlBeanDefinitionReader, org.springframework.core.env.ConfigurableEnvironment, org.springframework.core.io.ClassPathResource, .Resource

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 intentionally override certain bean definitions via an extra configuration file appended to the list.

Authors
Juergen Hoeller, Chris Beams
Since
3.0
See Also
load, XmlBeanDefinitionReader, org.springframework.context.annotation.AnnotationConfigApplicationContext

Field Summary

Modifier and TypeField and Description
private final XmlBeanDefinitionReader

Constructor Summary

AccessConstructor and Description
public
GenericXmlApplicationContext()

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

public
GenericXmlApplicationContext(Resource...
the resources to load from
resources
)

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

public
GenericXmlApplicationContext(String...
the resources to load from
resourceLocations
)

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

public
GenericXmlApplicationContext(Class<?>
class whose package will be used as a prefix when loading each specified resource name
relativeClass
,
String...
relatively-qualified names of resources to load
resourceNames
)

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

Method Summary

Modifier and TypeMethod and Description
public final XmlBeanDefinitionReader
getReader()

Exposes the underlying XmlBeanDefinitionReader for additional configuration facilities and loadBeanDefinition variations.

public void
load(Resource...
one or more resources to load from
resources
)

Load bean definitions from the given XML resources.

public void
load(String...
one or more resource locations to load from
resourceLocations
)

Load bean definitions from the given XML resources.

public void
load(Class<?>
class whose package will be used as a prefix when loading each specified resource name
relativeClass
,
String...
relatively-qualified names of resources to load
resourceNames
)

Load bean definitions from the given XML resources.

public void
public void
setValidating(boolean validating)

Set whether to use XML validation.

Inherited from org.springframework.context.support.GenericApplicationContext:
cancelRefreshcloseBeanFactorygetAutowireCapableBeanFactorygetBeanDefinitiongetBeanFactorygetClassLoadergetDefaultListableBeanFactorygetResourcegetResourcesisAliasisBeanDefinitionOverridableisBeanNameInUserefreshBeanFactoryrefreshForAotProcessingregisterAliasregisterBeanregisterBeanregisterBeanregisterBeanregisterBeanregisterBeanregisterBeanDefinitionremoveAliasremoveBeanDefinitionsetAllowBeanDefinitionOverridingsetAllowCircularReferencessetApplicationStartupsetClassLoadersetParentsetResourceLoader

Field Detail

readerback to summary
private final XmlBeanDefinitionReader reader

Constructor Detail

GenericXmlApplicationContextback to summary
public GenericXmlApplicationContext()

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

GenericXmlApplicationContextback to summary
public GenericXmlApplicationContext(Resource... resources)

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

Parameters
resources:Resource[]

the resources to load from

GenericXmlApplicationContextback to summary
public GenericXmlApplicationContext(String... resourceLocations)

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

Parameters
resourceLocations:String[]

the resources to load from

GenericXmlApplicationContextback to summary
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<?>

class whose package will be used as a prefix when loading each specified resource name

resourceNames:String[]

relatively-qualified names of resources to load

Method Detail

getReaderback to summary
public final XmlBeanDefinitionReader getReader()

Exposes the underlying XmlBeanDefinitionReader for additional configuration facilities and loadBeanDefinition variations.

loadback to summary
public void load(Resource... resources)

Load bean definitions from the given XML resources.

Parameters
resources:Resource[]

one or more resources to load from

loadback to summary
public void load(String... resourceLocations)

Load bean definitions from the given XML resources.

Parameters
resourceLocations:String[]

one or more resource locations to load from

loadback to summary
public void load(Class<?> relativeClass, String... resourceNames)

Load bean definitions from the given XML resources.

Parameters
relativeClass:Class<?>

class whose package will be used as a prefix when loading each specified resource name

resourceNames:String[]

relatively-qualified names of resources to load

setEnvironmentback to summary
public void setEnvironment(ConfigurableEnvironment environment)

Overrides org.springframework.context.support.AbstractApplicationContext.setEnvironment.

Implements org.springframework.context.ConfigurableApplicationContext.setEnvironment.

Delegates the given environment to underlying XmlBeanDefinitionReader. Should be called before any call to #load.

Parameters
environment:ConfigurableEnvironment

Doc from org.springframework.context.ConfigurableApplicationContext.setEnvironment.

the new environment

Annotations
@Override
setValidatingback to summary
public void setValidating(boolean validating)

Set whether to use XML validation. Default is true.