aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1339162 - /aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
Date Wed, 16 May 2012 13:41:23 GMT
Author: jwross
Date: Wed May 16 13:41:23 2012
New Revision: 1339162

URL: http://svn.apache.org/viewvc?rev=1339162&view=rev
Log:
ARIES-825: Fixed issue where the installable/shared content/dependencies data structures weren't
being populated when the deployment manifest was provided.

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java?rev=1339162&r1=1339161&r2=1339162&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
Wed May 16 13:41:23 2012
@@ -48,6 +48,8 @@ public class SubsystemResource implement
 		this.parent = parent;
 		this.resource = resource;
 		preferredProviderRepository = new PreferredProviderRepository(this);
+		computeContentResources();
+		computeDependencies();
 		deploymentManifest = computeDeploymentManifest();
 	}
 
@@ -163,15 +165,10 @@ public class SubsystemResource implement
 				to.add(c);
 	}
 	
-	private DeploymentManifest computeExistingDeploymentManifest() throws IOException {
-		return resource.getDeploymentManifest();
-	}
-	
-	private DeployedContentHeader computeDeployedContentHeader() {
-		Collection<Resource> resources = new HashSet<Resource>();
+	private void computeContentResources() {
 		SubsystemContentHeader contentHeader = resource.getSubsystemManifest().getSubsystemContentHeader();
 		if (contentHeader == null)
-			return null;
+			return;
 		for (SubsystemContentHeader.Content content : contentHeader.getContents()) {
 			OsgiIdentityRequirement requirement = new OsgiIdentityRequirement(
 					content.getName(), content.getVersionRange(),
@@ -182,10 +179,28 @@ public class SubsystemResource implement
 					throw new SubsystemException("Resource does not exist: "+ requirement);
 				continue;
 			}
-			resources.add(resource);
 			addContentResource(resource);
 		}
-		return DeployedContentHeader.newInstance(resources);
+	}
+	
+	private void computeDependencies() {
+		SubsystemContentHeader contentHeader = resource.getSubsystemManifest().getSubsystemContentHeader();
+		try {
+			Map<Resource, List<Wire>> resolution = Activator.getInstance().getResolver().resolve(createResolveContext());
+			for (Resource resource : resolution.keySet())
+				if (!contentHeader.contains(resource))
+					addDependency(resource);
+		}
+		catch (ResolutionException e) {
+			throw new SubsystemException(e);
+		}
+	}
+	
+	private DeployedContentHeader computeDeployedContentHeader() {
+		Collection<Resource> content = getContentResources();
+		if (content.isEmpty())
+			return null;
+		return DeployedContentHeader.newInstance(content);
 	}
 	
 	private DeploymentManifest computeDeploymentManifest() throws IOException {
@@ -198,26 +213,15 @@ public class SubsystemResource implement
 		return result;
 	}
 	
+	private DeploymentManifest computeExistingDeploymentManifest() throws IOException {
+		return resource.getDeploymentManifest();
+	}
+	
 	private ProvisionResourceHeader computeProvisionResourceHeader() {
-		SubsystemContentHeader contentHeader = resource.getSubsystemManifest().getSubsystemContentHeader();
-		// TODO This does not validate that all content bundles were found.
-		Map<Resource, List<Wire>> resolution;
-		try {
-			resolution = Activator.getInstance().getResolver().resolve(createResolveContext());
-		}
-		catch (ResolutionException e) {
-			throw new SubsystemException(e);
-		}
-		Collection<Resource> provisionResource = new HashSet<Resource>();
-		for (Resource resource : resolution.keySet()) {
-			if (!contentHeader.contains(resource)) {
-				provisionResource.add(resource);
-				addDependency(resource);
-			}
-		}
-		if (provisionResource.isEmpty())
+		Collection<Resource> dependencies = getDepedencies();
+		if (dependencies.isEmpty())
 			return null;
-		return ProvisionResourceHeader.newInstance(provisionResource);
+		return ProvisionResourceHeader.newInstance(dependencies);
 	}
 	
 	private ResolveContext createResolveContext() {
@@ -300,6 +304,20 @@ public class SubsystemResource implement
 		return subsystem;
 	}
 	
+	private Collection<Resource> getContentResources() {
+		Collection<Resource> result = new ArrayList<Resource>(installableContent.size()
+ sharedContent.size());
+		result.addAll(installableContent);
+		result.addAll(sharedContent);
+		return result;
+	}
+	
+	private Collection<Resource> getDepedencies() {
+		Collection<Resource> result = new ArrayList<Resource>(installableDependencies.size()
+ sharedDependencies.size());
+		result.addAll(installableDependencies);
+		result.addAll(sharedDependencies);
+		return result;
+	}
+	
 	private boolean isAcceptDependencies(AriesSubsystem subsystem) {
 		return subsystem.getArchive().getSubsystemManifest().getSubsystemTypeHeader().getProvisionPolicyDirective().isAcceptDependencies();
 	}



Mime
View raw message