// 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));
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());
}
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);