use of org.apache.cloudstack.spring.module.context.ResourceApplicationContext in project cloudstack by apache.
the class DefaultModuleDefinitionSet method loadContext.
protected ApplicationContext loadContext(ModuleDefinition def, ApplicationContext parent) {
ResourceApplicationContext context = new ResourceApplicationContext();
context.setApplicationName("/" + def.getName());
Resource[] resources = getConfigResources(def.getName());
context.setConfigResources(resources);
context.setParent(parent);
context.setClassLoader(def.getClassLoader());
long start = System.currentTimeMillis();
if (log.isInfoEnabled()) {
for (Resource resource : resources) {
log.info("Loading module context [{}] from {}", def.getName(), resource);
}
}
context.refresh();
log.info("Loaded module context [{}] in {} ms", def.getName(), (System.currentTimeMillis() - start));
contexts.put(def.getName(), context);
return context;
}
use of org.apache.cloudstack.spring.module.context.ResourceApplicationContext in project cloudstack by apache.
the class DefaultModuleDefinitionSet method getDefaultsContext.
protected ApplicationContext getDefaultsContext() {
URL config = DefaultModuleDefinitionSet.class.getResource(DEFAULT_CONFIG_XML);
ResourceApplicationContext context = new ResourceApplicationContext(new UrlResource(config));
context.setApplicationName("/defaults");
context.refresh();
@SuppressWarnings("unchecked") final List<Resource> resources = (List<Resource>) context.getBean(DEFAULT_CONFIG_RESOURCES);
withModule(new WithModule() {
@Override
public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
for (Resource defaults : def.getConfigLocations()) {
resources.add(defaults);
}
}
});
configProperties = (Properties) context.getBean(DEFAULT_CONFIG_PROPERTIES);
for (Resource resource : resources) {
load(resource, configProperties);
}
for (Resource resource : (Resource[]) context.getBean(MODULE_PROPERITES)) {
load(resource, configProperties);
}
parseExcludes();
return context;
}
Aggregations