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; }
void setBranch(ConfigFeatureBranch branch) throws ProvisioningException { this.branch = branch; if(branchDeps.size() > 1 || !branchDeps.containsKey(branch)) { final Iterator<ConfigFeatureBranch> iter = branchDeps.keySet().iterator(); while(iter.hasNext()) { final ConfigFeatureBranch branchDep = iter.next(); if(!branch.id.equals(branchDep.id)) { branch.addBranchDep(branchDep); } } } if(branchDependees != null) { for(ResolvedFeature branchDependee : branchDependees) { branchDependee.addBranchDep(branch, false); } branchDependees = null; } ordered(); }
void add(ResolvedFeature feature) { features = CollectionUtils.add(features, feature); feature.addCapabilityProviders(this); }
void merge(Map<ResolvedFeatureId, FeatureDependencySpec> deps, Map<String, Object> resolvedParams, boolean overwriteParams) throws ProvisioningException { if(!resolvedParams.isEmpty()) { for (Map.Entry<String, Object> entry : resolvedParams.entrySet()) { setParam(entry.getKey(), entry.getValue(), overwriteParams); } } if(!deps.isEmpty()) { for(Map.Entry<ResolvedFeatureId, FeatureDependencySpec> dep : deps.entrySet()) { addDependency(dep.getKey(), dep.getValue()); } } }
branchesByDeps.put(depsId, new ArrayList<>(branchFeatures)); if(branch.isBatch()) { branchFeatures.get(0).startBatch(); branchFeatures.get(branchFeatures.size() - 1).endBatch(); lastFeature.clearEndBranch(); final List<ResolvedFeature> branchFeatures = branch.getFeatures(); final ResolvedFeature firstFeature = branchFeatures.get(0); firstFeature.clearStartBranch(); if(branch.isBatch()) { if(lastFeature.isBatchEnd()) { lastFeature.clearBatchEnd(); firstFeature.clearBatchStart(); } else { firstFeature.startBatch(); branchFeatures.get(branchFeatures.size() - 1).endBatch();
if(features.size() == 1) { final ResolvedFeature feature = features.get(0); if(feature.isBatchStart()) { feature.clearBatchStart(); feature.clearBatchEnd(); if(independentBatchBranch.size() == 1) { final ResolvedFeature firstFeature = independentBatchBranch.get(0); firstFeature.clearBatchStart(); firstFeature.clearBatchEnd(); } else { independentBatchBranch.get(0).startBatch(); independentBatchBranch.get(independentBatchBranch.size() - 1).endBatch();
} else { final ResolvedFeature firstOnBranch = branch.getFeatures().get(0); firstOnBranch.clearStartBranch(); firstOnBranch.clearBatchStart(); ResolvedFeature lastOnBranch = independentBatchBranch.get(independentBatchBranch.size() - 1); lastOnBranch.clearEndBranch(); lastOnBranch.clearBatchEnd(); } else { final ResolvedFeature firstOnBranch = branch.getFeatures().get(0); firstOnBranch.clearStartBranch(); final ResolvedFeature lastOnBranch = independentNonBatchBranch.get(independentNonBatchBranch.size() - 1); lastOnBranch.clearEndBranch();
SpecFeatures specFeatures = null; for (ResolvedFeature feature : otherSpecFeatures.getFeatures()) { if(lastProcessedScope.isFilteredOut(feature.getSpecId(), feature.id)) { continue; feature = feature.copy(++featureIncludeCount); features.put(feature.id, feature); if(specFeatures == null) { localFeature.merge(feature, false);
feature.addBranchDep(dep.branch, refId.isChildRef()); } else { dep.addBranchDependee(feature);
void provided(ConfigFeatureBranch branch) { if(firstProvided != null) { branches = CollectionUtils.add(branches, branch); return; } firstProvided = branch; branches = Collections.singleton(branch); if (!branchDependees.isEmpty()) { for (ResolvedFeature branchDependee : branchDependees) { branchDependee.addBranchDep(branch, false); } branchDependees = Collections.emptyList(); } }
ResolvedFeature copy(int includeNo) throws ProvisioningException { final ResolvedFeature copy = new ResolvedFeature(id, spec, params.size() > 1 ? new HashMap<>(params) : params, deps.size() > 1 ? new LinkedHashMap<>(deps) : deps, includeNo); if(!resetParams.isEmpty()) { copy.resetParams = CollectionUtils.clone(resetParams); } if(!unsetParams.isEmpty()) { copy.unsetParams = CollectionUtils.clone(unsetParams); } return copy; }
private List<CircularRefInfo> orderCapabilityProviders(ResolvedFeature feature, List<CircularRefInfo> circularRefs) throws ProvisioningException { for (CapabilitySpec capSpec : feature.spec.xmlSpec.getRequiredCapabilities()) { final List<String> resolvedCaps = capResolver.resolve(capSpec, feature); if (resolvedCaps.isEmpty()) { continue; } for (String resolvedCap : resolvedCaps) { final CapabilityProviders providers; try { providers = getProviders(resolvedCap, false); } catch (ProvisioningException e) { throw new ProvisioningException(Errors.noCapabilityProvider(feature, capSpec, resolvedCap)); } circularRefs = CollectionUtils.addAll(circularRefs, orderProviders(providers)); if(providers.isProvided()) { feature.addBranchDep(providers.branches.iterator().next(), false); //System.out.println("added branch dep on cap provider " + feature.getId() + " -> " + providers.branches); } else { providers.addBranchDependee(feature); } } } return circularRefs; }