aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tjwat...@apache.org
Subject svn commit: r1694702 - in /aries/trunk/subsystem: subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AutostartTest.java
Date Fri, 07 Aug 2015 15:37:18 GMT
Author: tjwatson
Date: Fri Aug  7 15:37:18 2015
New Revision: 1694702

URL: http://svn.apache.org/r1694702
Log:
ARIES-1348 - subsystems that are dependencies are not auto started

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AutostartTest.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java?rev=1694702&r1=1694701&r2=1694702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java
Fri Aug  7 15:37:18 2015
@@ -96,7 +96,7 @@ public class StartAction extends Abstrac
 			return null;
 		// Always start if target is content of requestor.
 		if (!Utils.isContent(requestor, target)) {
-			// Aways start if target is a dependency of requestor.
+			// Always start if target is a dependency of requestor.
 			if (!Utils.isDependency(requestor, target)) {
 				// Always start if instigator equals target (explicit start).
 				if (!instigator.equals(target)) {
@@ -170,8 +170,19 @@ public class StartAction extends Abstrac
 			// root subsystem should have no effect, so there's no point in
 			// actually doing the resolution work.
 			if (!subsystem.isRoot()) {
-				for (Subsystem child : Activator.getInstance().getSubsystems().getChildren(subsystem))
+				//resolve dependencies to ensure framework resolution succeeds
+				for (Resource dep : Activator.getInstance().getSubsystems().getResourcesReferencedBy(subsystem))
{
+					if (dep instanceof BasicSubsystem &&
+						!Activator.getInstance().getSubsystems().getChildren(subsystem).contains(dep)) {
+						if (State.INSTALLED == (((BasicSubsystem) dep).getState())) {
+						    resolve((BasicSubsystem) dep);
+						}
+					}
+				}
+				
+				for (Subsystem child : Activator.getInstance().getSubsystems().getChildren(subsystem))
{
 					resolve((BasicSubsystem)child);
+				}
 
 				FrameworkWiring frameworkWiring = Activator.getInstance().getBundleContext().getBundle(0)
 						.adapt(FrameworkWiring.class);

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AutostartTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AutostartTest.java?rev=1694702&r1=1694701&r2=1694702&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AutostartTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AutostartTest.java
Fri Aug  7 15:37:18 2015
@@ -511,4 +511,30 @@ public class AutostartTest extends Subsy
 			stopAndUninstallSubsystemSilently(compositeA);
 		}
 	}
+
+	@Test
+	/* Start a composite with a dependency on an installed, but unresolved subsystem.
+	 * The unresolved dependency should be auto-resolved and started (test fix to
+	 *  bug ARIES-1348).
+	 *
+	 * composite b imports package exported by a bundle in composite.a.  
+	 *  - install composite a
+	 *  - install composite b
+	 *  - start composite b
+	 */  
+	public void testStartCompositeWithUnresolvedDependency() throws Exception {
+		Subsystem compositeA = installSubsystemFromFile(COMPOSITE_A);
+		Subsystem compositeB = installSubsystemFromFile(COMPOSITE_B);
+		try {
+			startSubsystem(compositeB);
+			// A should be automatically resolved and started.
+			assertState(Subsystem.State.ACTIVE, compositeA);
+		}
+		finally {
+			stopSubsystemSilently(compositeB);
+			stopSubsystemSilently(compositeA);
+			uninstallSubsystemSilently(compositeB);			
+			uninstallSubsystemSilently(compositeA);
+		}
+	}
 }



Mime
View raw message