Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnjum Fatima2019-01-07 20:30:36 +0000
committerAnjum Fatima2019-01-08 15:48:35 +0000
commit79e672bcbfdb99bd8b26771d9cfa859e531a908a (patch)
treeed84a5ea36b2b523a1657d94a788f7e7007ef669
parent821b16116174794481870a0cbb239b59bbd4cd13 (diff)
downloadrt.equinox.framework-79e672bcbfdb99bd8b26771d9cfa859e531a908a.tar.gz
rt.equinox.framework-79e672bcbfdb99bd8b26771d9cfa859e531a908a.tar.xz
rt.equinox.framework-79e672bcbfdb99bd8b26771d9cfa859e531a908a.zip
Bug 542691 - Stop adding the system.bundle alias to theI20190109-0655I20190108-1800
osgi.wiring.package capabilities Change-Id: I9a8314a8bb7ef71b713f1001c3807283b2653ed4 Signed-off-by: Anjum Fatima <anjum.eclipse@gmail.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java16
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java15
2 files changed, 23 insertions, 8 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
index 813a0189e..24af7a28f 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
@@ -3496,6 +3496,22 @@ public class TestModuleContainer extends AbstractTest {
assertTrue("Wrong error message: " + message, message.contains("b1") && message.contains("alias.name"));
}
+ @Test
+ public void testPackageNamespaceBundleSymbolicNameAttribute() throws Exception {
+ DummyContainerAdaptor adaptor = createDummyAdaptor();
+ ModuleContainer container = adaptor.getContainer();
+ // install the system.bundle
+ Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null, null, container);
+ ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
+ Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
+
+ ModuleWiring wiring = systemBundle.getCurrentRevision().getWiring();
+ List<BundleCapability> packages = wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE);
+ Assert.assertEquals("Wrong number of host packages.", 2, packages.size());
+ //system.bundle alias shouldn't be added to the bundle-symbolic-name attribute of the osgi.wiring.package capabilities of SYSTEM BUNDLE.
+ Assert.assertEquals("Wrong bundle-symbolic-name attribute", "org.eclipse.osgi", packages.get(0).getAttributes().get(PackageNamespace.CAPABILITY_BUNDLE_SYMBOLICNAME_ATTRIBUTE));
+ }
+
private static void assertWires(List<ModuleWire> required, List<ModuleWire>... provided) {
for (ModuleWire requiredWire : required) {
for (List<ModuleWire> providedList : provided) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java
index 239597afa..b1bfbc8ec 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java
@@ -100,13 +100,13 @@ public final class OSGiManifestBuilderFactory {
validateHeaders(manifest);
}
- Object symbolicName = getSymbolicNameAndVersion(builder, manifest, symbolicNameAlias, manifestVersion);
+ setSymbolicNameAndVersion(builder, manifest, symbolicNameAlias, manifestVersion);
Collection<Map<String, Object>> exportedPackages = new ArrayList<>();
- getPackageExports(builder, ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, manifest.get(Constants.EXPORT_PACKAGE)), symbolicName, exportedPackages);
- getPackageExports(builder, ManifestElement.parseHeader(HEADER_OLD_PROVIDE_PACKAGE, manifest.get(HEADER_OLD_PROVIDE_PACKAGE)), symbolicName, exportedPackages);
+ getPackageExports(builder, ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, manifest.get(Constants.EXPORT_PACKAGE)), exportedPackages);
+ getPackageExports(builder, ManifestElement.parseHeader(HEADER_OLD_PROVIDE_PACKAGE, manifest.get(HEADER_OLD_PROVIDE_PACKAGE)), exportedPackages);
if (extraExports != null && !extraExports.isEmpty()) {
- getPackageExports(builder, ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, extraExports), symbolicName, exportedPackages);
+ getPackageExports(builder, ManifestElement.parseHeader(Constants.EXPORT_PACKAGE, extraExports), exportedPackages);
}
getPackageImports(builder, manifest, exportedPackages, manifestVersion);
@@ -245,7 +245,7 @@ public final class OSGiManifestBuilderFactory {
return manifestVersionHeader == null ? 1 : Integer.parseInt(manifestVersionHeader);
}
- private static Object getSymbolicNameAndVersion(ModuleRevisionBuilder builder, Map<String, String> manifest, String symbolicNameAlias, int manifestVersion) throws BundleException {
+ private static void setSymbolicNameAndVersion(ModuleRevisionBuilder builder, Map<String, String> manifest, String symbolicNameAlias, int manifestVersion) throws BundleException {
boolean isFragment = manifest.get(Constants.FRAGMENT_HOST) != null;
builder.setTypes(isFragment ? BundleRevision.TYPE_FRAGMENT : 0);
String version = manifest.get(Constants.BUNDLE_VERSION);
@@ -311,11 +311,9 @@ public final class OSGiManifestBuilderFactory {
builder.addCapability(IdentityNamespace.IDENTITY_NAMESPACE, directives, identityAttributes);
}
}
-
- return symbolicName == null ? symbolicNameAlias : symbolicName;
}
- private static void getPackageExports(ModuleRevisionBuilder builder, ManifestElement[] exportElements, Object symbolicName, Collection<Map<String, Object>> exportedPackages) throws BundleException {
+ private static void getPackageExports(ModuleRevisionBuilder builder, ManifestElement[] exportElements, Collection<Map<String, Object>> exportedPackages) throws BundleException {
if (exportElements == null)
return;
for (ManifestElement exportElement : exportElements) {
@@ -328,6 +326,7 @@ public final class OSGiManifestBuilderFactory {
String specVersionAttr = (String) attributes.remove(Constants.PACKAGE_SPECIFICATION_VERSION);
Version version = versionAttr == null ? (specVersionAttr == null ? Version.emptyVersion : Version.parseVersion(specVersionAttr)) : Version.parseVersion(versionAttr);
attributes.put(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE, version);
+ String symbolicName = builder.getSymbolicName();
if (symbolicName != null) {
attributes.put(PackageNamespace.CAPABILITY_BUNDLE_SYMBOLICNAME_ATTRIBUTE, symbolicName);
}

Back to the top