Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Thoms2018-01-26 06:03:05 -0500
committerThomas Watson2018-01-31 09:13:30 -0500
commit58ead3e6dcd337c9596894b1a8b779c26e759844 (patch)
treead0cd7fbc78563124d29734134a646b3c17a9e67
parent99ea6b27ab528bdc5a5158fab0b9c8f4208a359a (diff)
downloadrt.equinox.framework-58ead3e6dcd337c9596894b1a8b779c26e759844.tar.gz
rt.equinox.framework-58ead3e6dcd337c9596894b1a8b779c26e759844.tar.xz
rt.equinox.framework-58ead3e6dcd337c9596894b1a8b779c26e759844.zip
Bug 528440 - Consider devmode for effective status computationI20180131-2000
In development mode, also capabilities with effective:="active" are considered as effective for GenericConstraint / GenericCapability. Change-Id: Ie8f667c851445bb6db987deade4e7b59de16c399 Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericCapability.java7
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericConstraint.java7
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java50
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java64
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/DevModeTest.java37
5 files changed, 131 insertions, 34 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericCapability.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericCapability.java
index 3156e00fa..b11603150 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericCapability.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericCapability.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2018 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Karsten Thoms (itemis) - Consider devmode for effective status computation
*******************************************************************************/
package org.eclipse.osgi.internal.module;
@@ -20,13 +21,13 @@ public class GenericCapability extends VersionSupplier {
final String[] uses;
final boolean effective;
- GenericCapability(ResolverBundle resolverBundle, GenericDescription base) {
+ GenericCapability(ResolverBundle resolverBundle, GenericDescription base, boolean developmentMode) {
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);
+ effective = effectiveDirective == null || Constants.EFFECTIVE_RESOLVE.equals(effectiveDirective) || (Constants.EFFECTIVE_ACTIVE.equals(effectiveDirective) && developmentMode);
}
public BundleDescription getBundleDescription() {
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericConstraint.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericConstraint.java
index 44589173c..8b41c1644 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericConstraint.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GenericConstraint.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 IBM Corporation and others.
+ * Copyright (c) 2006, 2018 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Karsten Thoms (itemis) - Consider devmode for effective status computation
*******************************************************************************/
package org.eclipse.osgi.internal.module;
@@ -19,10 +20,10 @@ public class GenericConstraint extends ResolverConstraint {
private final boolean effective;
private final boolean multiple;
- GenericConstraint(ResolverBundle bundle, GenericSpecification constraint) {
+ GenericConstraint(ResolverBundle bundle, GenericSpecification constraint, boolean developmentMode) {
super(bundle, constraint);
String effectiveDirective = constraint.getRequirement().getDirectives().get(Constants.EFFECTIVE_DIRECTIVE);
- effective = effectiveDirective == null || Constants.EFFECTIVE_RESOLVE.equals(effectiveDirective);
+ effective = effectiveDirective == null || Constants.EFFECTIVE_RESOLVE.equals(effectiveDirective) || (Constants.EFFECTIVE_ACTIVE.equals(effectiveDirective) && developmentMode);
multiple = (constraint.getResolution() & GenericSpecification.RESOLUTION_MULTIPLE) != 0;
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java
index 4502c1992..0c7174350 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2016 IBM Corporation and others.
+ * Copyright (c) 2004, 2018 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
@@ -7,13 +7,31 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Karsten Thoms (itemis) - Consider devmode for generic capabilities
+ * & constraints
*******************************************************************************/
package org.eclipse.osgi.internal.module;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
-import org.eclipse.osgi.internal.resolver.*;
-import org.eclipse.osgi.service.resolver.*;
+import org.eclipse.osgi.internal.resolver.ExportPackageDescriptionImpl;
+import org.eclipse.osgi.internal.resolver.GenericDescriptionImpl;
+import org.eclipse.osgi.internal.resolver.ImportPackageSpecificationImpl;
+import org.eclipse.osgi.internal.resolver.StateImpl;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.BundleSpecification;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.GenericDescription;
+import org.eclipse.osgi.service.resolver.GenericSpecification;
+import org.eclipse.osgi.service.resolver.HostSpecification;
+import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
+import org.eclipse.osgi.service.resolver.ResolverError;
+import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.osgi.framework.Constants;
import org.osgi.framework.namespace.IdentityNamespace;
@@ -64,15 +82,16 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
GenericSpecification[] requirements = getBundleDescription().getGenericRequires();
List<GenericConstraint> constraints = new ArrayList<>();
for (GenericSpecification requirement : requirements) {
- if (StateImpl.OSGI_EE_NAMESPACE.equals(requirement.getType()))
- constraints.add(new GenericConstraint(this, requirement));
+ if (StateImpl.OSGI_EE_NAMESPACE.equals(requirement.getType())) {
+ constraints.add(new GenericConstraint(this, requirement, resolver.isDevelopmentMode()));
+ }
}
genericReqiures = constraints.toArray(new GenericConstraint[constraints.size()]);
GenericDescription[] capabilities = getBundleDescription().getGenericCapabilities();
GenericCapability identity = null;
for (GenericDescription capability : capabilities) {
if (IdentityNamespace.IDENTITY_NAMESPACE.equals(capability.getType())) {
- identity = new GenericCapability(this, capability);
+ identity = new GenericCapability(this, capability, resolver.isDevelopmentMode());
break;
}
}
@@ -103,13 +122,15 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
GenericSpecification[] actualGenericRequires = getBundleDescription().getGenericRequires();
genericReqiures = new GenericConstraint[actualGenericRequires.length];
- for (int i = 0; i < genericReqiures.length; i++)
- genericReqiures[i] = new GenericConstraint(this, actualGenericRequires[i]);
+ for (int i = 0; i < genericReqiures.length; i++) {
+ genericReqiures[i] = new GenericConstraint(this, actualGenericRequires[i], resolver.isDevelopmentMode());
+ }
GenericDescription[] actualCapabilities = useSelectedExports ? getBundleDescription().getSelectedGenericCapabilities() : getBundleDescription().getGenericCapabilities();
genericCapabilities = new GenericCapability[actualCapabilities.length];
- for (int i = 0; i < genericCapabilities.length; i++)
- genericCapabilities[i] = new GenericCapability(this, actualCapabilities[i]);
+ for (int i = 0; i < genericCapabilities.length; i++) {
+ genericCapabilities[i] = new GenericCapability(this, actualCapabilities[i], resolver.isDevelopmentMode());
+ }
fragments = null;
fragmentExports = null;
@@ -361,8 +382,9 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
ArrayList<GenericConstraint> hostGenericRequires = new ArrayList<>(newGenericRequires.length);
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 (!StateImpl.OSGI_EE_NAMESPACE.equals(newGenericRequires[i].getType())) {
+ hostGenericRequires.add(new GenericConstraint(this, newGenericRequires[i], resolver.isDevelopmentMode()));
+ }
}
if (!hostGenericRequires.isEmpty())
fragmentGenericRequires.put(fragment.bundleID, hostGenericRequires);
@@ -390,7 +412,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
for (GenericDescription capability : newGenericCapabilities) {
if (!IdentityNamespace.IDENTITY_NAMESPACE.equals(capability.getType())) {
GenericDescription hostCapabililty = new GenericDescriptionImpl(getBundleDescription(), capability);
- hostCapabilities.add(new GenericCapability(this, hostCapabililty));
+ hostCapabilities.add(new GenericCapability(this, hostCapabililty, resolver.isDevelopmentMode()));
}
}
if (hostCapabilities.size() > 0) {
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index cb14f5d1b..dda954fe1 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2016 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2004, 2018 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 http://www.eclipse.org/legal/epl-v10.html
@@ -8,21 +8,53 @@
* IBM Corporation - initial API and implementation
* Danail Nachev - ProSyst - bug 218625
* Rob Harrop - SpringSource Inc. (bug 247522)
+ * Karsten Thoms (itemis) - Expose developmentMode
******************************************************************************/
package org.eclipse.osgi.internal.module;
import java.security.AccessController;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.osgi.framework.util.ArrayMap;
import org.eclipse.osgi.framework.util.SecureAction;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.framework.EquinoxContainer;
import org.eclipse.osgi.internal.framework.FilterImpl;
import org.eclipse.osgi.internal.module.GroupingChecker.PackageRoots;
-import org.eclipse.osgi.internal.resolver.*;
-import org.eclipse.osgi.service.resolver.*;
+import org.eclipse.osgi.internal.resolver.BaseDescriptionImpl;
+import org.eclipse.osgi.internal.resolver.BundleDescriptionImpl;
+import org.eclipse.osgi.internal.resolver.ExportPackageDescriptionImpl;
+import org.eclipse.osgi.internal.resolver.StateImpl;
+import org.eclipse.osgi.service.resolver.BaseDescription;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.BundleSpecification;
+import org.eclipse.osgi.service.resolver.DisabledInfo;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.GenericDescription;
+import org.eclipse.osgi.service.resolver.GenericSpecification;
+import org.eclipse.osgi.service.resolver.HostSpecification;
+import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
+import org.eclipse.osgi.service.resolver.NativeCodeDescription;
+import org.eclipse.osgi.service.resolver.NativeCodeSpecification;
+import org.eclipse.osgi.service.resolver.Resolver;
+import org.eclipse.osgi.service.resolver.ResolverError;
+import org.eclipse.osgi.service.resolver.State;
+import org.eclipse.osgi.service.resolver.StateWire;
+import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.*;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.hooks.resolver.ResolverHook;
import org.osgi.framework.namespace.IdentityNamespace;
import org.osgi.framework.wiring.BundleCapability;
@@ -408,16 +440,18 @@ public class ResolverImpl implements Resolver {
if (state == null)
throw new IllegalStateException("RESOLVER_NO_STATE"); //$NON-NLS-1$
- if (!initialized)
- initialize();
+ // set developmentMode each resolution
+ developmentMode = platformProperties.length == 0 ? false : StateImpl.DEVELOPMENT_MODE.equals(platformProperties[0].get(StateImpl.OSGI_RESOLVER_MODE));
+ // set uses timeout each resolution
+ usesTimeout = getUsesTimeout(platformProperties);
+ // set limit for constraints with multiple suppliers each resolution
+ usesMultipleSuppliersLimit = getMultipleSuppliersLimit(platformProperties);
hook = (state instanceof StateImpl) ? ((StateImpl) state).getResolverHook() : null;
+
+ if (!initialized) {
+ initialize();
+ }
try {
- // set developmentMode each resolution
- developmentMode = platformProperties.length == 0 ? false : StateImpl.DEVELOPMENT_MODE.equals(platformProperties[0].get(StateImpl.OSGI_RESOLVER_MODE));
- // set uses timeout each resolution
- usesTimeout = getUsesTimeout(platformProperties);
- // set limit for constraints with multiple suppliers each resolution
- usesMultipleSuppliersLimit = getMultipleSuppliersLimit(platformProperties);
reRefresh = addDevConstraints(reRefresh);
// Unresolve all the supplied bundles and their dependents
if (reRefresh != null)
@@ -2306,4 +2340,8 @@ public class ResolverImpl implements Resolver {
namespace.put(capability.getName(), capability);
}
}
+
+ boolean isDevelopmentMode() {
+ return developmentMode;
+ }
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/DevModeTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/DevModeTest.java
index 61fa92381..8e2c0fce3 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/DevModeTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/DevModeTest.java
@@ -14,7 +14,9 @@ import java.util.Dictionary;
import java.util.Hashtable;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.osgi.service.resolver.*;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.State;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -334,4 +336,37 @@ public class DevModeTest extends AbstractStateTest {
assertTrue("2.1", cRequired.length == 1);
assertTrue("2.2", cRequired[0] == a1);
}
+
+ public void testDevModeGenericCapability() throws BundleException {
+ State state = buildDevModeState();
+
+ int bundleID = 0;
+ Hashtable manifest = new Hashtable();
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "A; singleton:=true");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0");
+ manifest.put(Constants.REQUIRE_CAPABILITY, "osgi.service; filter:=\"(objectClass=foo.Bar)\";\n" + " effective:=\"active\"");
+ BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ state.addBundle(a);
+ state.resolve();
+ // a can't be resolved since its required capability is not provided
+
+ assertFalse("0.1", a.isResolved());
+
+ manifest.clear();
+ manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ manifest.put(Constants.BUNDLE_SYMBOLICNAME, "B; singleton:=true");
+ manifest.put(Constants.BUNDLE_VERSION, "1.0");
+ manifest.put(Constants.PROVIDE_CAPABILITY, "osgi.service; objectClass:List<String>=\"foo.Bar\"");
+ BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + "_" + (String) manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ state.addBundle(b);
+ state.resolve();
+ // with bundle B, A is resolvable now
+ assertTrue("0.2", a.isResolved());
+ }
+
}

Back to the top