now linking required and provided interfaces only once.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Thu, 12 Nov 2009 21:12:47 +0000 (21:12 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Thu, 12 Nov 2009 21:12:47 +0000 (21:12 +0000)
trunk/system/general/src/main/java/org/wamblee/system/container/Container.java
trunk/system/general/src/main/java/org/wamblee/system/core/Scope.java
trunk/system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java

index d86ec1ceaa42ded130612eb9c4d8ae46ccbd8c99..3dfda5cf041459e65dcb2d41c60d85eeedbb39b0 100644 (file)
@@ -273,7 +273,6 @@ public class Container extends AbstractComponent<Scope> {
 
     @Override
     protected Scope doStart(Scope aExternalScope) {
-        checkSealed();
         validate();
         Scope scope = new DefaultScope(getProvidedInterfaces().toArray(new ProvidedInterface[0]), aExternalScope);
         ComponentGraph graph = doStartOptionalDryRun(scope, false);
@@ -294,9 +293,7 @@ public class Container extends AbstractComponent<Scope> {
     private ComponentGraph doStartOptionalDryRun(Scope aScope, boolean aDryRun) {
         ComponentGraph graph = createComponentGraph();
         graph.validate();
-        if (!aDryRun) {
-            graph.link();
-        }
+        graph.link();
 
         LOG.info("Starting '" + getQualifiedName() + "'");
 
index 1b9f66154597e7aaa190a77f5acc3c58dbf0414c..fe83e85709c8083526dbc81873836815a85ec066 100644 (file)
@@ -55,7 +55,6 @@ public interface Scope {
        
        /**
         * Publishes an implementation of a provided interface. 
-        * @param aComponent Component that provides the interface.
         * @param aInterface Interface that is provided.
         * @param aImplementation Implementation of the interface.  
         */
index 008f0026c1127750598fcde2c5f5b296f299951c..b41c41c81445d277165fed2eb7f44414b224d944 100644 (file)
@@ -36,12 +36,14 @@ import org.wamblee.system.graph.Node;
  */
 public class ComponentGraph extends Graph {
     
+    private boolean _isLinked; 
     private CompositeEdgeFilter _edgeFilter; 
 
     /**
      * Constructs an empty component graph. 
      */
     public ComponentGraph() {
+        _isLinked = false; 
         _edgeFilter = new CompositeEdgeFilter(); 
     }
     
@@ -82,8 +84,12 @@ public class ComponentGraph extends Graph {
      * Links provided and required interfaces together in the component
      * model based on the graph model. 
      */
-    public void link() { 
+    public void link() {
+        if ( _isLinked ) { 
+            return; 
+        }
         accept(new LinkVisitor());
+        _isLinked = true; 
     }
     
     /**