Search in sources :

Example 1 with ModuleDefinition

use of com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.

the class DefaultModuleDefinitionSet method withModule.

protected void withModule(final WithModule with) {
    final ModuleDefinition rootDef = modules.get(root);
    withModule(rootDef, new Stack<>(), with);
}
Also used : ModuleDefinition(com.cloud.spring.module.model.ModuleDefinition)

Example 2 with ModuleDefinition

use of com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.

the class DefaultModuleDefinitionSet method withModule.

protected void withModule(final ModuleDefinition def, final Stack<ModuleDefinition> parents, final 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 (final ModuleDefinition child : def.getChildren()) {
        withModule(child, parents, with);
    }
    parents.pop();
}
Also used : ModuleDefinition(com.cloud.spring.module.model.ModuleDefinition)

Example 3 with ModuleDefinition

use of com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.

the class CloudStackSpringContext method getModuleDefinitionForWeb.

public ModuleDefinition getModuleDefinitionForWeb(final 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;
}
Also used : ModuleDefinition(com.cloud.spring.module.model.ModuleDefinition)

Example 4 with ModuleDefinition

use of com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.

the class DefaultModuleDefinitionSet method getConfigResources.

@Override
public Resource[] getConfigResources(final String name) {
    final Set<Resource> resources = new LinkedHashSet<>();
    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()]);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ModuleDefinition(com.cloud.spring.module.model.ModuleDefinition) UrlResource(org.springframework.core.io.UrlResource) Resource(org.springframework.core.io.Resource)

Example 5 with ModuleDefinition

use of com.cloud.spring.module.model.ModuleDefinition in project cosmic by MissionCriticalCloud.

the class DefaultModuleDefinitionSet method loadRootContext.

protected boolean loadRootContext() {
    final ModuleDefinition def = modules.get(root);
    if (def == null) {
        return false;
    }
    final ApplicationContext defaultsContext = getDefaultsContext();
    rootContext = loadContext(def, defaultsContext);
    return true;
}
Also used : ModuleDefinition(com.cloud.spring.module.model.ModuleDefinition) ResourceApplicationContext(com.cloud.spring.module.context.ResourceApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext)

Aggregations

ModuleDefinition (com.cloud.spring.module.model.ModuleDefinition)10 Resource (org.springframework.core.io.Resource)3 DefaultModuleDefinition (com.cloud.spring.module.model.impl.DefaultModuleDefinition)2 HashMap (java.util.HashMap)2 ResourceApplicationContext (com.cloud.spring.module.context.ResourceApplicationContext)1 DefaultModuleDefinitionSet (com.cloud.spring.module.model.impl.DefaultModuleDefinitionSet)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 ApplicationContext (org.springframework.context.ApplicationContext)1 UrlResource (org.springframework.core.io.UrlResource)1 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1 ResourcePatternResolver (org.springframework.core.io.support.ResourcePatternResolver)1