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.
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.
| Constructor: |
public ClassPathXmlApplicationContext() {
}
Create a new ClassPathXmlApplicationContext for bean-style configuration. |
public ClassPathXmlApplicationContext(ApplicationContext parent) {
super(parent);
}
Create a new ClassPathXmlApplicationContext for bean-style configuration. |
public ClassPathXmlApplicationContext(String configLocation) throws BeansException {
this(new String[] {configLocation}, true, null);
}
Create a new ClassPathXmlApplicationContext, loading the definitions
from the given XML file and automatically refreshing the context. Parameters:
configLocation - resource location
Throws:
BeansException - if context creation failed
|
public ClassPathXmlApplicationContext(String[] configLocations) throws BeansException {
this(configLocations, true, null);
}
Create a new ClassPathXmlApplicationContext, loading the definitions
from the given XML files and automatically refreshing the context. Parameters:
configLocations - array of resource locations
Throws:
BeansException - if context creation failed
|
public ClassPathXmlApplicationContext(String[] configLocations,
ApplicationContext parent) throws BeansException {
this(configLocations, true, parent);
}
Create a new ClassPathXmlApplicationContext with the given parent,
loading the definitions from the given XML files and automatically
refreshing the context. Parameters:
configLocations - array of resource locations
parent - the parent context
Throws:
BeansException - if context creation failed
|
public ClassPathXmlApplicationContext(String[] configLocations,
boolean refresh) throws BeansException {
this(configLocations, refresh, null);
}
Create a new ClassPathXmlApplicationContext, loading the definitions
from the given XML files. Parameters:
configLocations - array of resource locations
refresh - whether to automatically refresh the context,
loading all bean definitions and creating all singletons.
Alternatively, call refresh manually after further configuring the context.
Throws:
BeansException - if context creation failed
Also see:
- refresh()
|
public ClassPathXmlApplicationContext(String path,
Class clazz) throws BeansException {
this(new String[] {path}, clazz);
}
Create a new ClassPathXmlApplicationContext, loading the definitions
from the given XML file and automatically refreshing the context.
This is a convenience method to load class path resources relative to a
given Class. For full flexibility, consider using a GenericApplicationContext
with an XmlBeanDefinitionReader and a ClassPathResource argument. |
public ClassPathXmlApplicationContext(String[] paths,
Class clazz) throws BeansException {
this(paths, clazz, null);
}
Create a new ClassPathXmlApplicationContext, loading the definitions
from the given XML files and automatically refreshing the context. |
public ClassPathXmlApplicationContext(String[] configLocations,
boolean refresh,
ApplicationContext parent) throws BeansException {
super(parent);
setConfigLocations(configLocations);
if (refresh) {
refresh();
}
}
Create a new ClassPathXmlApplicationContext with the given parent,
loading the definitions from the given XML files. Parameters:
configLocations - array of resource locations
refresh - whether to automatically refresh the context,
loading all bean definitions and creating all singletons.
Alternatively, call refresh manually after further configuring the context.
parent - the parent context
Throws:
BeansException - if context creation failed
Also see:
- refresh()
|
public ClassPathXmlApplicationContext(String[] paths,
Class clazz,
ApplicationContext parent) throws BeansException {
super(parent);
Assert.notNull(paths, "Path array must not be null");
Assert.notNull(clazz, "Class argument must not be null");
this.configResources = new Resource[paths.length];
for (int i = 0; i < paths.length; i++) {
this.configResources[i] = new ClassPathResource(paths[i], clazz);
}
refresh();
}
Create a new ClassPathXmlApplicationContext with the given parent,
loading the definitions from the given XML files and automatically
refreshing the context. |