X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fgraph%2Fcomponent%2FComponentGraph.java;h=15f86557ab2a55dccdec85b2d8604d6b3bfcc07a;hb=901d0a5b61ed523b15124daf63a053f9c4a5fb4e;hp=20313b5983785b82d8b9d033a929a6fb3942e64f;hpb=6d4ac058c58d9c9b8f7649bdfb50cb27a61fe597;p=utils diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java b/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java index 20313b59..15f86557 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java @@ -33,26 +33,53 @@ import org.wamblee.system.graph.Node; // TODO info superfluous required interfaces // TODO check optional external required but mandatory internal. +/** + * Represents a component graph and provides the bridge from the + * component model to a graph model. The graph model is easier + * to work with to implement specific actions and validations than + * the component model. + */ public class ComponentGraph extends Graph { private CompositeInterfaceRestriction _restriction; + /** + * Constructs an empty component graph. + */ public ComponentGraph() { _restriction = new CompositeInterfaceRestriction(); } + /** + * Adds a restriction that must be satisfied by the component model. + * @param aRestriction Restriction. + */ public void addRestriction(InterfaceRestriction aRestriction) { _restriction.add(aRestriction); } + /** + * Adds an externally required interface of a container. + * This should be called before any components of the container are + * added. + * @param aInterface Required interface. + */ public void addRequiredInterface(RequiredInterface aInterface) { addNode(new ExternalRequiredInterfaceNode(aInterface)); } + /** + * Adds an externally provided interface of a container. + * This should be called after all components of the container have been added. + * @param aInterface Provided interface. + */ public void addProvidedInterface(ProvidedInterface aInterface) { addNode(new ExternalProvidedInterfaceNode(aInterface)); } + /** + * Validates the component graph. + */ public void validate() { extend(new RequiredProvidedEdgeFactory()); accept(new ApplyRestrictionsVisitor(this, _restriction)); @@ -62,6 +89,10 @@ public class ComponentGraph extends Graph { accept(new CheckStartupDependenciesVisitor(this)); } + /** + * Links provided and required interfaces together in the component + * model based on the graph model. + */ public void link() { accept(new LinkVisitor()); } @@ -86,6 +117,11 @@ public class ComponentGraph extends Graph { return result; } + /** + * Adds a component by adding required interfaces, components, and + * provided interfaces. + * @param aComponent Component to add. + */ public void addComponent(Component aComponent) { // Add required interfaces. Node compNode = new ComponentNode(aComponent);