(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Sun, 20 Apr 2008 22:19:41 +0000 (22:19 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Sun, 20 Apr 2008 22:19:41 +0000 (22:19 +0000)
system/general/src/main/java/org/wamblee/system/core/Container.java

index b44ca94f9b8512a0fdd3d30092bc314d1a32f567..1eaebf432a0e1c239189e621e3d0a35b9275f1ed 100644 (file)
@@ -133,30 +133,25 @@ public class Container extends AbstractComponent<Scope> {
      *             in case of any validation problems.
      */
     public void validate() {
-        List<ProvidedInterface> provided = new ArrayList<ProvidedInterface>();
-        for (Component component : _components) {
-            provided.addAll(Arrays.asList(component.getProvidedInterfaces()));
-        }
+        validateProvidedInterfacesArePresent();
+
+        validateRequiredInterfaces();
 
+        doStartOptionalDryRun(null, true);
+    }
+
+    private void validateRequiredInterfaces() {
         List<RequiredInterface> required = new ArrayList<RequiredInterface>();
         for (Component component : _components) {
             required.addAll(Arrays.asList(component.getRequiredInterfaces()));
         }
 
-        validateProvidedInterfacesArePresent(provided);
-
-        validateRequiredInterfaces(required);
-
-        doStartOptionalDryRun(null, true);
-    }
-
-    private void validateRequiredInterfaces(List<RequiredInterface> aRequired) {
         for (RequiredInterface service : getRequiredInterfaces()) {
             // TODO required interfaces by the component could be
             // subclasses or implementations of the requirements
             // of the contained components. The code below assumes
             // an exact match.
-            if (!(aRequired.contains(service))) {
+            if (!(required.contains(service))) {
                 info("Service '"
                         + service
                         + "' indicated as required is not actually required by any of the components");
@@ -165,7 +160,7 @@ public class Container extends AbstractComponent<Scope> {
             // is optional whereas the internally required service is
             // mandatory.
             if (service.isOptional()) {
-                for (RequiredInterface intf : aRequired) {
+                for (RequiredInterface intf : required) {
                     if (intf.equals(service) && !intf.isOptional()) {
                         warn("Required service '"
                                 + service
@@ -180,14 +175,17 @@ public class Container extends AbstractComponent<Scope> {
         }
     }
 
-    private void validateProvidedInterfacesArePresent(
-            List<ProvidedInterface> aProvided) {
+    private void validateProvidedInterfacesArePresent() {
+        List<ProvidedInterface> provided = new ArrayList<ProvidedInterface>();
+        for (Component component : _components) {
+            provided.addAll(Arrays.asList(component.getProvidedInterfaces()));
+        }
         for (ProvidedInterface service : getProvidedInterfaces()) {
             // TODO provided interfaces by components could be
             // provide subclasses or implementations of the
             // provided interfaces of the container.
             // The code below assumes an exact match.
-            if (!(aProvided.contains(service))) {
+            if (!(provided.contains(service))) {
                 throw new SystemAssemblyException(getName() + ": Service '"
                         + service
                         + "' is not provided by any of its components");