ResolvedFeature includeFeature(ResolvedFeatureId id, ResolvedFeatureSpec spec, Map<String, Object> resolvedParams, Map<ResolvedFeatureId, FeatureDependencySpec> resolvedDeps) throws ProvisioningException { if(id != null) { final ResolvedFeature feature = features.get(id); if(feature != null) { feature.merge(resolvedDeps, resolvedParams, true); return feature; } } final ResolvedFeature feature = new ResolvedFeature(id, spec, resolvedParams, resolvedDeps, ++featureIncludeCount); addFeature(feature); return feature; }
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; }
void addFeature(ResolvedFeature feature) throws ProvisioningDescriptionException { if(feature.id == null) { addToSpecFeatures(feature); return; } features.put(feature.id, feature); if (lastFg == 0) { addToSpecFeatures(feature); } }
private ResolvedConfig(ConfigModelStack configStack) throws ProvisioningException { this.id = configStack.id; this.props = CollectionUtils.unmodifiable(configStack.props); this.configDeps = CollectionUtils.unmodifiable(configStack.configDeps); this.features = CollectionUtils.unmodifiable(configStack.orderFeatures(true)); layers = Collections.unmodifiableList(configStack.getIncludedLayers()); }
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); } }
private void orderConfig(ConfigModelStack config, List<ProvisionedConfig> configList, Set<ConfigId> scheduledIds) throws ProvisioningException { if(!config.hasConfigDeps()) { configList.add(ResolvedConfig.build(config)); return; scheduledIds = CollectionUtils.add(scheduledIds, config.id); for(ConfigId depId : config.getConfigDeps().values()) { if(scheduledIds.contains(depId) || contains(configList, depId)) { continue;
if(config != null) { if(modelOnlyStack == null) { modelOnlyStack = new ConfigModelStack(configId, this); modelOnlyStack.pushConfig(config); ++pushedCount; if(config != null) { if(modelOnlyStack == null) { modelOnlyStack = new ConfigModelStack(configId, this); modelOnlyStack.pushConfig(config); ++pushedCount; if (config != null) { if(modelOnlyStack == null) { modelOnlyStack = new ConfigModelStack(configId, this); modelOnlyStack.pushConfig(config); ++pushedCount;
configStack = nameOnlyConfigs.get(id.getName()); if(configStack == null) { configStack = new ConfigModelStack(id, this); nameOnlyConfigs = CollectionUtils.putLinked(nameOnlyConfigs, id.getName(), configStack); configStack = new ConfigModelStack(id, this); namedConfigs = Collections.singletonMap(id.getName(), configStack); namedModelConfigs = CollectionUtils.putLinked(namedModelConfigs, id.getModel(), namedConfigs); configStack = new ConfigModelStack(id, this); namedConfigs.put(id.getName(), configStack); return configStack;
private void addToSpecFeatures(final ResolvedFeature feature) { getSpecFeatures(feature.spec).add(feature); }
private ConfigModelStack resolveConfigLayer(ConfigId layerId) throws ProvisioningException { ConfigModelStack layerStack = layers.get(layerId); if(layerStack == null) { layerStack = new ConfigModelStack(layerId, this); for (FeaturePackConfig fpConfig : config.getFeaturePackDeps()) { resolveConfigLayer(layout.getFeaturePack(fpConfig.getLocation().getProducer()), layerStack, layerId); } layers = CollectionUtils.put(layers, layerId, layerStack); } return layerStack; }
specFeatures = getSpecFeatures(otherSpecFeatures.spec); features.put(feature.id, feature); if(specFeatures == null) { specFeatures = getSpecFeatures(otherSpecFeatures.spec);
private void mergeFgScope() throws ProvisioningException { if(lastFg <= 0) { return; } final Map<ResolvedFeatureId, ResolvedFeature> endedGroup = fgFeatures.get(lastFg--); final Map<ResolvedFeatureId, ResolvedFeature> parentGroup = fgFeatures.get(lastFg); for (Map.Entry<ResolvedFeatureId, ResolvedFeature> entry : endedGroup.entrySet()) { final ResolvedFeature parentFeature = parentGroup.get(entry.getKey()); if (parentFeature == null) { parentGroup.put(entry.getKey(), entry.getValue()); if (lastFg == 0) { addToSpecFeatures(entry.getValue()); } } else { parentFeature.merge(entry.getValue(), true); } } endedGroup.clear(); features = parentGroup; }