aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1501275 - in /aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal: BundleResource.java BundleRevisionResource.java
Date Tue, 09 Jul 2013 14:03:31 GMT
Author: jwross
Date: Tue Jul  9 14:03:30 2013
New Revision: 1501275

URL: http://svn.apache.org/r1501275
Log:
[aries-952] Ask only what is required from the Application Modeller.

Previously, subsystems asked the modeller for the entire modelled resource. This resulted
in unneccessarily computing
non-service capabilities and requirements twice. Now, subsystems asks the modeller to compute
only the needed
service requirements and capabilities.

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

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java?rev=1501275&r1=1501274&r2=1501275&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
Tue Jul  9 14:03:30 2013
@@ -27,9 +27,9 @@ import java.util.jar.JarOutputStream;
 
 import org.apache.aries.application.modelling.ExportedService;
 import org.apache.aries.application.modelling.ImportedService;
-import org.apache.aries.application.modelling.ModelledResource;
 import org.apache.aries.application.modelling.ModelledResourceManager;
 import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.application.modelling.ParsedServiceElements;
 import org.apache.aries.subsystem.core.archive.BundleManifest;
 import org.apache.aries.subsystem.core.archive.BundleRequiredExecutionEnvironmentHeader;
 import org.apache.aries.subsystem.core.archive.BundleSymbolicNameHeader;
@@ -164,8 +164,7 @@ public class BundleResource implements R
 		capabilities.add(new OsgiIdentityCapability(this, manifest));
 	}
 	
-	private void computeOsgiServiceCapabilities(ModelledResource resource) {
-		Collection<? extends ExportedService> services = resource.getExportedServices();
+	private void computeOsgiServiceCapabilities(Collection<ExportedService> services)
{
 		for (ExportedService service : services)
 			capabilities.add(new BasicCapability.Builder()
 					.namespace(ServiceNamespace.SERVICE_NAMESPACE)
@@ -175,8 +174,7 @@ public class BundleResource implements R
 					.build());
 	}
 	
-	private void computeOsgiServiceRequirements(ModelledResource resource) {
-		Collection<? extends ImportedService> services = resource.getImportedServices();
+	private void computeOsgiServiceRequirements(Collection<ImportedService> services)
{
 		for (ImportedService service : services) {
 			StringBuilder builder = new StringBuilder("(&(")
 					.append(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE)
@@ -228,16 +226,18 @@ public class BundleResource implements R
 	}
 	
 	private void computeRequirementsAndCapabilities(IDirectory directory) throws ModellerException
{
+		// Compute all requirements and capabilities other than those related
+		// to services.
 		computeRequirementsOtherThanService();
 		computeCapabilitiesOtherThanService();
+		// Compute service requirements and capabilities if the optional
+		// ModelledResourceManager service is present.
 		ModelledResourceManager manager = getModelledResourceManager();
 		if (manager == null)
 			return;
-		// TODO Could use ModelledResourceManager.getServiceElements instead. 
-		// Only the service dependency info is being used right now.
-		ModelledResource resource = manager.getModelledResource(directory);
-		computeOsgiServiceRequirements(resource);
-		computeOsgiServiceCapabilities(resource);
+		ParsedServiceElements elements = manager.getServiceElements(directory);
+		computeOsgiServiceRequirements(elements.getReferences());
+		computeOsgiServiceCapabilities(elements.getServices());
 	}
 	
 	private void computeRequirementsOtherThanService() {

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleRevisionResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleRevisionResource.java?rev=1501275&r1=1501274&r2=1501275&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleRevisionResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleRevisionResource.java
Tue Jul  9 14:03:30 2013
@@ -20,9 +20,9 @@ import java.util.List;
 
 import org.apache.aries.application.modelling.ExportedService;
 import org.apache.aries.application.modelling.ImportedService;
-import org.apache.aries.application.modelling.ModelledResource;
 import org.apache.aries.application.modelling.ModelledResourceManager;
 import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.application.modelling.ParsedServiceElements;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.namespace.service.ServiceNamespace;
 import org.osgi.resource.Capability;
@@ -34,7 +34,7 @@ import org.osgi.service.subsystem.Subsys
 public class BundleRevisionResource implements Resource {
 	private final BundleRevision revision;
 	
-	private volatile ModelledResource resource;
+	private volatile ParsedServiceElements elements;
 	
 	public BundleRevisionResource(BundleRevision revision) {
 		if (revision == null)
@@ -72,14 +72,14 @@ public class BundleRevisionResource impl
 		return revision.getRequirements(namespace);
 	}
 	
-	private ModelledResource computeModelledResource() {
+	private ParsedServiceElements computeParsedServiceElements() {
 		Activator activator = Activator.getInstance();
 		ModelledResourceManager manager = activator.getModelledResourceManager();
 		if (manager == null)
 			return null;
 		BundleDirectory directory = new BundleDirectory(revision.getBundle());
 		try {
-			return manager.getModelledResource(directory);
+			return manager.getServiceElements(directory);
 		}
 		catch (ModellerException e) {
 			throw new SubsystemException(e);
@@ -87,10 +87,10 @@ public class BundleRevisionResource impl
 	}
 	
 	private List<Capability> computeServiceCapabilities() {
-		ModelledResource resource = getModelledResource();
-		if (resource == null)
+		ParsedServiceElements elements = getParsedServiceElements();
+		if (elements == null)
 			return Collections.emptyList();
-		Collection<? extends ExportedService> services = resource.getExportedServices();
+		Collection<? extends ExportedService> services = elements.getServices();
 		if (services.isEmpty())
 			return Collections.emptyList();
 		List<Capability> result = new ArrayList<Capability>(services.size());
@@ -105,10 +105,10 @@ public class BundleRevisionResource impl
 	}
 	
 	private List<Requirement> computeServiceRequirements() {
-		ModelledResource resource = getModelledResource();
-		if (resource == null)
+		ParsedServiceElements elements = getParsedServiceElements();
+		if (elements == null)
 			return Collections.emptyList();
-		Collection<? extends ImportedService> services = resource.getImportedServices();
+		Collection<? extends ImportedService> services = elements.getReferences();
 		if (services.isEmpty())
 			return Collections.emptyList();
 		List<Requirement> result = new ArrayList<Requirement>(services.size());
@@ -134,13 +134,13 @@ public class BundleRevisionResource impl
 		return result;
 	}
 
-	private ModelledResource getModelledResource() {
-		ModelledResource result = resource;
+	private ParsedServiceElements getParsedServiceElements() {
+		ParsedServiceElements result = elements;
 		if (result == null) {
 			synchronized (this) {
-				result = resource;
+				result = elements;
 				if (result == null)
-					resource = result = computeModelledResource();
+					elements = result = computeParsedServiceElements();
 			}
 		}
 		return result;



Mime
View raw message