From: Erik Brakkee Date: Sun, 20 Apr 2008 22:10:41 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.7~766 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=56f797f6f1b1465ea09106c223a5a9f218134159;p=utils --- 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 8e98755b..b44ca94f 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 @@ -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());