use of com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.
the class CloudStackSpringContext method getConfigLocationsForWeb.
public String[] getConfigLocationsForWeb(final String name, String[] configured) {
if (configured == null) {
configured = new String[] {};
}
ModuleDefinition def = getModuleDefinitionForWeb(name);
final List<Resource> inherited = new ArrayList<>();
while (def != null) {
inherited.addAll(def.getInheritableContextLocations());
def = moduleDefinitionSet.getModuleDefinition(def.getParentName());
}
final List<String> urlList = new ArrayList<>();
for (final Resource r : inherited) {
try {
final String urlString = r.getURL().toExternalForm();
urlList.add(urlString);
} catch (final 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 com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.
the class ModuleBasedContextFactory method loadModules.
public ModuleDefinitionSet loadModules(final Collection<ModuleDefinition> defs, final String root) throws IOException {
final Map<String, ModuleDefinition> modules = wireUpModules(root, defs);
final DefaultModuleDefinitionSet moduleSet = new DefaultModuleDefinitionSet(modules, root);
moduleSet.load();
return moduleSet;
}
use of com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.
the class ModuleBasedContextFactory method wireUpModules.
protected Map<String, ModuleDefinition> wireUpModules(final String root, final Collection<ModuleDefinition> defs) throws IOException {
final Map<String, ModuleDefinition> modules = new HashMap<>();
for (final ModuleDefinition def : defs) {
modules.put(def.getName(), def);
}
ModuleDefinition rootDef = null;
final Map<String, ModuleDefinition> result = new HashMap<>();
for (final ModuleDefinition def : modules.values()) {
if (def.getName().equals(root)) {
rootDef = def;
}
if (def.getParentName() != null) {
final ModuleDefinition parentDef = modules.get(def.getParentName());
if (parentDef != null) {
parentDef.addChild(def);
}
}
}
return traverse(rootDef, result);
}
use of com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.
the class ClasspathModuleDefinitionLocator method locateModules.
@Override
public Collection<ModuleDefinition> locateModules(final String context) throws IOException {
final ResourcePatternResolver resolver = getResolver();
final Map<String, ModuleDefinition> allModules = discoverModules(context, resolver);
return allModules.values();
}
use of com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.
the class ClasspathModuleDefinitionLocator method discoverModules.
protected Map<String, ModuleDefinition> discoverModules(final String baseDir, final ResourcePatternResolver resolver) throws IOException {
final Map<String, ModuleDefinition> result = new HashMap<>();
for (final Resource r : resolver.getResources(ModuleLocationUtils.getModulesLocation(baseDir))) {
final DefaultModuleDefinition def = new DefaultModuleDefinition(baseDir, r, resolver);
def.init();
if (def.isValid()) {
result.put(def.getName(), def);
}
}
return result;
}
Aggregations