aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1300170 - in /aries/trunk/subsystem: subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/
Date Tue, 13 Mar 2012 14:59:41 GMT
Author: jwross
Date: Tue Mar 13 14:59:40 2012
New Revision: 1300170

URL: http://svn.apache.org/viewvc?rev=1300170&view=rev
Log:
ARIES-825: Update subsystems to latest Subsystem, Resolver, and Repository APIs.

(1) Deleted unused SubsystemBundleListener class.
(2) Refactored subsystem identifier management into its own class.
(3) Bundle resources are now started according to their activation policy as well as transiently.

Added:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemIdentifier.java
Removed:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemBundleListener.java
Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemManifestValidator.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java?rev=1300170&r1=1300169&r2=1300170&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
Tue Mar 13 14:59:40 2012
@@ -108,8 +108,6 @@ public class AriesSubsystem implements S
 	private static final Map<String, AriesSubsystem> locationToSubsystem = Collections.synchronizedMap(new
HashMap<String, AriesSubsystem>());
 	private static final Map<Resource, Set<AriesSubsystem>> resourceToSubsystems
= Collections.synchronizedMap(new HashMap<Resource, Set<AriesSubsystem>>());
 	
-	private static long lastId;
-	
 	static synchronized Collection<AriesSubsystem> getSubsystems(Resource resource) {
 		// If the provided resource is null, all subsystems are desired.
 		if (resource == null)
@@ -237,12 +235,6 @@ public class AriesSubsystem implements S
 		}
 	}
 	
-	private synchronized static long getNextId() {
-		if (Long.MAX_VALUE == lastId)
-			throw new IllegalStateException("The next subsystem ID would exceed Long.MAX_VALUE: "
+ lastId);
-		return ++lastId;
-	}
-	
 	private final SubsystemArchive archive;
 	private final Set<Resource> constituents = Collections.synchronizedSet(new HashSet<Resource>());
 	private final File directory;
@@ -263,10 +255,12 @@ public class AriesSubsystem implements S
 		directory = Activator.getInstance().getBundleContext().getDataFile("");
 		archive = new SubsystemArchive(directory);
 		DeploymentManifest deploymentManifest = archive.getDeploymentManifest();
+		long lastId = 0;
 		if (deploymentManifest != null) {
 			autostart = Boolean.parseBoolean(deploymentManifest.getHeaders().get(DeploymentManifest.ARIESSUBSYSTEM_AUTOSTART).getValue());
 			id = Long.parseLong(deploymentManifest.getHeaders().get(DeploymentManifest.ARIESSUBSYSTEM_ID).getValue());
 			lastId = Long.parseLong(deploymentManifest.getHeaders().get(DeploymentManifest.ARIESSUBSYSTEM_LASTID).getValue());
+			SubsystemIdentifier.setLastId(lastId);
 			location = deploymentManifest.getHeaders().get(DeploymentManifest.ARIESSUBSYSTEM_LOCATION).getValue();
 		}
 		else {
@@ -329,7 +323,7 @@ public class AriesSubsystem implements S
 			
 		}
 		this.location = location;
-		id = getNextId();
+		id = SubsystemIdentifier.getNextId();
 		String directoryName = "subsystem" + id;
 		// TODO Add to constants.
 		String fileName = directoryName + ".esa";
@@ -701,7 +695,7 @@ public class AriesSubsystem implements S
 				null,
 				autostart,
 				id,
-				lastId,
+				SubsystemIdentifier.getLastId(),
 				location,
 				false,
 				false);
@@ -775,7 +769,7 @@ public class AriesSubsystem implements S
 					environment,
 					autostart,
 					id,
-					lastId,
+					SubsystemIdentifier.getLastId(),
 					location,
 					true,
 					false));
@@ -1184,7 +1178,7 @@ public class AriesSubsystem implements S
 		final Bundle bundle = ((BundleRevision)resource).getBundle();
 		if ((bundle.getState() & (Bundle.STARTING | Bundle.ACTIVE)) != 0)
 			return;
-		bundle.start(Bundle.START_TRANSIENT);
+		bundle.start(Bundle.START_TRANSIENT | Bundle.START_ACTIVATION_POLICY);
 		if (coordination == null)
 			return;
 		coordination.addParticipant(new Participant() {

Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemIdentifier.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemIdentifier.java?rev=1300170&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemIdentifier.java
(added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemIdentifier.java
Tue Mar 13 14:59:40 2012
@@ -0,0 +1,20 @@
+package org.apache.aries.subsystem.core.internal;
+
+public class SubsystemIdentifier {
+	private static long lastId;
+	
+	synchronized static long getLastId() {
+		return lastId;
+	}
+	
+	synchronized static long getNextId() {
+		if (Long.MAX_VALUE == lastId)
+			throw new IllegalStateException("The next subsystem ID would exceed Long.MAX_VALUE: "
+ lastId);
+		// First ID will be 1.
+		return ++lastId;
+	}
+	
+	synchronized static void setLastId(long id) {
+		lastId = id;
+	}
+}

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemManifestValidator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemManifestValidator.java?rev=1300170&r1=1300169&r2=1300170&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemManifestValidator.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemManifestValidator.java
Tue Mar 13 14:59:40 2012
@@ -12,6 +12,7 @@ public class SubsystemManifestValidator 
 			if (header == null)
 				return;
 			for (SubsystemContentHeader.Content content : header.getContents()) {
+				// TODO Need to update this to use the new VersionRange.isExact() method, which is more
robust.
 				if (!isExactVersion(content.getVersionRange()))
 					throw new SubsystemException("Composite subsystem using version range for content: "
+ content);
 			}

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java?rev=1300170&r1=1300169&r2=1300170&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
Tue Mar 13 14:59:40 2012
@@ -41,6 +41,7 @@ import java.util.Map.Entry;
 import junit.framework.Assert;
 
 import org.apache.aries.subsystem.core.ResourceHelper;
+import org.apache.aries.subsystem.core.internal.SubsystemIdentifier;
 import org.apache.aries.subsystem.core.obr.felix.RepositoryAdminRepository;
 import org.apache.aries.subsystem.itests.util.RepositoryGenerator;
 import org.apache.aries.subsystem.itests.util.Utils;
@@ -318,9 +319,9 @@ public abstract class SubsystemTest exte
 	
 	protected void assertLastId(long id) throws SecurityException, NoSuchFieldException, IllegalArgumentException,
IllegalAccessException {
 		Subsystem root = getRootSubsystem();
-		Field lastId = root.getClass().getDeclaredField("lastId");
+		Field lastId = SubsystemIdentifier.class.getDeclaredField("lastId");
 		lastId.setAccessible(true);
-		assertEquals("Incorrect value for lastId", id, lastId.getLong(root));
+		assertEquals("Wrong lastId", id, lastId.getLong(root));
 	}
 	
 	protected void assertLocation(String expected, String actual) {



Mime
View raw message