Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-09-23 21:13:47 +0000
committerThomas Watson2011-09-23 21:15:53 +0000
commit95830aefcf72ab237738d916e8298e034f344c91 (patch)
treef68e2cd3112c012f33fe4e220dd9e2b97f5a86a2 /bundles/org.eclipse.osgi/resolver
parent9f4a32866c2e03cd8ff895364f6a6d0a4ca15f6e (diff)
downloadrt.equinox.framework-95830aefcf72ab237738d916e8298e034f344c91.tar.gz
rt.equinox.framework-95830aefcf72ab237738d916e8298e034f344c91.tar.xz
rt.equinox.framework-95830aefcf72ab237738d916e8298e034f344c91.zip
Bug 350959 - [R4.4] BundleRevision must contain all capability and
requirement specified even if not effective
Diffstat (limited to 'bundles/org.eclipse.osgi/resolver')
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericCapability.java9
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericConstraint.java10
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java46
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java15
4 files changed, 45 insertions, 35 deletions
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericCapability.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericCapability.java
index b376ede08..3156e00fa 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericCapability.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericCapability.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 2011 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
@@ -18,12 +18,15 @@ import org.osgi.framework.Constants;
public class GenericCapability extends VersionSupplier {
final ResolverBundle resolverBundle;
final String[] uses;
+ final boolean effective;
GenericCapability(ResolverBundle resolverBundle, GenericDescription base) {
super(base);
this.resolverBundle = resolverBundle;
String usesDirective = base.getDeclaredDirectives().get(Constants.USES_DIRECTIVE);
uses = ManifestElement.getArrayFromList(usesDirective);
+ String effectiveDirective = base.getDeclaredDirectives().get(Constants.EFFECTIVE_DIRECTIVE);
+ effective = effectiveDirective == null || Constants.EFFECTIVE_RESOLVE.equals(effectiveDirective);
}
public BundleDescription getBundleDescription() {
@@ -41,4 +44,8 @@ public class GenericCapability extends VersionSupplier {
String[] getUsesDirective() {
return uses;
}
+
+ boolean isEffective() {
+ return effective;
+ }
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericConstraint.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericConstraint.java
index 7c3e9164f..7aa53580d 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericConstraint.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/GenericConstraint.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 2011 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
@@ -11,13 +11,17 @@
package org.eclipse.osgi.internal.module;
import org.eclipse.osgi.service.resolver.GenericSpecification;
+import org.osgi.framework.Constants;
public class GenericConstraint extends ResolverConstraint {
+ private final boolean effective;
private boolean supplierHasUses;
GenericConstraint(ResolverBundle bundle, GenericSpecification constraint) {
super(bundle, constraint);
+ String effectiveDirective = constraint.getRequirement().getDirectives().get(Constants.EFFECTIVE_DIRECTIVE);
+ effective = effectiveDirective == null || Constants.EFFECTIVE_RESOLVE.equals(effectiveDirective);
}
boolean isOptional() {
@@ -28,6 +32,10 @@ public class GenericConstraint extends ResolverConstraint {
return !supplierHasUses && (((GenericSpecification) constraint).getResolution() & GenericSpecification.RESOLUTION_MULTIPLE) != 0;
}
+ boolean isEffective() {
+ return effective;
+ }
+
public String getNameSpace() {
return ((GenericSpecification) getVersionConstraint()).getType();
}
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 8493bd23c..70ec071e7 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
@@ -1223,26 +1223,28 @@ public class ResolverImpl implements Resolver {
if (!failed) {
GenericConstraint[] genericRequires = bundle.getGenericRequires();
for (int i = 0; i < genericRequires.length; i++) {
- if (!resolveGenericReq(genericRequires[i], cycle)) {
- if (DEBUG || DEBUG_GENERICS)
- ResolverImpl.log("** GENERICS " + genericRequires[i].getVersionConstraint().getName() + "[" + genericRequires[i].getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- state.addResolverError(genericRequires[i].getVersionConstraint().getBundle(), ResolverError.MISSING_GENERIC_CAPABILITY, genericRequires[i].getVersionConstraint().toString(), genericRequires[i].getVersionConstraint());
- if (genericRequires[i].isFromFragment()) {
- if (!developmentMode) // only detach fragments when not in devmode
- bundle.detachFragment(bundleMapping.get(genericRequires[i].getVersionConstraint().getBundle()), null);
- continue;
- }
- if (!developmentMode) {
- // fail fast; otherwise we want to attempt to resolver other constraints in dev mode
- 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);
+ if (genericRequires[i].isEffective()) {
+ if (!resolveGenericReq(genericRequires[i], cycle)) {
+ if (DEBUG || DEBUG_GENERICS)
+ ResolverImpl.log("** GENERICS " + genericRequires[i].getVersionConstraint().getName() + "[" + genericRequires[i].getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ state.addResolverError(genericRequires[i].getVersionConstraint().getBundle(), ResolverError.MISSING_GENERIC_CAPABILITY, genericRequires[i].getVersionConstraint().toString(), genericRequires[i].getVersionConstraint());
+ if (genericRequires[i].isFromFragment()) {
+ if (!developmentMode) // only detach fragments when not in devmode
+ bundle.detachFragment(bundleMapping.get(genericRequires[i].getVersionConstraint().getBundle()), null);
+ continue;
+ }
+ if (!developmentMode) {
+ // fail fast; otherwise we want to attempt to resolver other constraints in dev mode
+ 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);
+ }
}
}
}
@@ -1713,7 +1715,7 @@ public class ResolverImpl implements Resolver {
GenericCapability[] capabilities = rb.getGenericCapabilities();
List<GenericDescription> selectedCapabilities = new ArrayList<GenericDescription>(capabilities.length);
for (GenericCapability capability : capabilities)
- if (permissionChecker.checkCapabilityPermission(capability.getGenericDescription()))
+ if (capability.isEffective() && permissionChecker.checkCapabilityPermission(capability.getGenericDescription()))
selectedCapabilities.add(capability.getGenericDescription());
GenericDescription[] selectedCapabilitiesArray = selectedCapabilities.toArray(new GenericDescription[selectedCapabilities.size()]);
@@ -2120,6 +2122,8 @@ public class ResolverImpl implements Resolver {
void addGenerics(GenericCapability[] generics) {
for (GenericCapability capability : generics) {
+ if (!capability.isEffective())
+ continue;
String type = capability.getGenericDescription().getType();
VersionHashMap<GenericCapability> namespace = resolverGenerics.get(type);
if (namespace == null) {
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 a93479068..a3ecf0253 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
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.osgi.internal.resolver;
-import org.osgi.framework.resource.ResourceConstants;
-
import java.lang.reflect.Constructor;
import java.util.*;
import org.eclipse.osgi.framework.internal.core.*;
@@ -21,6 +19,7 @@ import org.eclipse.osgi.service.resolver.*;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.*;
+import org.osgi.framework.resource.ResourceConstants;
/**
* This class builds bundle description objects from manifests
@@ -491,11 +490,7 @@ public class StateBuilder {
result = new ArrayList<GenericSpecification>();
for (ManifestElement element : osgiRequires) {
String[] namespaces = element.getValueComponents();
- types: for (String namespace : namespaces) {
- String effective = element.getDirective(Constants.EFFECTIVE_DIRECTIVE);
- if (effective != null && !Constants.EFFECTIVE_RESOLVE.equals(effective))
- break types;
-
+ for (String namespace : namespaces) {
GenericSpecificationImpl spec = new GenericSpecificationImpl();
spec.setType(namespace);
String filterSpec = element.getDirective(Constants.FILTER_DIRECTIVE);
@@ -581,11 +576,7 @@ public class StateBuilder {
for (ManifestElement element : osgiCapabilities) {
String[] namespaces = element.getValueComponents();
- types: for (String namespace : namespaces) {
- String effective = element.getDirective(Constants.EFFECTIVE_DIRECTIVE);
- // Any declared osgi.identity capability with an effective directive value of "resolve" will be overridden.
- if (effective != null && !Constants.EFFECTIVE_RESOLVE.equals(effective))
- break types; // ignore any namespace that is not effective at resolve time.
+ for (String namespace : namespaces) {
if (ResourceConstants.IDENTITY_NAMESPACE.equals(namespace))
throw new BundleException("A bundle is not allowed to define a capability in the " + ResourceConstants.IDENTITY_NAMESPACE + " name space."); //$NON-NLS-1$ //$NON-NLS-2$

Back to the top