use of org.apache.cloudstack.spring.module.model.ModuleDefinition in project cloudstack by apache.
the class CloudStackSpringContext method getConfigLocationsForWeb.
public String[] getConfigLocationsForWeb(String name, String[] configured) {
if (configured == null)
configured = new String[] {};
ModuleDefinition def = getModuleDefinitionForWeb(name);
List<Resource> inherited = new ArrayList<Resource>();
while (def != null) {
inherited.addAll(def.getInheritableContextLocations());
def = moduleDefinitionSet.getModuleDefinition(def.getParentName());
}
List<String> urlList = new ArrayList<String>();
for (Resource r : inherited) {
try {
String urlString = r.getURL().toExternalForm();
urlList.add(urlString);
} catch (IOException e) {
log.error("Failed to create URL for " + r.getDescription(), e);
}
}
String[] result = new String[urlList.size() + configured.length];
result = urlList.toArray(result);
System.arraycopy(configured, 0, result, urlList.size(), configured.length);
return result;
}
use of org.apache.cloudstack.spring.module.model.ModuleDefinition in project cloudstack by apache.
the class CloudStackSpringContext method getModuleDefinitionForWeb.
public ModuleDefinition getModuleDefinitionForWeb(String name) {
ModuleDefinition def = moduleDefinitionSet.getModuleDefinition(name);
if (def != null) {
return def;
}
/* Grab farthest descendant that is deterministic */
def = moduleDefinitionSet.getModuleDefinition(baseName);
if (def == null) {
throw new RuntimeException("Failed to find base spring module to extend for web");
}
while (def.getChildren().size() == 1) {
def = def.getChildren().iterator().next();
}
return def;
}
use of org.apache.cloudstack.spring.module.model.ModuleDefinition in project cloudstack by apache.
the class DefaultModuleDefinitionSet method getConfigResources.
@Override
public Resource[] getConfigResources(String name) {
Set<Resource> resources = new LinkedHashSet<Resource>();
ModuleDefinition original = null;
ModuleDefinition def = original = modules.get(name);
if (def == null)
return new Resource[] {};
resources.addAll(def.getContextLocations());
while (def != null) {
resources.addAll(def.getInheritableContextLocations());
def = modules.get(def.getParentName());
}
resources.addAll(original.getOverrideContextLocations());
return resources.toArray(new Resource[resources.size()]);
}
use of org.apache.cloudstack.spring.module.model.ModuleDefinition in project cloudstack by apache.
the class DefaultModuleDefinitionSet method withModule.
protected void withModule(WithModule with) {
ModuleDefinition rootDef = modules.get(root);
withModule(rootDef, new Stack<ModuleDefinition>(), with);
}
use of org.apache.cloudstack.spring.module.model.ModuleDefinition in project cloudstack by apache.
the class ModuleBasedContextFactory method wireUpModules.
protected Map<String, ModuleDefinition> wireUpModules(String root, Collection<ModuleDefinition> defs) throws IOException {
Map<String, ModuleDefinition> modules = new HashMap<String, ModuleDefinition>();
for (ModuleDefinition def : defs) {
modules.put(def.getName(), def);
}
ModuleDefinition rootDef = null;
Map<String, ModuleDefinition> result = new HashMap<String, ModuleDefinition>();
for (ModuleDefinition def : modules.values()) {
if (def.getName().equals(root)) {
rootDef = def;
}
if (def.getParentName() != null) {
ModuleDefinition parentDef = modules.get(def.getParentName());
if (parentDef != null)
parentDef.addChild(def);
}
}
return traverse(rootDef, result);
}
Aggregations