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;
}
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;
}
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);
}
}
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;
}
Aggregations