From: erik Date: Sun, 20 Apr 2008 22:10:41 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.2@603~163 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=1d4e8028827abc9ae9eb86345c66b6c9603c7806;p=utils --- diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/Container.java b/trunk/system/general/src/main/java/org/wamblee/system/core/Container.java index 8e98755b..b44ca94f 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/core/Container.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/core/Container.java @@ -147,24 +147,7 @@ public class Container extends AbstractComponent { validateRequiredInterfaces(required); - addProvidersOfRequiredInterfaces(provided); - validateRequiredProvidedMatch(provided, required); - } - - /** - * - * @param aProvided - * All provided interfaces. - * @param aRequired - * All required interfaces. - * @return - */ - private void validateRequiredProvidedMatch( - List aProvided, List aRequired) { - - for (Component component : _components) { - initializeProvidersForRequiredInterfaces(aProvided, component, true); - } + doStartOptionalDryRun(null, true); } private void validateRequiredInterfaces(List aRequired) { @@ -246,6 +229,10 @@ public class Container extends AbstractComponent { @Override protected Scope doStart(Scope aExternalScope) { + return doStartOptionalDryRun(aExternalScope, false); + } + + private Scope doStartOptionalDryRun(Scope aExternalScope, boolean aDryRun) { LOG.info("Starting '" + getQualifiedName() + "'"); Scope scope = new DefaultScope(getProvidedInterfaces(), aExternalScope); @@ -258,12 +245,14 @@ public class Container extends AbstractComponent { for (Component component : _components) { try { initializeProvidersForRequiredInterfaces(allProvided, - component, false); + component, aDryRun); // Start the service. - Object runtime = component.start(scope); - scope.addRuntime(component, runtime); - started.add(component); + if (!aDryRun) { + Object runtime = component.start(scope); + scope.addRuntime(component, runtime); + started.add(component); + } // add all provided services ProvidedInterface[] provided = component @@ -306,7 +295,8 @@ public class Container extends AbstractComponent { // components for (int i = aStarted.size() - 1; i >= 0; i--) { try { - aStarted.get(i).stop(aScope); + Component component = aStarted.get(i); + aStarted.get(i).stop(aScope.getRuntime(component)); } catch (Throwable t) { LOG.error(getQualifiedName() + ": error stopping " + aStarted.get(i).getQualifiedName());