aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1299925 - in /aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core: archive/ resource/
Date Mon, 12 Mar 2012 23:22:37 GMT
Author: jwross
Date: Mon Mar 12 23:22:36 2012
New Revision: 1299925

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

(1) Added support for osgi.wiring.bundle and generic capabilities in bundle content resources.
(2) Fixed an issue in ImportPackageHeader where the requirement filter was not generating
correctly for versions.
(3) Fixed an issue in VersionAttribute where the attribute value was a String and not a Version.

Added:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ProvideBundleCapability.java
Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionAttribute.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java?rev=1299925&r1=1299924&r2=1299925&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java
Mon Mar 12 23:22:36 2012
@@ -105,6 +105,10 @@ public class HeaderFactory {
 			return new ProvideCapabilityHeader(value);
 		if (SubsystemExportServiceHeader.NAME.equals(name))
 			return new SubsystemExportServiceHeader(value);
+		if (BundleSymbolicNameHeader.NAME.equals(name))
+			return new BundleSymbolicNameHeader(value);
+		if (BundleVersionHeader.NAME.equals(name))
+			return new BundleVersionHeader(value);
 		return new GenericHeader(name, value);
 			
 	}

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java?rev=1299925&r1=1299924&r2=1299925&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java
Mon Mar 12 23:22:36 2012
@@ -20,15 +20,12 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
 import org.osgi.framework.namespace.PackageNamespace;
-import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
 
@@ -148,45 +145,7 @@ public class ImportPackageHeader impleme
 		}
 		
 		public Requirement getRequirement(final Resource resource) {
-			return new Requirement() {
-				@Override
-				public String getNamespace() {
-					return BundleRevision.PACKAGE_NAMESPACE;
-				}
-				@Override
-				public Map<String, String> getDirectives() {
-					Collection<Directive> directives = Clause.this.getDirectives();
-					Map<String, String> result = new HashMap<String, String>(directives.size()
+ 1);
-					for (Directive directive : directives) {
-						result.put(directive.getName(), directive.getValue());
-					}
-					if (result.get(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE) == null) {
-						StringBuilder builder = new StringBuilder("(&");
-						for (Entry<String, Object> entry : getAttributes().entrySet())
-							builder.append('(').append(entry.getKey()).append('=').append(entry.getValue()).append(')');
-						result.put(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, builder.append(')').toString());
-					}
-					return result;
-				}
-				@Override
-				public Map<String, Object> getAttributes() {
-					Collection<Attribute> attributes = Clause.this.getAttributes();
-					Map<String, Object> result = new HashMap<String, Object>(attributes.size()
+ 1);
-					for (Attribute attribute : attributes) {
-						result.put(attribute.getName(), attribute.getValue());
-					}
-					if (result.get(PackageNamespace.PACKAGE_NAMESPACE) == null) {
-						result.put(PackageNamespace.PACKAGE_NAMESPACE, getPath());
-					}
-					if (result.get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE) == null)
-						result.put(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE, Version.emptyVersion.toString());
-					return result;
-				}
-				@Override
-				public Resource getResource() {
-					return resource;
-				}
-			};
+			return new ImportPackageRequirement(this, resource);
 		}
 		
 		public VersionRangeAttribute getVersionRangeAttribute() {

Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ProvideBundleCapability.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ProvideBundleCapability.java?rev=1299925&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ProvideBundleCapability.java
(added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ProvideBundleCapability.java
Mon Mar 12 23:22:36 2012
@@ -0,0 +1,77 @@
+package org.apache.aries.subsystem.core.archive;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.subsystem.core.resource.AbstractCapability;
+import org.osgi.framework.namespace.BundleNamespace;
+import org.osgi.resource.Resource;
+
+public class ProvideBundleCapability extends AbstractCapability {
+	public static final String ATTRIBUTE_BUNDLE_VERSION = BundleNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE;
+	public static final String DIRECTIVE_EFFECTIVE = BundleNamespace.CAPABILITY_EFFECTIVE_DIRECTIVE;
+	public static final String DIRECTIVE_FRAGMENT_ATTACHMENT = BundleNamespace.CAPABILITY_FRAGMENT_ATTACHMENT_DIRECTIVE;
+	public static final String DIRECTIVE_MANDATORY = BundleNamespace.CAPABILITY_MANDATORY_DIRECTIVE;
+	public static final String DIRECTIVE_SINGLETON = BundleNamespace.CAPABILITY_SINGLETON_DIRECTIVE;
+	public static final String DIRECTIVE_USES = BundleNamespace.CAPABILITY_USES_DIRECTIVE;
+	public static final String NAMESPACE = BundleNamespace.BUNDLE_NAMESPACE;
+	
+	private static Map<String, Object> initializeAttributes(BundleSymbolicNameHeader bsn,
BundleVersionHeader version) {
+		if (version == null) {
+			version = new BundleVersionHeader();
+		}
+		Clause clause = bsn.getClauses().get(0);
+		Collection<Attribute> attributes = clause.getAttributes();
+		Map<String, Object> result = new HashMap<String, Object>(attributes.size()
+ 2);
+		result.put(NAMESPACE, clause.getPath());
+		result.put(ATTRIBUTE_BUNDLE_VERSION, version.getValue());
+		for (Attribute attribute : attributes) {
+			result.put(attribute.getName(), attribute.getValue());
+		}
+		return Collections.unmodifiableMap(result);
+	}
+	
+	private static Map<String, String> initializeDirectives(Collection<Directive>
directives) {
+		if (directives.isEmpty())
+			return Collections.emptyMap();
+		Map<String, String> result = new HashMap<String, String>(directives.size());
+		for (Directive directive : directives) {
+			result.put(directive.getName(), directive.getValue());
+		}
+		return Collections.unmodifiableMap(result);
+	}
+	
+	private final Map<String, Object> attributes;
+	private final Map<String, String> directives;
+	private final Resource resource;
+	
+	public ProvideBundleCapability(BundleSymbolicNameHeader bsn, BundleVersionHeader version,
Resource resource) {
+		if (resource == null)
+			throw new NullPointerException("Missing required parameter: resource");
+		this.resource = resource;
+		attributes = initializeAttributes(bsn, version);
+		directives = initializeDirectives(bsn.getClauses().get(0).getDirectives());
+	}
+
+	@Override
+	public Map<String, Object> getAttributes() {
+		return attributes;
+	}
+
+	@Override
+	public Map<String, String> getDirectives() {
+		return directives;
+	}
+
+	@Override
+	public String getNamespace() {
+		return NAMESPACE;
+	}
+
+	@Override
+	public Resource getResource() {
+		return resource;
+	}
+}

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionAttribute.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionAttribute.java?rev=1299925&r1=1299924&r2=1299925&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionAttribute.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionAttribute.java
Mon Mar 12 23:22:36 2012
@@ -21,18 +21,15 @@ public class VersionAttribute extends Ab
 	
 	public static final VersionAttribute DEFAULT = new VersionAttribute();
 	
-	private final Version version;
-	
 	public VersionAttribute() {
 		this(Version.emptyVersion.toString());
 	}
 	
 	public VersionAttribute(String value) {
-		super(NAME, value);
-		version = Version.parseVersion(value);
+		super(NAME, Version.parseVersion(value));
 	}
 
 	public Version getVersion() {
-		return version;
+		return (Version)getValue();
 	}
 }

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java?rev=1299925&r1=1299924&r2=1299925&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java
Mon Mar 12 23:22:36 2012
@@ -22,8 +22,13 @@ import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 
 import org.apache.aries.subsystem.core.archive.BundleManifest;
+import org.apache.aries.subsystem.core.archive.BundleSymbolicNameHeader;
+import org.apache.aries.subsystem.core.archive.BundleVersionHeader;
 import org.apache.aries.subsystem.core.archive.ExportPackageHeader;
 import org.apache.aries.subsystem.core.archive.ImportPackageHeader;
+import org.apache.aries.subsystem.core.archive.ProvideBundleCapability;
+import org.apache.aries.subsystem.core.archive.ProvideCapabilityCapability;
+import org.apache.aries.subsystem.core.archive.ProvideCapabilityHeader;
 import org.apache.aries.subsystem.core.archive.RequireBundleHeader;
 import org.apache.aries.subsystem.core.archive.RequireBundleRequirement;
 import org.apache.aries.subsystem.core.archive.RequireCapabilityHeader;
@@ -75,6 +80,17 @@ public class BundleResource implements R
 		if (rbh != null)
 			for (RequireBundleHeader.Clause clause : rbh.getClauses())
 				requirements.add(new RequireBundleRequirement(clause));
+		// TODO The osgi.wiring.bundle capability should not be provided for fragments. Nor should
the host capability.
+		BundleSymbolicNameHeader bsnh = (BundleSymbolicNameHeader)manifest.getHeader(BundleSymbolicNameHeader.NAME);
+		BundleVersionHeader bvh = (BundleVersionHeader)manifest.getHeader(BundleVersionHeader.NAME);
+		capabilities.add(new ProvideBundleCapability(bsnh, bvh, this));
+		ProvideCapabilityHeader pch = (ProvideCapabilityHeader)manifest.getHeader(ProvideCapabilityHeader.NAME);
+		if (pch != null) {
+			for (ProvideCapabilityHeader.Clause clause : pch.getClauses()) {
+				capabilities.add(new ProvideCapabilityCapability(clause, this));
+			}
+		}
+		// TODO Bundle-RequiredExecutionEnvironment
 	}
 	
 	private BundleResource(String content) throws IOException {



Mime
View raw message