本文整理了Java中org.springframework.context.support.ClassPathXmlApplicationContext.setConfigLocations()
方法的一些代码示例,展示了ClassPathXmlApplicationContext.setConfigLocations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPathXmlApplicationContext.setConfigLocations()
方法的具体详情如下:
包路径:org.springframework.context.support.ClassPathXmlApplicationContext
类名称:ClassPathXmlApplicationContext
方法名:setConfigLocations
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Create a new ClassPathXmlApplicationContext with the given parent,
* loading the definitions from the given XML files.
* @param configLocations array of resource locations
* @param refresh whether to automatically refresh the context,
* loading all bean definitions and creating all singletons.
* Alternatively, call refresh manually after further configuring the context.
* @param parent the parent context
* @throws BeansException if context creation failed
* @see #refresh()
*/
public ClassPathXmlApplicationContext(
String[] configLocations, boolean refresh, @Nullable ApplicationContext parent)
throws BeansException {
super(parent);
setConfigLocations(configLocations);
if (refresh) {
refresh();
}
}
代码示例来源:origin: org.springframework/spring-context
/**
* Create a new ClassPathXmlApplicationContext with the given parent,
* loading the definitions from the given XML files.
* @param configLocations array of resource locations
* @param refresh whether to automatically refresh the context,
* loading all bean definitions and creating all singletons.
* Alternatively, call refresh manually after further configuring the context.
* @param parent the parent context
* @throws BeansException if context creation failed
* @see #refresh()
*/
public ClassPathXmlApplicationContext(
String[] configLocations, boolean refresh, @Nullable ApplicationContext parent)
throws BeansException {
super(parent);
setConfigLocations(configLocations);
if (refresh) {
refresh();
}
}
代码示例来源:origin: spring-projects/spring-integration
context.setConfigLocations(new String[]{"classpath:org/springframework/integration/channel/channel-override-config.xml"});
context.setParent(parentContext);
Method method = ReflectionUtils.findMethod(ClassPathXmlApplicationContext.class, "obtainFreshBeanFactory");
代码示例来源:origin: apache/servicemix-bundles
/**
* Create a new ClassPathXmlApplicationContext with the given parent,
* loading the definitions from the given XML files.
* @param configLocations array of resource locations
* @param refresh whether to automatically refresh the context,
* loading all bean definitions and creating all singletons.
* Alternatively, call refresh manually after further configuring the context.
* @param parent the parent context
* @throws BeansException if context creation failed
* @see #refresh()
*/
public ClassPathXmlApplicationContext(
String[] configLocations, boolean refresh, @Nullable ApplicationContext parent)
throws BeansException {
super(parent);
setConfigLocations(configLocations);
if (refresh) {
refresh();
}
}
代码示例来源:origin: NationalSecurityAgency/datawave
public static synchronized MarkingFunctions createMarkingFunctions() {
if (markingFunctions != null)
return markingFunctions;
ClassLoader thisClassLoader = MarkingFunctionsFactory.class.getClassLoader();
// ignore calls to close as this blows away the cache manager
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
try {
context.setClassLoader(thisClassLoader);
context.setConfigLocations("classpath*:/MarkingFunctionsContext.xml", "classpath*:/CacheContext.xml");
context.refresh();
markingFunctions = context.getBean("markingFunctions", MarkingFunctions.class);
} catch (Throwable t) {
log.warn("Could not load spring context files! Got " + t);
if (log.isDebugEnabled()) {
log.debug("Failed to load Spring contexts", t);
}
}
return markingFunctions;
}
代码示例来源:origin: NationalSecurityAgency/datawave
public static synchronized TypeMetadataProvider createTypeMetadataProvider() {
if (typeMetadataProvider != null)
return typeMetadataProvider;
ClassLoader thisClassLoader = TypeMetadataProvider.Factory.class.getClassLoader();
// ignore calls to close as this blows away the cache manager
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
try {
// To prevent failure when this is run on the tservers:
// The VFS ClassLoader has been created and has been made the current thread's context classloader, but its resource paths are empty at this
// time.
// The spring ApplicationContext will prefer the current thread's context classloader, so the spring context would fail to find
// any classes or context files to load.
// Instead, set the classloader on the ApplicationContext to be the one that is loading this class.
// It is a VFSClassLoader that has the accumulo lib/ext jars set as its resources.
// After setting the classloader, then set the config locations and refresh the context.
context.setClassLoader(thisClassLoader);
context.setConfigLocations("classpath:/TypeMetadataBridgeContext.xml", "classpath:/TypeMetadataProviderContext.xml");
context.refresh();
typeMetadataProvider = context.getBean("typeMetadataProvider", TypeMetadataProvider.class);
} catch (Throwable t) {
// got here because the VFSClassLoader on the tservers does not implement findResources
// none of the spring wiring will work.
log.warn("Could not load spring context files. got " + t);
}
return typeMetadataProvider;
}
}
代码示例来源:origin: NationalSecurityAgency/datawave
/**
* Initializes the internal field maps using the EdgeModelContext.xml config
*/
private void loadContext() {
String contextOverride = System.getProperty("edge.model.context.path");
if (null != contextOverride) {
FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(contextOverride);
loadMaps(context);
context.close();
} else {
ClassLoader thisClassLoader = EdgeModelAware.class.getClassLoader();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
try {
context.setClassLoader(thisClassLoader);
context.setConfigLocations(EDGE_MODEL_CONTEXT);
context.refresh();
loadMaps(context);
context.close();
} catch (Throwable t) {
log.fatal("Edge model configuration not loaded!! Edge queries will fail until this issue is corrected.");
log.fatal(String.format("Ensure that the Spring config file '%s' is on the classpath and contains bean names '%s', '%s', and '%s'",
EDGE_MODEL_CONTEXT, BASE_MODEL_BEAN, KEYUTIL_MODEL_BEAN, TRANSFORM_MODEL_BEAN), t);
}
}
}
代码示例来源:origin: googleads/aw-reporting
appCtx.setConfigLocations(listOfClassPathXml.toArray(new String[listOfClassPathXml.size()]));
appCtx.addBeanFactoryPostProcessor(configurer);
logger.warn("Updating database schema, this could take a few minutes ...");
内容来源于网络,如有侵权,请联系作者删除!