(no commit message)
[utils] / system / general / src / main / java / org / wamblee / system / container / Container.java
index e4466d4a3f5b972f6aab3d96c2e6bd510faf0013..9669cb216dd65a28e0f75670e3f0a9d106b2efb0 100644 (file)
@@ -17,9 +17,7 @@ package org.wamblee.system.container;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -184,7 +182,26 @@ public class Container extends AbstractComponent<Scope> {
     
     public void connectExternalProvided(String aExternalProvided, String aComponent, String aProvidedInterface) {
         checkSealed();
-        // TODO validate
+        Component server = findComponent(aComponent);
+       
+      
+        if ( server == null ) { 
+               throw new SystemAssemblyException("No component '" + aComponent + "' in the container");
+        }
+        if ( aProvidedInterface != null ) { 
+               if ( findInterface(server.getProvidedInterfaces(), aProvidedInterface) == null) { 
+                       throw new SystemAssemblyException(
+                                       getQualifiedName() + ": Component '" + aComponent + "' does not have a provided interface named '" 
+                                       + aProvidedInterface + "'");
+               }
+        }
+        if ( aExternalProvided != null ) { 
+               if ( findInterface(getProvidedInterfaces(), aExternalProvided) == null) { 
+                       throw new SystemAssemblyException(
+                                       getQualifiedName() + ": Container does not have a provided interface named '" 
+                                       + aExternalProvided + "'");
+               }
+        }
         _edgeFilter.add(new ConnectExternalProvidedProvidedFilter(aExternalProvided, aComponent, aProvidedInterface));
     }
 
@@ -254,7 +271,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);
@@ -275,9 +291,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() + "'");