FeatureNode feature = featureEntry.getValue(); for (String rawDep : feature.getRawDeps()) { if (!featureMap.containsKey(rawDep)) { problems.add("Feature [" + name + "] has dependency on unknown feature: " + rawDep); } else { feature.addDep(featureMap.get(rawDep)); theFeatures.add(feature); feature.completeNodeGraph(); } catch (GadgetException e) { problems.add(e.getMessage());
for (FeatureNode nextDep : next.one.getDepList()) { toTraverse.add(Pair.of(nextDep, Pair.of(next.two.one + 1, debug)));
List<FeatureNode> fullDeps = Lists.newLinkedList(); for (FeatureNode requestedFeature : requested) { for (FeatureNode toAdd : requestedFeature.getTransitiveDeps()) { if (!alreadySeen.contains(toAdd.name)) { alreadySeen.add(toAdd.name);
boolean specificContainerMatched = false; List<FeatureBundle> noContainerBundles = Lists.newLinkedList(); for (FeatureBundle bundle : entry.getBundles()) { if (bundle.getType().equals(targetBundleType)) { String containerAttrib = bundle.getAttribs().get("container");
boolean specificContainerMatched = false; List<FeatureBundle> noContainerBundles = Lists.newLinkedList(); for (FeatureBundle bundle : entry.getBundles()) { if (bundle.getType().equals(targetBundleType)) { String containerAttrib = bundle.getAttribs().get("container");
boolean specificContainerMatched = false; List<FeatureBundle> noContainerBundles = Lists.newLinkedList(); for (FeatureBundle bundle : entry.getBundles(ctx.getRenderingContext())) { String containerAttrib = bundle.getAttribs().get("container"); if (containerAttrib != null) {
new FeatureNode(parsed.getName(), bundles, parsed.getDeps()));
featureMapBuilder.put(parsed.getName(), new FeatureNode(parsed.getName(), bundles, parsed.getDeps()));
FeatureNode feature = featureEntry.getValue(); for (String rawDep : feature.getRawDeps()) { if (!featureMap.containsKey(rawDep)) { problems.add("Feature [" + name + "] has dependency on unknown feature: " + rawDep); } else { feature.addDep(featureMap.get(rawDep)); theFeatures.add(feature); feature.completeNodeGraph(); } catch (GadgetException e) { problems.add(e.getMessage());
featureMapBuilder.put(parsed.getName(), new FeatureNode(parsed.getName(), bundles, parsed.getDeps()));
List<FeatureNode> fullDeps = Lists.newLinkedList(); for (FeatureNode requestedFeature : requested) { for (FeatureNode toAdd : requestedFeature.getTransitiveDeps()) { if (!alreadySeen.contains(toAdd.name)) { alreadySeen.add(toAdd.name);
FeatureNode feature = featureEntry.getValue(); for (String rawDep : feature.getRawDeps()) { if (!featureMap.containsKey(rawDep)) { problems.add("Feature [" + name + "] has dependency on unknown feature: " + rawDep); } else { feature.addDep(featureMap.get(rawDep)); theFeatures.add(feature); feature.completeNodeGraph(); } catch (GadgetException e) { problems.add(e.getMessage());
List<FeatureNode> fullDeps = Lists.newLinkedList(); for (FeatureNode requestedFeature : requested) { for (FeatureNode toAdd : requestedFeature.getTransitiveDeps()) { if (!alreadySeen.contains(toAdd.name)) { alreadySeen.add(toAdd.name);
public void completeNodeGraph() throws GadgetException { if (!calculatedDepsStale) { return; } // Detect feature dependency loop Set<String> tempList = new HashSet<String>(); this.checkDependencyLoop(this, tempList); this.nodeDepth = 0; this.transitiveDeps = Lists.newLinkedList(); this.transitiveDeps.add(this); Queue<Pair<FeatureNode, Pair<Integer, String>>> toTraverse = Lists.newLinkedList(); toTraverse.add(Pair.of(this, Pair.of(0, ""))); while (!toTraverse.isEmpty()) { Pair<FeatureNode, Pair<Integer, String>> next = toTraverse.poll(); String debug = next.two.two + (next.two.one > 0 ? " -> " : "") + next.one.name; // Breadth-first list of dependencies. this.transitiveDeps.add(next.one); this.nodeDepth = Math.max(this.nodeDepth, next.two.one); for (FeatureNode nextDep : next.one.getDepList()) { toTraverse.add(Pair.of(nextDep, Pair.of(next.two.one + 1, debug))); } } Collections.reverse(this.transitiveDeps); calculatedDepsStale = false; }
/** * Check whether current feature node has dependency loop * @param featureNode * feature node which needs to check whether it has dependency loop. * @param dependencyList * used to check whether current branch of feature dependency tree has dependency loop or not. * @throws GadgetException * a new GadgetException will be thrown if a loop is detected. */ private void checkDependencyLoop(FeatureNode featureNode, Set<String> dependencyList) throws GadgetException { String featureNodeName = featureNode.name; if (dependencyList.contains(featureNodeName)) { // If dependencyList already contains this feature node, then current branch has dependency loop. throw new GadgetException(GadgetException.Code.INVALID_CONFIG, "Feature " + featureNodeName + " has dependency loop problem."); } // Add the current dependency into branch. dependencyList.add(featureNodeName); List<FeatureNode> deps = featureNode.getDepList(); for (FeatureNode f : deps) { checkDependencyLoop(f, dependencyList); // Remove the part which already has been verified. dependencyList.remove(f.name); } } }
for (FeatureNode nextDep : next.one.getDepList()) { toTraverse.add(Pair.of(nextDep, Pair.of(next.two.one + 1, debug)));