Search in sources :

Example 1 with ConfigLayerDependency

use of org.jboss.galleon.spec.ConfigLayerDependency in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method popLayer.

private FeatureGroupSupport popLayer(ConfigModelStack layerStack) throws ProvisioningException {
    final FeatureGroupSupport fg = layerStack.peekAtGroup();
    if (!(fg instanceof ConfigLayerSpec)) {
        throw new ProvisioningException("Expected config layer but got " + fg);
    }
    final ConfigLayerSpec layer = (ConfigLayerSpec) fg;
    if (layer.hasLayerDeps()) {
        for (ConfigLayerDependency dep : layer.getLayerDeps()) {
            layerStack.addLayerDep(dep);
        }
    }
    layerStack.popGroup();
    return fg;
}
Also used : FeatureGroupSupport(org.jboss.galleon.config.FeatureGroupSupport) ProvisioningException(org.jboss.galleon.ProvisioningException) ConfigLayerSpec(org.jboss.galleon.spec.ConfigLayerSpec) ConfigLayerDependency(org.jboss.galleon.spec.ConfigLayerDependency)

Example 2 with ConfigLayerDependency

use of org.jboss.galleon.spec.ConfigLayerDependency in project galleon by wildfly.

the class LayersConfigBuilder method getAllLayers.

private static Map<String, Map<String, Set<String>>> getAllLayers(ProvisioningLayout<FeaturePackLayout> pLayout, boolean includeDependencies) throws ProvisioningException, IOException {
    Map<String, Map<String, Set<String>>> layersMap = new HashMap<>();
    for (FeaturePackLayout fp : pLayout.getOrderedFeaturePacks()) {
        for (ConfigId layer : fp.loadLayers()) {
            String model = layer.getModel();
            Map<String, Set<String>> names = layersMap.get(model);
            if (names == null) {
                names = new HashMap<>();
                layersMap.put(model, names);
            }
            Set<String> dependencies = new TreeSet<>();
            if (includeDependencies) {
                ConfigLayerSpec spec = fp.loadConfigLayerSpec(model, layer.getName());
                for (ConfigLayerDependency dep : spec.getLayerDeps()) {
                    dependencies.add(dep.getName());
                }
            }
            // Case where a layer is redefined in multiple FP. Add all deps.
            Set<String> existingDependencies = names.get(layer.getName());
            if (existingDependencies != null) {
                existingDependencies.addAll(dependencies);
                dependencies = existingDependencies;
            }
            names.put(layer.getName(), dependencies);
        }
    }
    return layersMap;
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ConfigLayerSpec(org.jboss.galleon.spec.ConfigLayerSpec) ConfigLayerDependency(org.jboss.galleon.spec.ConfigLayerDependency) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) TreeSet(java.util.TreeSet) ConfigId(org.jboss.galleon.config.ConfigId) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ConfigLayerDependency

use of org.jboss.galleon.spec.ConfigLayerDependency in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method includeLayer.

private void includeLayer(ConfigModelStack configStack, ConfigId layerId) throws ProvisioningException {
    if (!configStack.addLayer(layerId)) {
        return;
    }
    final ConfigModelStack layerStack = resolveConfigLayer(layerId);
    if (layerStack.hasLayerDeps()) {
        for (ConfigLayerDependency layerDep : layerStack.getLayerDeps()) {
            if (configStack.isLayerExcluded(layerDep.getName())) {
                if (layerDep.isOptional()) {
                    continue;
                }
                throw new ProvisioningException(Errors.unsatisfiedLayerDependency(layerId.getName(), layerDep.getName()));
            }
            includeLayer(configStack, new ConfigId(configStack.id.getModel(), layerDep.getName()));
        }
    }
    configStack.includedLayer(layerId);
    for (ResolvedFeature feature : layerStack.orderFeatures(false)) {
        if (configStack.isFilteredOut(feature.getSpecId(), feature.getId())) {
            continue;
        }
        configStack.includeFeature(feature.id, feature.spec, feature.params, feature.deps, feature.unsetParams, feature.resetParams);
    }
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) ConfigLayerDependency(org.jboss.galleon.spec.ConfigLayerDependency) ConfigId(org.jboss.galleon.config.ConfigId)

Example 4 with ConfigLayerDependency

use of org.jboss.galleon.spec.ConfigLayerDependency in project galleon by wildfly.

the class ConfigLayerXmlWriter method toElement.

protected ElementNode toElement(ConfigLayerSpec layer, String ns) {
    final ElementNode configE = addElement(null, Element.LAYER_SPEC.getLocalName(), ns);
    addAttribute(configE, Attribute.NAME, layer.getName());
    if (layer.hasLayerDeps()) {
        final ElementNode layers = addElement(configE, Element.DEPENDENCIES.getLocalName(), ns);
        for (ConfigLayerDependency layerDep : layer.getLayerDeps()) {
            final ElementNode layerE = addElement(layers, Element.LAYER.getLocalName(), ns);
            addAttribute(layerE, Attribute.NAME, layerDep.getName());
            if (layerDep.isOptional()) {
                addAttribute(layerE, Attribute.OPTIONAL, "true");
            }
        }
    }
    FeatureGroupXmlWriter.addFeatureGroupDepBody(layer, configE, ns);
    return configE;
}
Also used : ConfigLayerDependency(org.jboss.galleon.spec.ConfigLayerDependency) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Aggregations

ConfigLayerDependency (org.jboss.galleon.spec.ConfigLayerDependency)4 ProvisioningException (org.jboss.galleon.ProvisioningException)2 ConfigId (org.jboss.galleon.config.ConfigId)2 ConfigLayerSpec (org.jboss.galleon.spec.ConfigLayerSpec)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 FeatureGroupSupport (org.jboss.galleon.config.FeatureGroupSupport)1 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)1 ElementNode (org.jboss.galleon.xml.util.ElementNode)1