use of org.apache.cloudstack.spring.module.model.ModuleDefinition in project cloudstack by apache.
the class DefaultModuleDefinitionSet method loadRootContext.
protected boolean loadRootContext() {
ModuleDefinition def = modules.get(root);
if (def == null)
return false;
ApplicationContext defaultsContext = getDefaultsContext();
rootContext = loadContext(def, defaultsContext);
return true;
}
use of org.apache.cloudstack.spring.module.model.ModuleDefinition in project cloudstack by apache.
the class DefaultModuleDefinitionSet method withModule.
protected void withModule(ModuleDefinition def, Stack<ModuleDefinition> parents, WithModule with) {
if (def == null)
return;
if (!shouldLoad(def)) {
log.info("Excluding context [{}] based on configuration", def.getName());
return;
}
with.with(def, parents);
parents.push(def);
for (ModuleDefinition child : def.getChildren()) {
withModule(child, parents, with);
}
parents.pop();
}
use of org.apache.cloudstack.spring.module.model.ModuleDefinition 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;
}
use of org.apache.cloudstack.spring.module.model.ModuleDefinition in project cloudstack by apache.
the class ModuleBasedContextFactory method loadModules.
public ModuleDefinitionSet loadModules(Collection<ModuleDefinition> defs, String root) throws IOException {
Map<String, ModuleDefinition> modules = wireUpModules(root, defs);
DefaultModuleDefinitionSet moduleSet = new DefaultModuleDefinitionSet(modules, root);
moduleSet.load();
return moduleSet;
}
use of org.apache.cloudstack.spring.module.model.ModuleDefinition in project cloudstack by apache.
the class ClasspathModuleDefinitionLocator method discoverModules.
protected Map<String, ModuleDefinition> discoverModules(String baseDir, ResourcePatternResolver resolver) throws IOException {
Map<String, ModuleDefinition> result = new HashMap<String, ModuleDefinition>();
for (Resource r : resolver.getResources(ModuleLocationUtils.getModulesLocation(baseDir))) {
DefaultModuleDefinition def = new DefaultModuleDefinition(baseDir, r, resolver);
def.init();
if (def.isValid())
result.put(def.getName(), def);
}
return result;
}
Aggregations