Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2012-01-31 10:54:51 -0500
committerThomas Watson2012-01-31 10:54:51 -0500
commita05b273883a39de44a4e65c1eaea59e9d749a95e (patch)
tree64a0a4837b1326675f5b2b6813653d36b986e060
parent7f8b4e60490b6fce74759b903ada90f70556726c (diff)
downloadrt.equinox.framework-a05b273883a39de44a4e65c1eaea59e9d749a95e.tar.gz
rt.equinox.framework-a05b273883a39de44a4e65c1eaea59e9d749a95e.tar.xz
rt.equinox.framework-a05b273883a39de44a4e65c1eaea59e9d749a95e.zip
Bug 369880 - failure to attach fragment w/ BREE to an already resolved
host
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java221
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java38
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java70
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java2
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java5
5 files changed, 315 insertions, 21 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 9c0b84dad..b58ca558d 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
@@ -4553,6 +4553,227 @@ public class StateResolverTest extends AbstractStateTest {
assertTrue("D is not resolved", d.isResolved()); //$NON-NLS-1$
assertTrue("E is not resolved", e.isResolved()); //$NON-NLS-1$
}
+
+ public void testBug369880() throws BundleException {
+ State state = buildEmptyState();
+ Dictionary[] props = new Dictionary[] {new Hashtable()};
+ props[0].put("org.osgi.framework.executionenvironment", "test"); //$NON-NLS-1$ //$NON-NLS-2$
+ state.setPlatformProperties(props);
+ int bundleID = 0;
+
+ Hashtable manifest = new Hashtable();
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.osgi"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "test");
+ BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ 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.0"); //$NON-NLS-1$
+ manifest.put(Constants.FRAGMENT_HOST, "org.eclipse.osgi; bundle-version=\"[1.0, 1.1)\""); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "test");
+ BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ state.addBundle(a);
+ state.resolve();
+ assertTrue("A is not resolved", a.isResolved()); //$NON-NLS-1$
+
+ state.addBundle(b);
+ state.resolve();
+ assertTrue("B is not resolved", b.isResolved()); //$NON-NLS-1$
+
+ BundleWiring aWiring = a.getWiring();
+ List aRequirements = a.getRequirements("osgi.ee");
+ List aRequiredWires = aWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from system bundle", 1, aRequirements.size());
+ assertEquals("Wrong number of wires from system bundle", 1, aRequiredWires.size());
+
+ BundleWiring bWiring = b.getWiring();
+ List bRequirements = b.getRequirements("osgi.ee");
+ List bRequiredWires = bWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from fragment", 1, bRequirements.size());
+ assertEquals("Wrong number of wires from fragment", 1, bRequiredWires.size());
+ }
+
+ public void testResolveFragmentEE01() throws BundleException {
+ State state = buildEmptyState();
+ Dictionary[] props = new Dictionary[] {new Hashtable()};
+ props[0].put("org.osgi.framework.executionenvironment", "test"); //$NON-NLS-1$ //$NON-NLS-2$
+ state.setPlatformProperties(props);
+ int bundleID = 0;
+
+ Hashtable manifest = new Hashtable();
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.osgi"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "test");
+ BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ 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.0"); //$NON-NLS-1$
+ manifest.put(Constants.FRAGMENT_HOST, "org.eclipse.osgi; bundle-version=\"[1.0, 1.1)\""); //$NON-NLS-1$
+ manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.ee; filter:=\"(osgi.ee=test)\"");
+ BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ 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.0"); //$NON-NLS-1$
+ manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.identity; filter:=\"(osgi.identity=b)\""); //$NON-NLS-1$
+ BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ state.addBundle(b);
+ state.addBundle(a);
+ state.addBundle(c);
+ state.resolve();
+ assertTrue("A is not resolved", a.isResolved()); //$NON-NLS-1$
+ assertTrue("B is not resolved", b.isResolved()); //$NON-NLS-1$
+ assertTrue("C is not resolved", c.isResolved()); //$NON-NLS-1$
+
+ BundleWiring aWiring = a.getWiring();
+ List aRequirements = a.getRequirements("osgi.ee");
+ List aRequiredWires = aWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from system bundle", 1, aRequirements.size());
+ assertEquals("Wrong number of wires from system bundle", 1, aRequiredWires.size());
+
+ BundleWiring bWiring = b.getWiring();
+ List bRequirements = b.getRequirements("osgi.ee");
+ List bRequiredWires = bWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from fragment", 1, bRequirements.size());
+ assertEquals("Wrong number of wires from fragment", 1, bRequiredWires.size());
+
+ BundleWiring cWiring = c.getWiring();
+ List cRequirements = c.getRequirements("osgi.identity");
+ List cRequiredWires = cWiring.getRequiredWires("osgi.identity");
+ assertEquals("Wrong number of osgi.identity requirements from c", 1, cRequirements.size());
+ assertEquals("Wrong number of wires from c", 1, cRequiredWires.size());
+
+ 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.0"); //$NON-NLS-1$
+ manifest.put(Constants.FRAGMENT_HOST, "org.eclipse.osgi; bundle-version=\"[1.0, 1.1)\""); //$NON-NLS-1$
+ manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.ee; filter:=\"(osgi.ee=fail)\"");
+ b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), b.getBundleId());
+ state.updateBundle(b);
+ state.resolve(false);
+ assertTrue("A is not resolved", a.isResolved()); //$NON-NLS-1$
+ assertFalse("B is not resolved", b.isResolved()); //$NON-NLS-1$
+ assertFalse("C is not resolved", c.isResolved()); //$NON-NLS-1$
+ }
+
+ public void testResolveFragmentEE02() throws BundleException, IOException {
+ State state = buildEmptyState();
+ Dictionary[] props = new Dictionary[] {new Hashtable()};
+ props[0].put("org.osgi.framework.executionenvironment", "test"); //$NON-NLS-1$ //$NON-NLS-2$
+ state.setPlatformProperties(props);
+ int bundleID = 0;
+
+ Hashtable manifest = new Hashtable();
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "org.eclipse.osgi"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "test");
+ BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ 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.0"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "test");
+ BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ 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.0"); //$NON-NLS-1$
+ manifest.put(Constants.IMPORT_PACKAGE, "d");
+ manifest.put(Constants.FRAGMENT_HOST, "b");
+ manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "test");
+ BundleDescription c = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ state.addBundle(b);
+ state.addBundle(a);
+ state.addBundle(c);
+ state.resolve();
+ assertTrue("A is not resolved", a.isResolved()); //$NON-NLS-1$
+ assertTrue("B is not resolved", b.isResolved()); //$NON-NLS-1$
+ assertFalse("C is resolved", c.isResolved()); //$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.0"); //$NON-NLS-1$
+ manifest.put(Constants.EXPORT_PACKAGE, "d");
+ manifest.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "test");
+ BundleDescription d = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ state.addBundle(d);
+ state.resolve();
+ assertTrue("A is not resolved", a.isResolved()); //$NON-NLS-1$
+ assertTrue("B is not resolved", b.isResolved()); //$NON-NLS-1$
+ assertFalse("C is resolved", c.isResolved()); //$NON-NLS-1$
+ assertTrue("D is not resolved", d.isResolved()); //$NON-NLS-1$
+
+ state.resolve(new BundleDescription[] {b});
+ assertTrue("A is not resolved", a.isResolved()); //$NON-NLS-1$
+ assertTrue("B is not resolved", b.isResolved()); //$NON-NLS-1$
+ assertTrue("C is not resolved", c.isResolved()); //$NON-NLS-1$
+ assertTrue("D is not resolved", d.isResolved()); //$NON-NLS-1$
+
+ BundleWiring aWiring = a.getWiring();
+ List aRequirements = a.getRequirements("osgi.ee");
+ List aRequiredWires = aWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from system bundle", 1, aRequirements.size());
+ assertEquals("Wrong number of wires from system bundle", 1, aRequiredWires.size());
+
+ BundleWiring bWiring = b.getWiring();
+ List bRequirements = b.getRequirements("osgi.ee");
+ List bRequiredWires = bWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from fragment", 1, bRequirements.size());
+ assertEquals("Wrong number of wires from fragment", 1, bRequiredWires.size());
+
+ BundleWiring cWiring = c.getWiring();
+ List cRequirements = c.getRequirements("osgi.ee");
+ List cRequiredWires = cWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from c", 1, cRequirements.size());
+ assertEquals("Wrong number of wires from c", 1, cRequiredWires.size());
+
+ File stateCache = OSGiTestsActivator.getContext().getDataFile("statecache"); //$NON-NLS-1$
+ stateCache.mkdirs();
+ StateObjectFactory.defaultFactory.writeState(state, stateCache);
+ state = StateObjectFactory.defaultFactory.readState(stateCache);
+
+ a = state.getBundle("org.eclipse.osgi", null);
+ b = state.getBundle("b", null);
+ c = state.getBundle("c", null);
+ d = state.getBundle("d", null);
+
+ aWiring = a.getWiring();
+ aRequirements = a.getRequirements("osgi.ee");
+ aRequiredWires = aWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from system bundle", 1, aRequirements.size());
+ assertEquals("Wrong number of wires from system bundle", 1, aRequiredWires.size());
+
+ bWiring = b.getWiring();
+ bRequirements = b.getRequirements("osgi.ee");
+ bRequiredWires = bWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from fragment", 1, bRequirements.size());
+ assertEquals("Wrong number of wires from fragment", 1, bRequiredWires.size());
+
+ cWiring = c.getWiring();
+ cRequirements = c.getRequirements("osgi.ee");
+ cRequiredWires = cWiring.getRequiredWires("osgi.ee");
+ assertEquals("Wrong number of osgi.ee requirements from c", 1, cRequirements.size());
+ assertEquals("Wrong number of wires from c", 1, cRequiredWires.size());
+ }
}
//testFragmentUpdateNoVersionChanged()
//testFragmentUpdateVersionChanged()
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java
index abb88e838..b928a918a 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,14 +10,12 @@
*******************************************************************************/
package org.eclipse.osgi.internal.module;
-import org.osgi.framework.resource.ResourceConstants;
-
import java.util.*;
import java.util.Map.Entry;
-import org.eclipse.osgi.internal.resolver.ExportPackageDescriptionImpl;
-import org.eclipse.osgi.internal.resolver.GenericDescriptionImpl;
+import org.eclipse.osgi.internal.resolver.*;
import org.eclipse.osgi.service.resolver.*;
import org.osgi.framework.Constants;
+import org.osgi.framework.resource.ResourceConstants;
/*
* A companion to BundleDescription from the state used while resolving.
@@ -63,7 +61,13 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
exports = new ResolverExport[0];
imports = new ResolverImport[0];
requires = new BundleConstraint[0];
- genericReqiures = new GenericConstraint[0];
+ GenericSpecification[] requirements = getBundleDescription().getGenericRequires();
+ List<GenericConstraint> constraints = new ArrayList<GenericConstraint>();
+ for (GenericSpecification requirement : requirements) {
+ if (StateImpl.OSGI_EE_NAMESPACE.equals(requirement.getType()))
+ constraints.add(new GenericConstraint(this, requirement));
+ }
+ genericReqiures = constraints.toArray(new GenericConstraint[constraints.size()]);
GenericDescription[] capabilities = getBundleDescription().getGenericCapabilities();
GenericCapability identity = null;
for (GenericDescription capability : capabilities) {
@@ -355,9 +359,13 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
if (newGenericRequires.length > 0) {
ArrayList<GenericConstraint> hostGenericRequires = new ArrayList<GenericConstraint>(newGenericRequires.length);
- for (int i = 0; i < newGenericRequires.length; i++)
- hostGenericRequires.add(new GenericConstraint(this, newGenericRequires[i]));
- fragmentGenericRequires.put(fragment.bundleID, hostGenericRequires);
+ for (int i = 0; i < newGenericRequires.length; i++) {
+ // only add namespaces that are not osgi.ee
+ if (!StateImpl.OSGI_EE_NAMESPACE.equals(newGenericRequires[i].getType()))
+ hostGenericRequires.add(new GenericConstraint(this, newGenericRequires[i]));
+ }
+ if (!hostGenericRequires.isEmpty())
+ fragmentGenericRequires.put(fragment.bundleID, hostGenericRequires);
}
ArrayList<ResolverExport> hostExports = new ArrayList<ResolverExport>(newExports.length);
@@ -454,9 +462,15 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
}
}
// generic constraints cannot conflict;
- // only check that a fragment does not add generics constraints to an already resolved host
- if (isResolved() && newGenericRequires != null && newGenericRequires.length > 0)
- result = true;
+ // only check that a fragment does not add generic constraints to an already resolved host
+ if (isResolved() && newGenericRequires != null) {
+ for (GenericSpecification genericSpecification : newGenericRequires) {
+ if (!StateImpl.OSGI_EE_NAMESPACE.equals(genericSpecification.getType())) {
+ result = true;
+ resolver.getState().addResolverError(fragment, ResolverError.FRAGMENT_CONFLICT, genericSpecification.toString(), genericSpecification);
+ }
+ }
+ }
return result;
}
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 0b1436e52..a57207539 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
@@ -149,7 +149,7 @@ public class ResolverImpl implements Resolver {
private void rewireBundles() {
List<ResolverBundle> visited = new ArrayList<ResolverBundle>(bundleMapping.size());
for (ResolverBundle rb : bundleMapping.values()) {
- if (!rb.getBundleDescription().isResolved() || rb.isFragment())
+ if (!rb.getBundleDescription().isResolved())
continue;
rewireBundle(rb, visited);
}
@@ -347,6 +347,9 @@ public class ResolverImpl implements Resolver {
private void attachFragment0(ResolverBundle bundle) {
if (!bundle.isFragment() || !bundle.isResolvable())
return;
+ bundle.clearWires();
+ if (!resolveOSGiEE(bundle))
+ return;
// no need to select singletons now; it will be done when we select the rest of the singleton bundles (bug 152042)
// find all available hosts to attach to.
boolean foundMatch = false;
@@ -383,6 +386,31 @@ public class ResolverImpl implements Resolver {
}
+ private boolean resolveOSGiEE(ResolverBundle bundle) {
+ GenericConstraint[] requirements = bundle.getGenericRequires();
+ for (GenericConstraint requirement : requirements) {
+ if (!(StateImpl.OSGI_EE_NAMESPACE.equals(requirement.getNameSpace()) || requirement.isEffective()))
+ continue;
+ {
+ if (!resolveGenericReq(requirement, new ArrayList<ResolverBundle>(0))) {
+ if (DEBUG || DEBUG_GENERICS)
+ ResolverImpl.log("** GENERICS " + requirement.getVersionConstraint().getName() + "[" + requirement.getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ state.addResolverError(requirement.getVersionConstraint().getBundle(), ResolverError.MISSING_GENERIC_CAPABILITY, requirement.getVersionConstraint().toString(), requirement.getVersionConstraint());
+ if (!developmentMode) {
+ // fail fast; otherwise we want to attempt to resolver other constraints in dev mode
+ return false;
+ }
+ } else {
+ VersionSupplier supplier = requirement.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);
+ }
+ }
+ }
+ return true;
+ }
+
public synchronized void resolve(BundleDescription[] reRefresh, Dictionary<Object, Object>[] platformProperties) {
if (DEBUG)
ResolverImpl.log("*** BEGIN RESOLUTION ***"); //$NON-NLS-1$
@@ -438,11 +466,25 @@ public class ResolverImpl implements Resolver {
}
}
- ResolverBundle[] bundles = unresolvedBundles.toArray(new ResolverBundle[unresolvedBundles.size()]);
-
usesCalculationTimeout = false;
- resolveBundles(bundles, platformProperties, hookDisabled);
+ List<ResolverBundle> toResolve = new ArrayList<ResolverBundle>(unresolvedBundles);
+ // first resolve the system bundle to allow osgi.ee capabilities to be resolved
+ List<ResolverBundle> unresolvedSystemBundles = new ArrayList<ResolverBundle>(1);
+ String systemBSN = getSystemBundle();
+ for (Iterator<ResolverBundle> iToResolve = toResolve.iterator(); iToResolve.hasNext();) {
+ ResolverBundle rb = iToResolve.next();
+ String symbolicName = rb.getName();
+ if (symbolicName != null && symbolicName.equals(systemBSN)) {
+ unresolvedSystemBundles.add(rb);
+ iToResolve.remove();
+ }
+ }
+ if (!unresolvedSystemBundles.isEmpty())
+ resolveBundles(unresolvedSystemBundles.toArray(new ResolverBundle[unresolvedSystemBundles.size()]), platformProperties, hookDisabled);
+
+ // Now resolve the rest
+ resolveBundles(toResolve.toArray(new ResolverBundle[toResolve.size()]), platformProperties, hookDisabled);
@SuppressWarnings("unchecked")
Collection<ResolverBundle> optionalResolved = resolveOptional ? resolveOptionalConstraints(currentlyResolved) : Collections.EMPTY_LIST;
@@ -1283,7 +1325,7 @@ public class ResolverImpl implements Resolver {
break;
}
} else {
- if ("osgi.ee".equals(genericRequires[i].getNameSpace())) { //$NON-NLS-1$
+ if (StateImpl.OSGI_EE_NAMESPACE.equals(genericRequires[i].getNameSpace())) {
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)
@@ -1438,8 +1480,15 @@ public class ResolverImpl implements Resolver {
foundResolvedMatch = true;
continue;
}
+ boolean successfulResolve = false;
+ if (capabilitySupplier.getState() != ResolverBundle.RESOLVED) {
+ // only attempt to resolve the supplier if not osgi.ee name space
+ if (!StateImpl.OSGI_EE_NAMESPACE.equals(constraint.getNameSpace()))
+ successfulResolve = resolveBundle(capabilitySupplier, cycle);
+ }
+
// if in dev mode then allow a constraint to resolve to an unresolved bundle
- if (capabilitySupplier.getState() == ResolverBundle.RESOLVED || (resolveBundle(capabilitySupplier, cycle) || developmentMode)) {
+ if (capabilitySupplier.getState() == ResolverBundle.RESOLVED || (successfulResolve || developmentMode)) {
foundResolvedMatch |= !capability.getResolverBundle().isFragment() ? true : capability.getResolverBundle().getHost().getPossibleSuppliers() != null;
// Check cyclic dependencies
if (capabilitySupplier.getState() == ResolverBundle.RESOLVING)
@@ -1707,6 +1756,15 @@ public class ResolverImpl implements Resolver {
BaseDescription supplier = bundle == null ? null : bundle.getBundleDescription();
state.resolveConstraint(requires[i], supplier);
}
+ GenericConstraint[] genericRequires = rb.getGenericRequires();
+ for (int i = 0; i < genericRequires.length; i++) {
+ VersionSupplier[] matchingCapabilities = genericRequires[i].getMatchingCapabilities();
+ if (matchingCapabilities == null)
+ state.resolveConstraint(genericRequires[i].getVersionConstraint(), null);
+ else
+ for (int j = 0; j < matchingCapabilities.length; j++)
+ state.resolveConstraint(genericRequires[i].getVersionConstraint(), matchingCapabilities[j].getBaseDescription());
+ }
}
private void stateResolveBundle(ResolverBundle rb) {
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 dd46fd60c..bde0d203f 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
@@ -506,7 +506,7 @@ public class StateBuilder {
}
GenericSpecificationImpl spec = new GenericSpecificationImpl();
spec.setResolution(GenericSpecificationImpl.RESOLUTION_FROM_BREE);
- spec.setType("osgi.ee"); //$NON-NLS-1$
+ spec.setType(StateImpl.OSGI_EE_NAMESPACE);
try {
FilterImpl filter = FilterImpl.newInstance(filterSpec);
spec.setMatchingFilter(filter);
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 78ee9354e..7613216f0 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
@@ -35,6 +35,7 @@ public abstract class StateImpl implements State {
private static final String OSGI_ARCH = "osgi.arch"; //$NON-NLS-1$
public static final String[] PROPS = {OSGI_OS, OSGI_WS, OSGI_NL, OSGI_ARCH, Constants.FRAMEWORK_SYSTEMPACKAGES, Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, Constants.OSGI_RESOLVER_MODE, Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "osgi.resolveOptional", "osgi.genericAliases", Constants.FRAMEWORK_OS_NAME, Constants.FRAMEWORK_OS_VERSION, Constants.FRAMEWORK_PROCESSOR, Constants.FRAMEWORK_LANGUAGE, Constants.STATE_SYSTEM_BUNDLE, Constants.FRAMEWORK_SYSTEMCAPABILITIES, Constants.FRAMEWORK_SYSTEMCAPABILITIES_EXTRA}; //$NON-NLS-1$ //$NON-NLS-2$
private static final DisabledInfo[] EMPTY_DISABLEDINFOS = new DisabledInfo[0];
+ public static final String OSGI_EE_NAMESPACE = "osgi.ee"; //$NON-NLS-1$
transient private Resolver resolver;
transient private StateDeltaImpl changes;
@@ -876,7 +877,7 @@ public abstract class StateImpl implements State {
if (profileEE == null || profileEE.length() == 0)
return;
for (GenericDescription capability : capabilities) {
- if ("osgi.ee".equals(capability.getType()) && profileIndex.equals(capability.getAttributes().get(ExportPackageDescriptionImpl.EQUINOX_EE))) //$NON-NLS-1$
+ if (OSGI_EE_NAMESPACE.equals(capability.getType()) && profileIndex.equals(capability.getAttributes().get(ExportPackageDescriptionImpl.EQUINOX_EE)))
return; // profile already specifies osgi.ee capabilities
}
Map<String, List<String>> eeVersions = new HashMap<String, List<String>>();
@@ -894,7 +895,7 @@ public abstract class StateImpl implements State {
}
for (Map.Entry<String, List<String>> eeVersion : eeVersions.entrySet()) {
GenericDescriptionImpl capability = new GenericDescriptionImpl();
- capability.setType("osgi.ee"); //$NON-NLS-1$
+ capability.setType(OSGI_EE_NAMESPACE);
Dictionary<String, Object> attributes = new Hashtable<String, Object>();
attributes.put(capability.getType(), eeVersion.getKey());
if (eeVersion.getValue().size() > 0) {

Back to the top