diff options
author | Thomas Watson | 2011-08-23 15:43:47 +0000 |
---|---|---|
committer | Thomas Watson | 2011-08-23 15:43:47 +0000 |
commit | 70fdbc6b9936f587bdcc1481eb0e67468e29a0c6 (patch) | |
tree | ba8ad99c3fb91e453533225dd1d6521998632fbf /bundles | |
parent | c31d218de84897d1bc8b90d3c853716af3f965c2 (diff) | |
download | rt.equinox.framework-70fdbc6b9936f587bdcc1481eb0e67468e29a0c6.tar.gz rt.equinox.framework-70fdbc6b9936f587bdcc1481eb0e67468e29a0c6.tar.xz rt.equinox.framework-70fdbc6b9936f587bdcc1481eb0e67468e29a0c6.zip |
Bug 355421 - system bundle is missing the osgi.identity capabilityv20110829-1633
Diffstat (limited to 'bundles')
4 files changed, 64 insertions, 11 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java index 547e4d7c6..014a90912 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java @@ -2714,6 +2714,7 @@ public class StateResolverTest extends AbstractStateTest { manifest.put(Constants.BUNDLE_VERSION, "1.0"); //$NON-NLS-1$ BundleDescription systemBundle = state.getFactory().createBundleDescription(state, manifest, "org.eclipse.osgi", bundleID++); //$NON-NLS-1$ + manifest.clear(); manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A"); //$NON-NLS-1$ manifest.put(Constants.BUNDLE_VERSION, "1.0"); //$NON-NLS-1$ @@ -2721,6 +2722,7 @@ public class StateResolverTest extends AbstractStateTest { manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.4"); //$NON-NLS-1$ BundleDescription a = state.getFactory().createBundleDescription(state, manifest, "A", bundleID++); //$NON-NLS-1$ + manifest.clear(); manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B"); //$NON-NLS-1$ manifest.put(Constants.BUNDLE_VERSION, "1.0"); //$NON-NLS-1$ @@ -2729,6 +2731,24 @@ public class StateResolverTest extends AbstractStateTest { manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.2"); //$NON-NLS-1$ BundleDescription b = state.getFactory().createBundleDescription(state, manifest, "B", bundleID++); //$NON-NLS-1$ + manifest.clear(); + manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_SYMBOLICNAME, "C"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_VERSION, "1.0"); //$NON-NLS-1$ + manifest.put(Constants.IMPORT_PACKAGE, "pkg.d, pkg.system.b"); //$NON-NLS-1$ + manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.ee; filter:=\"(&(osgi.ee=JavaSE)(version>=1.4))\""); //$NON-NLS-1$ + BundleDescription c = state.getFactory().createBundleDescription(state, manifest, "C", bundleID++); //$NON-NLS-1$ + + manifest.clear(); + manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_SYMBOLICNAME, "D"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_VERSION, "1.0"); //$NON-NLS-1$ + manifest.put(Constants.EXPORT_PACKAGE, "pkg.d"); //$NON-NLS-1$ + manifest.put(Constants.IMPORT_PACKAGE, "pkg.system.b"); //$NON-NLS-1$ + manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.ee; filter:=\"(&(osgi.ee=JavaSE)(version>=1.2))\""); //$NON-NLS-1$ + BundleDescription d = state.getFactory().createBundleDescription(state, manifest, "D", bundleID++); //$NON-NLS-1$ + + manifest.clear(); manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "system.b"); //$NON-NLS-1$ manifest.put(Constants.BUNDLE_VERSION, "1.0"); //$NON-NLS-1$ @@ -2739,26 +2759,38 @@ public class StateResolverTest extends AbstractStateTest { Dictionary[] props = new Dictionary[] {new Hashtable(), new Hashtable()}; props[0].put("org.osgi.framework.system.packages", "pkg.system.a, pkg.system.c"); //$NON-NLS-1$ //$NON-NLS-2$ props[0].put("org.osgi.framework.executionenvironment", "J2SE-1.2"); //$NON-NLS-1$ //$NON-NLS-2$ + props[0].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"JavaSE\"; version:Version=\"1.2\""); props[1].put("org.osgi.framework.system.packages", "pkg.system.a, pkg.system.b, pkg.system.c"); //$NON-NLS-1$ //$NON-NLS-2$ props[1].put("org.osgi.framework.executionenvironment", "J2SE-1.4"); //$NON-NLS-1$ //$NON-NLS-2$ + props[1].put("org.osgi.framework.system.capabilities", "osgi.ee; osgi.ee=\"JavaSE\"; version:List<Version>=\"1.2, 1.3, 1.4\""); state.setPlatformProperties(props); state.addBundle(systemBundle); state.addBundle(a); state.addBundle(b); + state.addBundle(c); + state.addBundle(d); state.addBundle(systemB); state.resolve(); + Collection ids = systemBundle.getCapabilities(ResourceConstants.IDENTITY_NAMESPACE); + assertNotNull("Null osgi.identity", ids); + assertEquals("Wrong number of identities", 1, ids.size()); + assertTrue("1.0", systemBundle.isResolved()); //$NON-NLS-1$ assertTrue("1.1", a.isResolved()); //$NON-NLS-1$ assertTrue("1.2", b.isResolved()); //$NON-NLS-1$ - assertTrue("1.3", systemB.isResolved()); //$NON-NLS-1$ + assertTrue("1.3", c.isResolved()); //$NON-NLS-1$ + assertTrue("1.4", d.isResolved()); //$NON-NLS-1$ + assertTrue("1.5", systemB.isResolved()); //$NON-NLS-1$ assertTrue("2.0", a.getResolvedImports()[1].getExporter() == systemBundle); //$NON-NLS-1$ assertTrue("2.1", b.getResolvedImports()[0].getExporter() == systemB); //$NON-NLS-1$ + assertTrue("2.2", c.getResolvedImports()[1].getExporter() == systemBundle); //$NON-NLS-1$ + assertTrue("2.3", d.getResolvedImports()[0].getExporter() == systemB); //$NON-NLS-1$ // now test the uses clause for pkg.b such that bundle 'A' will be forced to used - // pkg.system from bundle 'system.b' + // pkg.system.b from bundle 'system.b' manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B"); //$NON-NLS-1$ manifest.put(Constants.BUNDLE_VERSION, "1.0"); //$NON-NLS-1$ @@ -2767,7 +2799,18 @@ public class StateResolverTest extends AbstractStateTest { manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.2"); //$NON-NLS-1$ BundleDescription b_updated = state.getFactory().createBundleDescription(state, manifest, "B", b.getBundleId()); //$NON-NLS-1$ state.updateBundle(b_updated); - state.resolve(new BundleDescription[] {b_updated}); + + // now test the uses clause for pkg.d such that bundle 'C' will be forced to used + // pkg.system.b from bundle 'system.b' + manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_SYMBOLICNAME, "D"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_VERSION, "1.0"); //$NON-NLS-1$ + manifest.put(Constants.EXPORT_PACKAGE, "pkg.d; uses:=\"pkg.system.b\""); //$NON-NLS-1$ + manifest.put(Constants.IMPORT_PACKAGE, "pkg.system.b"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.2"); //$NON-NLS-1$ + BundleDescription d_updated = state.getFactory().createBundleDescription(state, manifest, "D", d.getBundleId()); //$NON-NLS-1$ + state.updateBundle(d_updated); + state.resolve(new BundleDescription[] {b_updated, d_updated}); assertTrue("3.0", systemBundle.isResolved()); //$NON-NLS-1$ assertTrue("3.1", a.isResolved()); //$NON-NLS-1$ @@ -2776,6 +2819,7 @@ public class StateResolverTest extends AbstractStateTest { assertTrue("2.0", a.getResolvedImports()[1].getExporter() == systemB); //$NON-NLS-1$ assertTrue("2.1", b_updated.getResolvedImports()[0].getExporter() == systemB); //$NON-NLS-1$ + assertTrue("2.2", c.getResolvedImports()[1].getExporter() == systemB); //$NON-NLS-1$ } public void testPlatformProperties02() throws BundleException { diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java index 0f4d7b661..ebd92db6e 100644 --- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java +++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java @@ -1229,6 +1229,13 @@ public class ResolverImpl implements Resolver { failed = true; break; } + } else { + if ("osgi.ee".equals(genericRequires[i].getNameSpace())) { //$NON-NLS-1$ + VersionSupplier supplier = genericRequires[i].getSelectedSupplier(); + Integer ee = supplier == null ? null : (Integer) ((GenericDescription) supplier.getBaseDescription()).getAttributes().get(ExportPackageDescriptionImpl.EQUINOX_EE); + if (ee != null && ((BundleDescriptionImpl) bundle.getBaseDescription()).getEquinoxEE() < 0) + ((BundleDescriptionImpl) bundle.getBundleDescription()).setEquinoxEE(ee); + } } } } diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java index 577c97e85..bca93d05a 100644 --- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java +++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java @@ -569,10 +569,10 @@ public class StateBuilder { if (osgiIdentity != null) // always add the capability to the front result.add(0, osgiIdentity); - return createOSGiCapabilities(osgiCapabilities, result); + return createOSGiCapabilities(osgiCapabilities, result, (Integer) null); } - static List<GenericDescription> createOSGiCapabilities(ManifestElement[] osgiCapabilities, List<GenericDescription> result) throws BundleException { + static List<GenericDescription> createOSGiCapabilities(ManifestElement[] osgiCapabilities, List<GenericDescription> result, Integer profileIndex) throws BundleException { if (osgiCapabilities == null) return result; if (result == null) @@ -591,6 +591,8 @@ public class StateBuilder { GenericDescriptionImpl desc = new GenericDescriptionImpl(); desc.setType(namespace); Map<String, Object> mapAttrs = getAttributes(element, new String[0]); + if (profileIndex != null) + mapAttrs.put(ExportPackageDescriptionImpl.EQUINOX_EE, profileIndex); Dictionary<String, Object> attrs = mapAttrs == null ? new Hashtable<String, Object>() : new Hashtable<String, Object>(mapAttrs); desc.setAttributes(attrs); Map<String, String> directives = new HashMap<String, String>(); diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java index aa8d9cbf5..68f61b241 100644 --- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java +++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java @@ -846,12 +846,12 @@ public abstract class StateImpl implements State { private void resetSystemCapabilities() { BundleDescription[] systemBundles = getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); - Long builtIn = new Long(1); for (BundleDescription systemBundle : systemBundles) { GenericDescription[] capabilities = systemBundle.getGenericCapabilities(); List<GenericDescription> newCapabilities = new ArrayList<GenericDescription>(capabilities.length); for (GenericDescription capability : capabilities) { - if (builtIn.equals(capability.getDeclaredAttributes().get("equinox.builtin"))) //$NON-NLS-1$ + Object equinoxEEIndex = capability.getDeclaredAttributes().get(ExportPackageDescriptionImpl.EQUINOX_EE); + if (equinoxEEIndex == null) newCapabilities.add(capability); // keep the built in ones. } // now add the externally defined ones @@ -863,16 +863,16 @@ public abstract class StateImpl implements State { private void addSystemCapabilities(List<GenericDescription> capabilities) { for (int i = 0; i < platformProperties.length; i++) try { - addSystemCapabilities(capabilities, ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, (String) platformProperties[i].get(Constants.FRAMEWORK_SYSTEMCAPABILITIES))); - addSystemCapabilities(capabilities, ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, (String) platformProperties[i].get(Constants.FRAMEWORK_SYSTEMCAPABILITIES_EXTRA))); + addSystemCapabilities(capabilities, ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, (String) platformProperties[i].get(Constants.FRAMEWORK_SYSTEMCAPABILITIES)), i); + addSystemCapabilities(capabilities, ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, (String) platformProperties[i].get(Constants.FRAMEWORK_SYSTEMCAPABILITIES_EXTRA)), i); } catch (BundleException e) { // TODO consider throwing this... } } - private void addSystemCapabilities(List<GenericDescription> capabilities, ManifestElement[] elements) { + private void addSystemCapabilities(List<GenericDescription> capabilities, ManifestElement[] elements, Integer profileIndex) { try { - StateBuilder.createOSGiCapabilities(elements, capabilities); + StateBuilder.createOSGiCapabilities(elements, capabilities, profileIndex); } catch (BundleException e) { throw new RuntimeException("Unexpected exception adding system capabilities.", e); //$NON-NLS-1$ } |