Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2018-10-25 09:21:42 -0400
committerThomas Watson2018-10-25 09:22:02 -0400
commit7ccdd7e69de9f01a94e786a28611352172e8d424 (patch)
treef42c3bd2445b974684a501244cb5d9c29a5af51e
parentb6a2eeb3e48d7905c4b6cb4f58d91f7ad2563442 (diff)
downloadrt.equinox.framework-7ccdd7e69de9f01a94e786a28611352172e8d424.tar.gz
rt.equinox.framework-7ccdd7e69de9f01a94e786a28611352172e8d424.tar.xz
rt.equinox.framework-7ccdd7e69de9f01a94e786a28611352172e8d424.zip
Bug 540468 - Update to latest felix resolver
Change-Id: Idaa7dd19a8a68d26ebd2cdcbe3351ad53b17cfe8 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java2
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java23
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolutionError.java4
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java6
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/reason/ReasonException.java96
5 files changed, 127 insertions, 4 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 64f4ebc2e..fb9c5289b 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
@@ -1673,7 +1673,7 @@ public class TestModuleContainer extends AbstractTest {
testOut.close();
}
String traceOutput = bytesOut.toString();
- Assert.assertTrue("Wrong traceOutput: " + traceOutput, traceOutput.startsWith("org.osgi.service.resolver.ResolutionException"));
+ Assert.assertTrue("Wrong traceOutput: " + traceOutput, traceOutput.startsWith("org.apache.felix.resolver.reason.ReasonException"));
}
/*
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java
index cc55266e4..bfb1b4681 100755
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java
@@ -24,11 +24,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.felix.resolver.ResolverImpl.PermutationType;
import org.apache.felix.resolver.ResolverImpl.ResolveSession;
+import org.apache.felix.resolver.reason.ReasonException;
import org.apache.felix.resolver.util.*;
import org.osgi.framework.Version;
import org.osgi.framework.namespace.*;
import org.osgi.resource.*;
import org.osgi.service.resolver.HostedCapability;
+import org.osgi.service.resolver.ResolutionException;
import org.osgi.service.resolver.ResolveContext;
class Candidates
@@ -1274,6 +1276,11 @@ class Candidates
return Collections.singleton(requirement);
}
+ @Override
+ public ResolutionException toException() {
+ return new ReasonException(ReasonException.Reason.DynamicImport, getMessage(), null, getUnresolvedRequirements());
+ }
+
}
static class FragmentNotSelectedError extends ResolutionError {
@@ -1288,6 +1295,16 @@ class Candidates
return "Fragment was not selected for attachment: " + resource;
}
+ @Override
+ public Collection<Requirement> getUnresolvedRequirements() {
+ return resource.getRequirements(HostNamespace.HOST_NAMESPACE);
+ }
+
+ @Override
+ public ResolutionException toException() {
+ return new ReasonException(ReasonException.Reason.FragmentNotSelected, getMessage(), null, getUnresolvedRequirements());
+ }
+
}
static class MissingRequirementError extends ResolutionError {
@@ -1318,6 +1335,12 @@ class Candidates
return Collections.singleton(requirement);
}
+ @Override
+ public ResolutionException toException() {
+ return new ReasonException(
+ ReasonException.Reason.MissingRequirement, getMessage(), cause != null ? cause.toException() : null, getUnresolvedRequirements());
+ }
+
}
}
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolutionError.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolutionError.java
index 04138392f..bae01a171 100755
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolutionError.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolutionError.java
@@ -38,9 +38,7 @@ public abstract class ResolutionError {
return Collections.emptyList();
}
- public ResolutionException toException() {
- return new ResolutionException(getMessage(), null, getUnresolvedRequirements());
- }
+ public abstract ResolutionException toException();
@Override
public String toString() {
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java
index e2203595e..43975c7bf 100755
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java
@@ -25,6 +25,7 @@ import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
+import org.apache.felix.resolver.reason.ReasonException;
import org.apache.felix.resolver.util.ArrayMap;
import org.apache.felix.resolver.util.CandidateSelector;
import org.apache.felix.resolver.util.OpenHashMap;
@@ -2437,6 +2438,11 @@ public class ResolverImpl implements Resolver
return cap;
}
+
+ @Override
+ public ResolutionException toException() {
+ return new ReasonException(ReasonException.Reason.UseConstraint, getMessage(), null, getUnresolvedRequirements());
+ }
}
private static class EnhancedExecutor
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/reason/ReasonException.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/reason/ReasonException.java
new file mode 100755
index 000000000..00fd0c7e1
--- /dev/null
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/reason/ReasonException.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.resolver.reason;
+
+import java.util.Collection;
+
+import org.osgi.resource.Requirement;
+import org.osgi.service.resolver.ResolutionException;
+
+/**
+ * An exception that holds the reason for a resolution failure.
+ *
+ * @see {@link ResolutionException}
+ */
+public class ReasonException extends ResolutionException {
+
+ /**
+ * The reasons for resolution failure.
+ */
+ public static enum Reason {
+ /**
+ * Represents an unresolved package referenced by {@code Dynamic-ImportPackage}.
+ * <p>
+ * {@link ReasonException#getUnresolvedRequirements()} will return a
+ * collection containing the single {@code osgi.wiring.package;resolution:=dynamic}
+ * requirement which failed to resolve.
+ * <p>
+ * This reason has no a transitive cause.
+ */
+ DynamicImport,
+
+ /**
+ * Represents the scenario where a fragment matches a host but is not
+ * selected because another fragment with the same {@code Bundle-SymbolicName}
+ * already matched, usually a fragment of a higher version.
+ * <p>
+ * {@link ReasonException#getUnresolvedRequirements()} will return
+ * a collection containing the single {@code osgi.wiring.host} requirement of
+ * the fragment.
+ * <p>
+ * This reason has no a transitive cause.
+ */
+ FragmentNotSelected,
+
+ /**
+ * Represents the scenario where a requirement could not be resolved.
+ * <p>
+ * {@link ReasonException#getUnresolvedRequirements()} will return
+ * a collection containing a single requirement that didn't resolve.
+ * <p>
+ * This reason may have a transitive cause.
+ */
+ MissingRequirement,
+
+ /**
+ * Represents a failure in the <em>use constraints</em> of a bundle.
+ * <p>
+ * {@link ReasonException#getUnresolvedRequirements()} will return
+ * a collection containing a single requirement to blame for the use constraint
+ * violation.
+ * <p>
+ * This reason has no a transitive cause.
+ */
+ UseConstraint
+ }
+
+ private static final long serialVersionUID = -5276675175114379539L;
+
+ public ReasonException(Reason reason, String message, Throwable cause, Collection<Requirement> unresolvedRequirements) {
+ super(message, cause, unresolvedRequirements);
+ this.reason = reason;
+ }
+
+ public Reason getReason() {
+ return reason;
+ }
+
+ private final Reason reason;
+
+}

Back to the top