Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-06-01 20:30:24 +0000
committerThomas Watson2017-06-16 12:38:08 +0000
commit943977005bfc2a3c04daca26822418310029133f (patch)
treee8accb568fea9950462ed41e23aa2f3fa2f3673a /bundles/org.eclipse.osgi/felix
parentc91ca50fbdc7aa849a03bad83e51ce8141c498d5 (diff)
downloadrt.equinox.framework-943977005bfc2a3c04daca26822418310029133f.tar.gz
rt.equinox.framework-943977005bfc2a3c04daca26822418310029133f.tar.xz
rt.equinox.framework-943977005bfc2a3c04daca26822418310029133f.zip
Bug 492825 - [osgi R7] Resolver specification updates for version 1.1
Implement resovlveDynamic and findRelatedResources Change-Id: I0841246411734e191b62d24a10f7918f904f932d Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi/felix')
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java4
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/FelixResolveContext.java56
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java47
3 files changed, 29 insertions, 78 deletions
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 b87c6ac73..af597d487 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
@@ -184,9 +184,9 @@ class Candidates
addCandidates(result.candidates);
result.candidates = null;
result.remaining = null;
- if ((rc instanceof FelixResolveContext) && !Util.isFragment(resource))
+ if (!Util.isFragment(resource))
{
- Collection<Resource> ondemandFragments = ((FelixResolveContext) rc).getOndemandResources(resource);
+ Collection<Resource> ondemandFragments = rc.findRelatedResources(resource);
for (Resource fragment : ondemandFragments)
{
if (m_session.isValidOnDemandResource(fragment))
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/FelixResolveContext.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/FelixResolveContext.java
index 9782d0a02..ddfb49bcf 100755
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/FelixResolveContext.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/FelixResolveContext.java
@@ -18,46 +18,22 @@
*/package org.apache.felix.resolver;
import java.util.Collection;
-
import org.osgi.framework.namespace.PackageNamespace;
-import org.osgi.resource.Resource;
-import org.osgi.resource.Wire;
-import org.osgi.resource.Wiring;
-
-public interface FelixResolveContext
-{
- /**
- * Return the resources that the resolver should attempt to resolve on
- * demand for specified resource which is being resolved. Inability to
- * resolve one of the on demand resources will not result in a resolution
- * exception.
- *
- * <p>
- * The resolver will ask for on demand resources for each resource that is
- * getting pulled into a resolve operation. An example of an on demand
- * resource is a fragment. When a host is being resolved the resolve context
- * will be asked if any additional resources should be added to the resolve
- * operation. The resolve context may decide that the potential fragments of
- * the host should be resolved along with the host.
- *
- * @return A collection of the resources that the resolver should attempt to
- * resolve for this resolve context. May be empty if there are no on demand
- * resources. The returned collection may be unmodifiable.
- */
- public Collection<Resource> getOndemandResources(Resource host);
+import org.osgi.resource.*;
- /**
- * Returns the subset of {@link Wiring#getRequiredResourceWires(String) require wires}
- * that provide wires to {@link Capability capabilities} which substitute capabilities
- * of the given wiring. For example, when a {@link PackageNamespace package} name is both
- * provided and required by the same resource. If the package requirement is resolved
- * to a capability hosted by a different wiring then the package capability is
- * considered to be substituted.
- *
- * @param wiring the wiring to get the substitution wires from
- * @return A collection containing a snapshot of the substitution {@link Wire}s
- * for the {@link Requirement requirements} of this wiring, or an empty list
- * if this wiring has no substitution wires.
- */
- public Collection<Wire> getSubstitutionWires(Wiring wiring);
+public interface FelixResolveContext {
+ /**
+ * Returns the subset of {@link Wiring#getRequiredResourceWires(String) require wires}
+ * that provide wires to {@link Capability capabilities} which substitute capabilities
+ * of the given wiring. For example, when a {@link PackageNamespace package} name is both
+ * provided and required by the same resource. If the package requirement is resolved
+ * to a capability hosted by a different wiring then the package capability is
+ * considered to be substituted.
+ *
+ * @param wiring the wiring to get the substitution wires from
+ * @return A collection containing a snapshot of the substitution {@link Wire}s
+ * for the {@link Requirement requirements} of this wiring, or an empty list
+ * if this wiring has no substitution wires.
+ */
+ public Collection<Wire> getSubstitutionWires(Wiring wiring);
}
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 128482c27..7735df71f 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
@@ -600,43 +600,18 @@ public class ResolverImpl implements Resolver
return error;
}
- /**
- * Resolves a dynamic requirement for the specified host resource using the
- * specified {@link ResolveContext}. The dynamic requirement may contain
- * wild cards in its filter for the package name. The matching candidates
- * are used to resolve the requirement and the resolve context is not asked
- * to find providers for the dynamic requirement. The host resource is
- * expected to not be a fragment, to already be resolved and have an
- * existing wiring provided by the resolve context.
- * <p>
- * This operation may resolve additional resources in order to resolve the
- * dynamic requirement. The returned map will contain entries for each
- * resource that got resolved in addition to the specified host resource.
- * The wire list for the host resource will only contain a single wire which
- * is for the dynamic requirement.
- *
- * @param rc the resolve context
- * @param host the hosting resource
- * @param dynamicReq the dynamic requirement
- * @param matches a list of matching capabilities
- * @return The new resources and wires required to satisfy the specified
- * dynamic requirement. The returned map is the property of the caller and
- * can be modified by the caller.
- * @throws ResolutionException
- */
- public Map<Resource, List<Wire>> resolve(
- ResolveContext rc, Resource host, Requirement dynamicReq,
- List<Capability> matches)
- throws ResolutionException
+ public Map<Resource,List<Wire>> resolveDynamic(ResolveContext context,
+ Wiring hostWiring, Requirement dynamicRequirement)
+ throws ResolutionException
{
+ Resource host = hostWiring.getResource();
+ List<Capability> matches = context.findProviders(dynamicRequirement);
// We can only create a dynamic import if the following
// conditions are met:
- // 1. The specified resource is resolved.
- // 2. The package in question is not already imported.
- // 3. The package in question is not accessible via require-bundle.
- // 4. The package in question is not exported by the resource.
- // 5. The package in question matches a dynamic import of the resource.
- if (!matches.isEmpty() && rc.getWirings().containsKey(host))
+ // 1. The package in question is not already imported.
+ // 2. The package in question is not accessible via require-bundle.
+ // 3. The package in question is not exported by the resource.
+ if (!matches.isEmpty())
{
// Make sure all matching candidates are packages.
for (Capability cap : matches)
@@ -647,11 +622,11 @@ public class ResolverImpl implements Resolver
"Matching candidate does not provide a package name.");
}
}
- ResolveSession session = new ResolveSession(rc, new DumbExecutor(), host, dynamicReq, matches);
+ ResolveSession session = new ResolveSession(context, new DumbExecutor(), host, dynamicRequirement, matches);
return doResolve(session);
}
- return Collections.emptyMap();
+ throw new Candidates.MissingRequirementError(dynamicRequirement).toException();
}
private static List<WireCandidate> getWireCandidates(ResolveSession session, Candidates allCandidates, Resource resource)

Back to the top