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

index 8e98755b5e7b02b8d8c33c2243150fac045660a5..b44ca94f9b8512a0fdd3d30092bc314d1a32f567 100644 (file)
@@ -147,24 +147,7 @@ public class Container extends AbstractComponent<Scope> {
 
         validateRequiredInterfaces(required);
 
-        addProvidersOfRequiredInterfaces(provided);
-        validateRequiredProvidedMatch(provided, required);
-    }
-
-    /**
-     * 
-     * @param aProvided
-     *            All provided interfaces.
-     * @param aRequired
-     *            All required interfaces.
-     * @return
-     */
-    private void validateRequiredProvidedMatch(
-            List<ProvidedInterface> aProvided, List<RequiredInterface> aRequired) {
-
-        for (Component component : _components) {
-            initializeProvidersForRequiredInterfaces(aProvided, component, true);
-        }
+        doStartOptionalDryRun(null, true);
     }
 
     private void validateRequiredInterfaces(List<RequiredInterface> aRequired) {
@@ -246,6 +229,10 @@ public class Container extends AbstractComponent<Scope> {
 
     @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<Scope> {
         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<Scope> {
         // 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());