connectExternalRequired no validates.
[utils] / system / general / src / main / java / org / wamblee / system / container / Container.java
index 9ef2ae18d817a0e35f8fda0c20c525a29d08775e..e4466d4a3f5b972f6aab3d96c2e6bd510faf0013 100644 (file)
@@ -160,7 +160,24 @@ public class Container extends AbstractComponent<Scope> {
     public void connectExternalRequired(String aComponent, String aRequiredInterface, 
             String aExternalRequiredInterface) {
         checkSealed();
-        // TODO validate
+        Component client = findComponent(aComponent);
+        if ( client == null ) { 
+               throw new SystemAssemblyException(getQualifiedName() + ": No component '" + aComponent + "' in the container");
+        }
+        if ( aRequiredInterface != null ) { 
+               if ( findInterface(client.getRequiredInterfaces(), aRequiredInterface) == null ) { 
+                       throw new SystemAssemblyException(
+                                       getQualifiedName() + ": Component '" + aComponent + "' does not have a required interface named '" 
+                                       + aRequiredInterface + "'");
+               }
+        }
+        if ( aExternalRequiredInterface != null) { 
+               if ( findInterface(getRequiredInterfaces(), aExternalRequiredInterface) == null ) { 
+                       throw new SystemAssemblyException(
+                                       getQualifiedName() + ": container does not have a required interface named '" 
+                                       + aExternalRequiredInterface + "'");
+               }
+        }
         _edgeFilter.add(new ConnectRequiredExternallyRequiredEdgeFilter(
                 aComponent, aRequiredInterface, aExternalRequiredInterface));
     }