From c93fd9abab341c2537b526b4a10b9f65962022c0 Mon Sep 17 00:00:00 2001 From: erik Date: Sun, 20 Apr 2008 22:19:41 +0000 Subject: [PATCH] --- .../org/wamblee/system/core/Container.java | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/system/general/src/main/java/org/wamblee/system/core/Container.java b/system/general/src/main/java/org/wamblee/system/core/Container.java index b44ca94f..1eaebf43 100644 --- a/system/general/src/main/java/org/wamblee/system/core/Container.java +++ b/system/general/src/main/java/org/wamblee/system/core/Container.java @@ -133,30 +133,25 @@ public class Container extends AbstractComponent { * in case of any validation problems. */ public void validate() { - List provided = new ArrayList(); - for (Component component : _components) { - provided.addAll(Arrays.asList(component.getProvidedInterfaces())); - } + validateProvidedInterfacesArePresent(); + + validateRequiredInterfaces(); + doStartOptionalDryRun(null, true); + } + + private void validateRequiredInterfaces() { List required = new ArrayList(); for (Component component : _components) { required.addAll(Arrays.asList(component.getRequiredInterfaces())); } - validateProvidedInterfacesArePresent(provided); - - validateRequiredInterfaces(required); - - doStartOptionalDryRun(null, true); - } - - private void validateRequiredInterfaces(List 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 { // 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 { } } - private void validateProvidedInterfacesArePresent( - List aProvided) { + private void validateProvidedInterfacesArePresent() { + List provided = new ArrayList(); + 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"); -- 2.31.1