[Git][java-team/felix-resolver][upstream] 3 commits: New upstream version 2.0.0
Emmanuel Bourg (@ebourg)
gitlab at salsa.debian.org
Fri Nov 20 08:00:35 GMT 2026
Emmanuel Bourg pushed to branch upstream at Debian Java Maintainers / felix-resolver
Commits:
41c9353d by Emmanuel Bourg at 2026-11-19T11:59:34+01:00
New upstream version 2.0.0
- - - - -
3144b038 by Emmanuel Bourg at 2026-11-19T11:59:35+01:00
New upstream version 2.0.2
- - - - -
9c1f6e34 by Emmanuel Bourg at 2026-11-19T11:59:35+01:00
New upstream version 2.0.4
- - - - -
17 changed files:
- DEPENDENCIES
- NOTICE
- doc/changelog.txt
- pom.xml
- src/main/appended-resources/META-INF/NOTICE
- src/main/java/org/apache/felix/resolver/Candidates.java
- − src/main/java/org/apache/felix/resolver/FelixResolveContext.java
- src/main/java/org/apache/felix/resolver/ResolverImpl.java
- src/main/java/org/osgi/service/resolver/HostedCapability.java
- src/main/java/org/osgi/service/resolver/ResolutionException.java
- src/main/java/org/osgi/service/resolver/ResolveContext.java
- src/main/java/org/osgi/service/resolver/Resolver.java
- src/main/java/org/osgi/service/resolver/package-info.java
- − src/main/java/org/osgi/service/resolver/packageinfo
- src/test/java/org/apache/felix/resolver/test/ResolverTest.java
- src/test/java/org/apache/felix/resolver/test/util/IterativeResolver.java
- src/test/java/org/apache/felix/resolver/test/util/ResolveContextImpl.java
Changes:
=====================================
DEPENDENCIES
=====================================
@@ -10,6 +10,10 @@ From: 'OSGi Alliance' (http://www.osgi.org)
- osgi.core (http://www.osgi.org) org.osgi:org.osgi.core:jar:5.0.0
License: Apache License, Version 2.0 (http://opensource.org/licenses/apache2.0.php)
+From: 'OSGi Alliance' (http://www.osgi.org/)
+ - org.osgi:osgi.annotation (http://www.osgi.org/) org.osgi:osgi.annotation:jar:6.0.1
+ License: Apache License, Version 2.0 (http://opensource.org/licenses/apache2.0.php)
+
=====================================
NOTICE
=====================================
@@ -1,6 +1,6 @@
Apache Felix Resolver
-Copyright 2006-2018 The Apache Software Foundation
+Copyright 2006-2021 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
@@ -8,5 +8,5 @@ The Apache Software Foundation (http://www.apache.org/).
This product includes software developed at
The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2015).
+Copyright (c) OSGi Alliance (2000, 2020).
Licensed under the Apache License 2.0.
=====================================
doc/changelog.txt
=====================================
@@ -1,3 +1,22 @@
+2.0.4
+----
+
+** Improvement
+ * [FELIX-6398] - Update framework packages to osgi.core 8
+
+2.0.2
+-----
+
+** Bug
+ * [FELIX-6140] - possible deadlock in ResolverImpl.EnhancedExecutor.await()
+ * [FELIX-6212] - Issues with uses capability checking with split packages and reexport
+
+2.0.0
+-----
+
+** New Feature
+ * [FELIX-5482] - Contribute Resolver 1.1 implementation for OSGi R7
+
1.16.0
------
=====================================
pom.xml
=====================================
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>felix-parent</artifactId>
- <version>3</version>
+ <version>5</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -29,14 +29,20 @@
<description>
Provide OSGi resolver service.
</description>
- <version>1.16.0</version>
+ <version>2.0.4</version>
<artifactId>org.apache.felix.resolver</artifactId>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.resolver-1.16.0</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.resolver-1.16.0</developerConnection>
- <url>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.resolver-1.16.0</url>
+ <connection>scm:git:https://github.com/apache/felix-dev.git</connection>
+ <developerConnection>scm:git:https://github.com/apache/felix-dev.git</developerConnection>
+ <url>https://gitbox.apache.org/repos/asf?p=felix-dev.git</url>
+ <tag>org.apache.felix.resolver-2.0.4</tag>
</scm>
<dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.annotation</artifactId>
+ <version>6.0.1</version>
+ </dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
@@ -54,9 +60,15 @@
<version>1.8.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<properties>
- <felix.java.version>5</felix.java.version>
+ <felix.java.version>6</felix.java.version>
</properties>
<build>
<plugins>
=====================================
src/main/appended-resources/META-INF/NOTICE
=====================================
@@ -1,4 +1,4 @@
This product includes software developed at
The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2015).
+Copyright (c) OSGi Alliance (2000, 2020).
Licensed under the Apache License 2.0.
=====================================
src/main/java/org/apache/felix/resolver/Candidates.java
=====================================
@@ -186,17 +186,15 @@ class Candidates
addCandidates(result.candidates);
result.candidates = null;
result.remaining = null;
- if ((rc instanceof FelixResolveContext) && !Util.isFragment(resource))
+ Collection<Resource> relatedResources = rc.findRelatedResources(resource);
+ m_session.setRelatedResources(resource, relatedResources);
+ for (Resource relatedResource : relatedResources)
{
- Collection<Resource> ondemandFragments = ((FelixResolveContext) rc).getOndemandResources(resource);
- for (Resource fragment : ondemandFragments)
+ if (m_session.isValidRelatedResource(relatedResource))
{
- if (m_session.isValidOnDemandResource(fragment))
- {
- // This resource is a valid on demand resource;
- // populate it now, consider it optional
- toPopulate.addFirst(fragment);
- }
+ // This resource is a valid related resource;
+ // populate it now, consider it optional
+ toPopulate.addFirst(relatedResource);
}
}
continue;
@@ -1239,14 +1237,14 @@ class Candidates
for (Requirement dependent : dependents)
{
CandidateSelector dependentSelector = m_candidateMap.get(
- dependent);
+ dependent);
// If the dependent selector only has one capability left then check if
// the current candidate is the selector's current candidate.
if (dependentSelector != null
- && dependentSelector.getRemainingCandidateCount() <= 1)
+ && dependentSelector.getRemainingCandidateCount() <= 1)
{
if (current.equals(
- dependentSelector.getCurrentCandidate()))
+ dependentSelector.getCurrentCandidate()))
{
// return false since we do not want to allow this requirement
// to substitute the capability
=====================================
src/main/java/org/apache/felix/resolver/FelixResolveContext.java deleted
=====================================
@@ -1,63 +0,0 @@
-/*
- * 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;
-
-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);
-
- /**
- * 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);
-}
=====================================
src/main/java/org/apache/felix/resolver/ResolverImpl.java
=====================================
@@ -22,7 +22,6 @@ import java.security.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.felix.resolver.reason.ReasonException;
@@ -54,7 +53,7 @@ public class ResolverImpl implements Resolver
// Note this class is not thread safe.
// Only use in the context of a single thread.
- static class ResolveSession
+ static class ResolveSession implements Runnable
{
// Holds the resolve context for this session
private final ResolveContext m_resolveContext;
@@ -63,9 +62,11 @@ public class ResolverImpl implements Resolver
private final Resource m_dynamicHost;
private final Requirement m_dynamicReq;
private final List<Capability> m_dynamicCandidates;
- // keeps track of valid on demand fragments that we have seen.
+ // keeps track of valid related resources that we have seen.
// a null value or TRUE indicate it is valid
- Map<Resource, Boolean> m_validOnDemandResources = new HashMap<Resource, Boolean>(0);
+ private Map<Resource, Boolean> m_validRelatedResources = new HashMap<Resource, Boolean>(0);
+ // keeps track of related resources for each resource
+ private Map<Resource, Collection<Resource>> m_relatedResources = new HashMap<Resource, Collection<Resource>>(0);
// Holds candidate permutations based on permutating "uses" chains.
// These permutations are given higher priority.
private final List<Candidates> m_usesPermutations = new LinkedList<Candidates>();
@@ -89,8 +90,19 @@ public class ResolverImpl implements Resolver
private final Set<Requirement> m_sub_mutated = new HashSet<Requirement>();
private final ConcurrentMap<String, List<String>> m_usesCache = new ConcurrentHashMap<String, List<String>>();
private ResolutionError m_currentError;
+ volatile private CancellationException m_isCancelled = null;
- ResolveSession(ResolveContext resolveContext, Executor executor, Resource dynamicHost, Requirement dynamicReq, List<Capability> dynamicCandidates)
+ static ResolveSession createSession(ResolveContext resolveContext, Executor executor, Resource dynamicHost, Requirement dynamicReq, List<Capability> dynamicCandidates)
+ {
+ ResolveSession session = new ResolveSession(resolveContext, executor, dynamicHost, dynamicReq, dynamicCandidates);
+ // call onCancel first
+ session.getContext().onCancel(session);
+ // now gather the mandatory and optional resources
+ session.initMandatoryAndOptionalResources();
+ return session;
+ }
+
+ private ResolveSession(ResolveContext resolveContext, Executor executor, Resource dynamicHost, Requirement dynamicReq, List<Capability> dynamicCandidates)
{
m_resolveContext = resolveContext;
m_executor = executor;
@@ -101,12 +113,18 @@ public class ResolverImpl implements Resolver
m_mandatoryResources = Collections.singletonList(dynamicHost);
m_optionalResources = Collections.emptyList();
} else {
- // Make copies of arguments in case we want to modify them.
- m_mandatoryResources = new ArrayList<Resource>(resolveContext.getMandatoryResources());
- m_optionalResources = new ArrayList<Resource>(resolveContext.getOptionalResources());
+ // Do not call resolve context yet, onCancel must be called first
+ m_mandatoryResources = new ArrayList<Resource>();
+ m_optionalResources = new ArrayList<Resource>();
}
}
+ private void initMandatoryAndOptionalResources() {
+ if (!isDynamic()) {
+ m_mandatoryResources.addAll(getContext().getMandatoryResources());
+ m_optionalResources.addAll(getContext().getOptionalResources());
+ }
+ }
Candidates getMultipleCardCandidates()
{
return m_multipleCardCandidates;
@@ -282,28 +300,52 @@ public class ResolverImpl implements Resolver
return m_dynamicCandidates;
}
- public boolean isValidOnDemandResource(Resource fragment) {
- Boolean valid = m_validOnDemandResources.get(fragment);
+ public boolean isValidRelatedResource(Resource resource) {
+ Boolean valid = m_validRelatedResources.get(resource);
if (valid == null)
{
- // Mark this resource as a valid on demand resource
- m_validOnDemandResources.put(fragment, Boolean.TRUE);
+ // Mark this resource as a valid related resource
+ m_validRelatedResources.put(resource, Boolean.TRUE);
valid = Boolean.TRUE;
}
return valid;
}
- public boolean invalidateOnDemandResource(Resource faultyResource) {
- Boolean valid = m_validOnDemandResources.get(faultyResource);
+ public boolean invalidateRelatedResource(Resource faultyResource) {
+ Boolean valid = m_validRelatedResources.get(faultyResource);
if (valid != null && valid)
{
- // This was an ondemand resource.
+ // This was related resource.
// Invalidate it and try again.
- m_validOnDemandResources.put(faultyResource, Boolean.FALSE);
+ m_validRelatedResources.put(faultyResource, Boolean.FALSE);
return true;
}
return false;
}
+
+ public Collection<Resource> getRelatedResources(Resource resource) {
+ Collection<Resource> related = m_relatedResources.get(resource);
+ return related == null ? Collections.<Resource> emptyList() : related;
+ }
+
+ public void setRelatedResources(Resource resource, Collection<Resource> related) {
+ m_relatedResources.put(resource, related);
+ }
+
+ @Override
+ public void run() {
+ m_isCancelled = new CancellationException();
+ }
+
+ boolean isCancelled() {
+ return m_isCancelled != null;
+ }
+
+ void checkForCancel() throws ResolutionException {
+ if (isCancelled()) {
+ throw new ResolutionException("Resolver operation has been cancelled.", m_isCancelled, null);
+ }
+ }
}
public ResolverImpl(Logger logger)
@@ -374,13 +416,12 @@ public class ResolverImpl implements Resolver
public Map<Resource, List<Wire>> resolve(ResolveContext rc, Executor executor) throws ResolutionException
{
- ResolveSession session = new ResolveSession(rc, executor, null, null, null);
+ ResolveSession session = ResolveSession.createSession(rc, executor, null, null, null);
return doResolve(session);
}
private Map<Resource, List<Wire>> doResolve(ResolveSession session) throws ResolutionException {
Map<Resource, List<Wire>> wireMap = new HashMap<Resource, List<Wire>>();
-
boolean retry;
do
{
@@ -394,6 +435,7 @@ public class ResolverImpl implements Resolver
Map<Resource, ResolutionError> faultyResources = new HashMap<Resource, ResolutionError>();
Candidates allCandidates = findValidCandidates(session, faultyResources);
+ session.checkForCancel();
// If there is a resolve exception, then determine if an
// optionally resolved resource is to blame (typically a fragment).
@@ -405,7 +447,7 @@ public class ResolverImpl implements Resolver
retry = (session.getOptionalResources().removeAll(resourceKeys));
for (Resource faultyResource : resourceKeys)
{
- if (session.invalidateOnDemandResource(faultyResource))
+ if (session.invalidateRelatedResource(faultyResource))
{
retry = true;
}
@@ -433,8 +475,7 @@ public class ResolverImpl implements Resolver
}
if (session.isDynamic() )
{
- wireMap = populateDynamicWireMap(session.getContext(),
- session.getDynamicHost(), session.getDynamicRequirement(),
+ wireMap = populateDynamicWireMap(session,
wireMap, allCandidates);
}
else
@@ -445,7 +486,7 @@ public class ResolverImpl implements Resolver
{
wireMap =
populateWireMap(
- session.getContext(), allCandidates.getWrappedHost(resource),
+ session, allCandidates.getWrappedHost(resource),
wireMap, allCandidates);
}
}
@@ -552,7 +593,7 @@ public class ResolverImpl implements Resolver
}
}
}
- while (session.getCurrentError() != null);
+ while (!session.isCancelled() && session.getCurrentError() != null);
return allCandidates;
}
@@ -580,6 +621,9 @@ public class ResolverImpl implements Resolver
rethrow = checkPackageSpaceConsistency(
session, entry.getValue(),
allCandidates, session.isDynamic(), resourcePkgMap, resultCache);
+ if (session.isCancelled()) {
+ return null;
+ }
if (rethrow != null)
{
Resource faultyResource = entry.getKey();
@@ -601,43 +645,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)
@@ -648,11 +667,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 = ResolveSession.createSession(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)
@@ -788,7 +807,7 @@ public class ResolverImpl implements Resolver
return resourcePkgs;
}
- private static void computeUses(
+ private void computeUses(
ResolveSession session,
Map<Resource, List<WireCandidate>> allWireCandidates,
Map<Resource, Packages> resourcePkgMap,
@@ -997,7 +1016,7 @@ public class ResolverImpl implements Resolver
}
}
- private static void mergeUses(
+ private void mergeUses(
ResolveSession session, Resource current, Packages currentPkgs,
Capability mergeCap, List<Requirement> blameReqs, Capability matchingCap,
Map<Resource, Packages> resourcePkgMap,
@@ -1074,32 +1093,36 @@ public class ResolverImpl implements Resolver
continue;
}
- ArrayMap<Capability, UsedBlames> usedPkgBlames = currentPkgs.m_usedPkgs.getOrCompute(usedPkgName);
+ ArrayMap<Set<Capability>, UsedBlames> usedPkgBlames = currentPkgs.m_usedPkgs.getOrCompute(usedPkgName);
+ List<Blame> newBlames = new ArrayList<Blame>();
for (Blame blame : candSourceBlames)
{
+ List<Requirement> newBlameReqs;
if (blame.m_reqs != null)
{
- List<Requirement> blameReqs2 = new ArrayList<Requirement>(blameReqs.size() + 1);
- blameReqs2.addAll(blameReqs);
+ newBlameReqs = new ArrayList<Requirement>(blameReqs.size() + 1);
+ newBlameReqs.addAll(blameReqs);
// Only add the last requirement in blame chain because
// that is the requirement wired to the blamed capability
- blameReqs2.add(blame.m_reqs.get(blame.m_reqs.size() - 1));
- addUsedBlame(usedPkgBlames, blame.m_cap, blameReqs2, matchingCap);
- mergeUses(session, current, currentPkgs, blame.m_cap, blameReqs2, matchingCap,
- resourcePkgMap, cycleMap);
+ newBlameReqs.add(blame.m_reqs.get(blame.m_reqs.size() - 1));
}
else
{
- addUsedBlame(usedPkgBlames, blame.m_cap, blameReqs, matchingCap);
- mergeUses(session, current, currentPkgs, blame.m_cap, blameReqs, matchingCap,
- resourcePkgMap, cycleMap);
+ newBlameReqs = blameReqs;
}
+ newBlames.add(new Blame(blame.m_cap, newBlameReqs));
+ }
+ addUsedBlames(usedPkgBlames, newBlames, matchingCap, resourcePkgMap);
+ for (Blame newBlame : newBlames)
+ {
+ mergeUses(session, current, currentPkgs, newBlame.m_cap, newBlame.m_reqs, matchingCap,
+ resourcePkgMap, cycleMap);
}
}
}
}
- private static Map<Resource, Packages> calculatePackageSpaces(
+ private Map<Resource, Packages> calculatePackageSpaces(
final ResolveSession session,
final Candidates allCandidates,
Collection<Resource> hosts)
@@ -1256,18 +1279,39 @@ public class ResolverImpl implements Resolver
return uses;
}
- private static void addUsedBlame(
- ArrayMap<Capability, UsedBlames> usedBlames, Capability usedCap,
- List<Requirement> blameReqs, Capability matchingCap)
+ private void addUsedBlames(
+ ArrayMap<Set<Capability>, UsedBlames> usedBlames, Collection<Blame> blames, Capability matchingCap, Map<Resource, Packages> resourcePkgMap)
{
- // Create a new Blame based off the used capability and the
- // blame chain requirements.
- Blame newBlame = new Blame(usedCap, blameReqs);
- // Find UsedBlame that uses the same capablity as the new blame.
- UsedBlames addToBlame = usedBlames.getOrCompute(usedCap);
- // Add the new Blame and record the matching capability cause
+ Set<Capability> usedCaps;
+ if (blames.size() == 1)
+ {
+ usedCaps = getPackageSources(blames.iterator().next().m_cap, resourcePkgMap);
+ }
+ else
+ {
+ usedCaps = new HashSet<Capability>();
+ for (Blame blame : blames)
+ {
+ usedCaps.addAll(getPackageSources(blame.m_cap, resourcePkgMap));
+ }
+ }
+ if (usedCaps.isEmpty())
+ {
+ // This most likely is an issue with the resolve context.
+ // To avoid total failure we do not add blames if there is
+ // no source capabilities
+ m_logger.log(Logger.LOG_INFO,
+ "Package sources are empty for used capability: " + blames);
+ return;
+ }
+ // Find UsedBlame that uses the same capability as the new blame.
+ UsedBlames addToBlame = usedBlames.getOrCompute(usedCaps);
+ // Add the new Blames and record the matching capability cause
// in case the root requirement has multiple cardinality.
- addToBlame.addBlame(newBlame, matchingCap);
+ for (Blame blame : blames)
+ {
+ addToBlame.addBlame(blame, matchingCap);
+ }
}
private ResolutionError checkPackageSpaceConsistency(
@@ -1332,7 +1376,6 @@ public class ResolverImpl implements Resolver
}
}
}
-
// IMPLEMENTATION NOTE:
// Below we track the mutated reqs that have been permuted
// in a single candidates permutation. This permutation may contain a
@@ -1349,20 +1392,20 @@ public class ResolverImpl implements Resolver
{
String pkgName = entry.getKey();
Blame exportBlame = entry.getValue();
- ArrayMap<Capability, UsedBlames> pkgBlames = pkgs.m_usedPkgs.get(pkgName);
+ ArrayMap<Set<Capability>, UsedBlames> pkgBlames = pkgs.m_usedPkgs.get(pkgName);
if (pkgBlames == null)
{
continue;
}
for (UsedBlames usedBlames : pkgBlames.values())
{
- if (!isCompatible(exportBlame, usedBlames.m_cap, resourcePkgMap))
+ if (!isCompatible(exportBlame, usedBlames.m_caps, resourcePkgMap))
{
mutated = (mutated != null)
- ? mutated
- : new HashSet<Requirement>();
+ ? mutated
+ : new HashSet<Requirement>();
rethrow = permuteUsedBlames(session, rethrow, allCandidates, resource,
- pkgName, null, usedBlames, permRef1, permRef2, mutated);
+ pkgName, null, usedBlames, permRef1, permRef2, mutated);
}
}
@@ -1402,7 +1445,7 @@ public class ResolverImpl implements Resolver
for (Entry<String, List<Blame>> entry : allImportRequirePkgs.fast())
{
String pkgName = entry.getKey();
- ArrayMap<Capability, UsedBlames> pkgBlames = pkgs.m_usedPkgs.get(pkgName);
+ ArrayMap<Set<Capability>, UsedBlames> pkgBlames = pkgs.m_usedPkgs.get(pkgName);
if (pkgBlames == null)
{
continue;
@@ -1411,12 +1454,11 @@ public class ResolverImpl implements Resolver
for (UsedBlames usedBlames : pkgBlames.values())
{
- if (!isCompatible(requirementBlames, usedBlames.m_cap, resourcePkgMap))
+ if (!isCompatible(requirementBlames, usedBlames.m_caps, resourcePkgMap))
{
mutated = (mutated != null)
- ? mutated
- : new HashSet<Requirement>();
- // Split packages, need to think how to get a good message for split packages (sigh)
+ ? mutated
+ : new HashSet<Requirement>();// Split packages, need to think how to get a good message for split packages (sigh)
// For now we just use the first requirement that brings in the package that conflicts
Blame requirementBlame = requirementBlames.get(0);
rethrow = permuteUsedBlames(session, rethrow, allCandidates, resource, pkgName, requirementBlame, usedBlames, permRef1, permRef2, mutated);
@@ -1482,6 +1524,9 @@ public class ResolverImpl implements Resolver
rethrow = checkPackageSpaceConsistency(
session, cap.getResource(),
allCandidates, false, resourcePkgMap, resultCache);
+ if (session.isCancelled()) {
+ return null;
+ }
if (rethrow != null)
{
// If the lower level check didn't create any permutations,
@@ -1499,12 +1544,12 @@ public class ResolverImpl implements Resolver
}
return null;
}
-
+
private ResolutionError permuteUsedBlames(ResolveSession session,
- ResolutionError rethrow, Candidates allCandidates, Resource resource,
- String pkgName, Blame requirementBlame, UsedBlames usedBlames,
- AtomicReference<Candidates> permRef1, AtomicReference<Candidates> permRef2,
- Set<Requirement> mutated)
+ ResolutionError rethrow, Candidates allCandidates, Resource resource,
+ String pkgName, Blame requirementBlame, UsedBlames usedBlames,
+ AtomicReference<Candidates> permRef1, AtomicReference<Candidates> permRef2,
+ Set<Requirement> mutated)
{
for (Blame usedBlame : usedBlames.m_blames)
{
@@ -1520,12 +1565,12 @@ public class ResolverImpl implements Resolver
if (requirementBlame == null)
{
rethrow = new UseConstraintError(session.getContext(), allCandidates,
- resource, pkgName, usedBlame);
+ resource, pkgName, usedBlame);
}
else
{
rethrow = new UseConstraintError(session.getContext(), allCandidates,
- resource, pkgName, requirementBlame, usedBlame);
+ resource, pkgName, requirementBlame, usedBlame);
}
}
@@ -1565,8 +1610,7 @@ public class ResolverImpl implements Resolver
return rethrow;
}
- private boolean permuteUsedBlameRequirement(Requirement req, Set<Requirement> mutated,
- Candidates permutation)
+ private boolean permuteUsedBlameRequirement(Requirement req, Set<Requirement> mutated, Candidates permutation)
{
// Sanity check for multiple.
if (Util.isMultiple(req))
@@ -1592,7 +1636,7 @@ public class ResolverImpl implements Resolver
}
return false;
}
-
+
private static OpenHashMap<String, Blame> calculateExportedPackages(
ResolveSession session,
Candidates allCandidates,
@@ -1624,17 +1668,7 @@ public class ResolverImpl implements Resolver
// map to determine which exports are substitutable.
if (wiring != null)
{
- Collection<Wire> substitutionWires;
- if (session.getContext() instanceof FelixResolveContext)
- {
- substitutionWires = ((FelixResolveContext) session.getContext()).getSubstitutionWires(
- wiring);
- }
- else
- {
- substitutionWires = getSubstitutionWires(wiring);
- }
- for (Wire wire : substitutionWires)
+ for (Wire wire : session.getContext().getSubstitutionWires(wiring))
{
Capability cap = wire.getCapability();
if (!cap.getResource().equals(wire.getProvider()))
@@ -1675,65 +1709,21 @@ public class ResolverImpl implements Resolver
return exports;
}
- private static Collection<Wire> getSubstitutionWires(Wiring wiring)
- {
- Set<String> exportNames = new HashSet<String>();
- for (Capability cap : wiring.getResource().getCapabilities(null))
- {
- if (PackageNamespace.PACKAGE_NAMESPACE.equals(cap.getNamespace()))
- {
- exportNames.add(
- (String) cap.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
- }
- }
- // Add fragment exports
- for (Wire wire : wiring.getProvidedResourceWires(null))
- {
- if (HostNamespace.HOST_NAMESPACE.equals(wire.getCapability().getNamespace()))
- {
- for (Capability cap : wire.getRequirement().getResource().getCapabilities(
- null))
- {
- if (PackageNamespace.PACKAGE_NAMESPACE.equals(cap.getNamespace()))
- {
- exportNames.add((String) cap.getAttributes().get(
- PackageNamespace.PACKAGE_NAMESPACE));
- }
- }
- }
- }
- Collection<Wire> substitutionWires = new ArrayList<Wire>();
- for (Wire wire : wiring.getRequiredResourceWires(null))
- {
- if (PackageNamespace.PACKAGE_NAMESPACE.equals(
- wire.getCapability().getNamespace()))
- {
- if (exportNames.contains(wire.getCapability().getAttributes().get(
- PackageNamespace.PACKAGE_NAMESPACE)))
- {
- substitutionWires.add(wire);
- }
- }
- }
- return substitutionWires;
- }
-
private static boolean isCompatible(
- Blame currentBlame, Capability candCap,
+ Blame currentBlame, Set<Capability> candSources,
Map<Resource, Packages> resourcePkgMap)
{
- if (currentBlame.m_cap.equals(candCap))
+ if (candSources.contains(currentBlame.m_cap))
{
return true;
}
- Set<Capability> candSources = getPackageSources(candCap, resourcePkgMap);
Set<Capability> currentSources = getPackageSources(currentBlame.m_cap, resourcePkgMap);
return currentSources.containsAll(candSources)
|| candSources.containsAll(currentSources);
}
private static boolean isCompatible(
- List<Blame> currentBlames, Capability candCap,
+ List<Blame> currentBlames, Set<Capability> candSources,
Map<Resource, Packages> resourcePkgMap)
{
int size = currentBlames.size();
@@ -1742,7 +1732,7 @@ public class ResolverImpl implements Resolver
case 0:
return true;
case 1:
- return isCompatible(currentBlames.get(0), candCap, resourcePkgMap);
+ return isCompatible(currentBlames.get(0), candSources, resourcePkgMap);
default:
Set<Capability> currentSources = new HashSet<Capability>(currentBlames.size());
for (Blame currentBlame : currentBlames)
@@ -1750,7 +1740,6 @@ public class ResolverImpl implements Resolver
Set<Capability> blameSources = getPackageSources(currentBlame.m_cap, resourcePkgMap);
currentSources.addAll(blameSources);
}
- Set<Capability> candSources = getPackageSources(candCap, resourcePkgMap);
return currentSources.containsAll(candSources)
|| candSources.containsAll(currentSources);
}
@@ -1881,11 +1870,11 @@ public class ResolverImpl implements Resolver
}
private static Map<Resource, List<Wire>> populateWireMap(
- ResolveContext rc, Resource resource,
+ ResolveSession session, Resource resource,
Map<Resource, List<Wire>> wireMap, Candidates allCandidates)
{
Resource unwrappedResource = getDeclaredResource(resource);
- if (!rc.getWirings().containsKey(unwrappedResource)
+ if (!session.getContext().getWirings().containsKey(unwrappedResource)
&& !wireMap.containsKey(unwrappedResource))
{
wireMap.put(unwrappedResource, Collections.<Wire>emptyList());
@@ -1908,7 +1897,7 @@ public class ResolverImpl implements Resolver
|| !resource.equals(cand.getResource()))
{
// Populate wires for the candidate
- populateWireMap(rc, cand.getResource(),
+ populateWireMap(session, cand.getResource(),
wireMap, allCandidates);
Resource provider;
@@ -1988,7 +1977,7 @@ public class ResolverImpl implements Resolver
// Otherwise, if the fragment isn't already resolved and
// this is the first time we are seeing it, then create
// a wire for the non-payload requirement.
- else if (!rc.getWirings().containsKey(fragment)
+ else if (!session.getContext().getWirings().containsKey(fragment)
&& !wireMap.containsKey(fragment))
{
Wire wire = createWire(req, allCandidates);
@@ -2004,6 +1993,12 @@ public class ResolverImpl implements Resolver
wireMap.put(fragment, fragmentWires);
}
}
+ // now make sure any related resources are populated
+ for (Resource related : session.getRelatedResources(unwrappedResource)) {
+ if (allCandidates.isPopulated(related)) {
+ populateWireMap(session, related, wireMap, allCandidates);
+ }
+ }
}
return wireMap;
@@ -2038,31 +2033,31 @@ public class ResolverImpl implements Resolver
}
private static Map<Resource, List<Wire>> populateDynamicWireMap(
- ResolveContext rc, Resource resource, Requirement dynReq,
- Map<Resource, List<Wire>> wireMap, Candidates allCandidates)
+ ResolveSession session, Map<Resource,
+ List<Wire>> wireMap, Candidates allCandidates)
{
- wireMap.put(resource, Collections.<Wire>emptyList());
+ wireMap.put(session.getDynamicHost(), Collections.<Wire>emptyList());
List<Wire> packageWires = new ArrayList<Wire>();
// Get the candidates for the current dynamic requirement.
// Record the dynamic candidate.
- Capability dynCand = allCandidates.getFirstCandidate(dynReq);
+ Capability dynCand = allCandidates.getFirstCandidate(session.getDynamicRequirement());
- if (!rc.getWirings().containsKey(dynCand.getResource()))
+ if (!session.getContext().getWirings().containsKey(dynCand.getResource()))
{
- populateWireMap(rc, dynCand.getResource(),
+ populateWireMap(session, dynCand.getResource(),
wireMap, allCandidates);
}
packageWires.add(
new WireImpl(
- resource,
- dynReq,
+ session.getDynamicHost(),
+ session.getDynamicRequirement(),
getDeclaredResource(dynCand.getResource()),
getDeclaredCapability(dynCand)));
- wireMap.put(resource, packageWires);
+ wireMap.put(session.getDynamicHost(), packageWires);
return wireMap;
}
@@ -2100,7 +2095,7 @@ public class ResolverImpl implements Resolver
System.out.println(" " + entry.getKey() + " - " + entry.getValue());
}
System.out.println(" USED");
- for (Entry<String, ArrayMap<Capability, UsedBlames>> entry : packages.m_usedPkgs.entrySet())
+ for (Entry<String, ArrayMap<Set<Capability>, UsedBlames>> entry : packages.m_usedPkgs.entrySet())
{
System.out.println(" " + entry.getKey() + " - " + entry.getValue().values());
}
@@ -2124,7 +2119,7 @@ public class ResolverImpl implements Resolver
public final OpenHashMap<String, Blame> m_substitePkgs;
public final OpenHashMap<String, List<Blame>> m_importedPkgs;
public final OpenHashMap<String, List<Blame>> m_requiredPkgs;
- public final OpenHashMap<String, ArrayMap<Capability, UsedBlames>> m_usedPkgs;
+ public final OpenHashMap<String, ArrayMap<Set<Capability>, UsedBlames>> m_usedPkgs;
public final OpenHashMap<Capability, Set<Capability>> m_sources;
@SuppressWarnings("serial")
@@ -2145,12 +2140,12 @@ public class ResolverImpl implements Resolver
return new ArrayList<Blame>();
}
};
- m_usedPkgs = new OpenHashMap<String, ArrayMap<Capability, UsedBlames>>(128) {
+ m_usedPkgs = new OpenHashMap<String, ArrayMap<Set<Capability>, UsedBlames>>(128) {
@Override
- protected ArrayMap<Capability, UsedBlames> compute(String s) {
- return new ArrayMap<Capability, UsedBlames>() {
+ protected ArrayMap<Set<Capability>, UsedBlames> compute(String s) {
+ return new ArrayMap<Set<Capability>, UsedBlames>() {
@Override
- protected UsedBlames compute(Capability key) {
+ protected UsedBlames compute(Set<Capability> key) {
return new UsedBlames(key);
}
};
@@ -2204,18 +2199,18 @@ public class ResolverImpl implements Resolver
*/
private static class UsedBlames
{
- public final Capability m_cap;
+ public final Set<Capability> m_caps;
public final List<Blame> m_blames = new ArrayList<ResolverImpl.Blame>();
private Map<Requirement, Set<Capability>> m_rootCauses;
- public UsedBlames(Capability cap)
+ public UsedBlames(Set<Capability> caps)
{
- m_cap = cap;
+ m_caps = caps;
}
public void addBlame(Blame blame, Capability matchingRootCause)
{
- if (!m_cap.equals(blame.m_cap))
+ if (!m_caps.contains(blame.m_cap))
{
throw new IllegalArgumentException(
"Attempt to add a blame with a different used capability: "
@@ -2467,7 +2462,8 @@ public class ResolverImpl implements Resolver
}
@Override
- public ResolutionException toException() {
+ public ResolutionException toException()
+ {
return new ReasonException(ReasonException.Reason.UseConstraint, getMessage(), null, getUnresolvedRequirements());
}
}
@@ -2475,8 +2471,8 @@ public class ResolverImpl implements Resolver
private static class EnhancedExecutor
{
private final Executor executor;
- private final AtomicInteger count = new AtomicInteger();
- private Throwable throwable;
+ private final Queue<Future<Void>> awaiting = new ConcurrentLinkedQueue<Future<Void>>();
+ private final AtomicReference<Throwable> throwable = new AtomicReference<Throwable>();
public EnhancedExecutor(Executor executor)
{
@@ -2485,8 +2481,7 @@ public class ResolverImpl implements Resolver
public void execute(final Runnable runnable)
{
- count.incrementAndGet();
- executor.execute(new Runnable()
+ FutureTask<Void> task = new FutureTask<Void>(new Runnable()
{
public void run()
{
@@ -2496,59 +2491,63 @@ public class ResolverImpl implements Resolver
}
catch (Throwable t)
{
- synchronized (count)
- {
- if (throwable == null)
- {
- throwable = t;
- }
- }
- }
- finally
- {
- if (count.decrementAndGet() == 0)
- {
- synchronized (count)
- {
- count.notifyAll();
- }
- }
+ throwable.compareAndSet(null, t);
}
}
- });
+ }, (Void) null);
+ // must have a happens-first to add the task to awaiting
+ awaiting.add(task);
+ try
+ {
+ executor.execute(task);
+ }
+ catch (Throwable t)
+ {
+ // if the task did not get added successfully to the executor we must cancel
+ // the task so we don't await on it
+ task.cancel(false);
+ throwable.compareAndSet(null, t);
+ }
}
public void await()
{
- synchronized (count)
+ Future<Void> awaitTask;
+ while (throwable.get() == null && (awaitTask = awaiting.poll()) != null)
{
- if (count.get() > 0)
+ if (!awaitTask.isDone() && !awaitTask.isCancelled())
{
try
{
- count.wait();
+ awaitTask.get();
+ }
+ catch (CancellationException e)
+ {
+ // ignore; will have throwable set
}
catch (InterruptedException e)
{
throw new IllegalStateException(e);
}
- if (throwable != null)
+ catch (ExecutionException e)
{
- if (throwable instanceof RuntimeException)
- {
- throw (RuntimeException) throwable;
- }
- else if (throwable instanceof Error)
- {
- throw (Error) throwable;
- }
- else
- {
- throw new RuntimeException(throwable);
- }
+ throw new RuntimeException(e.getCause());
}
}
}
+ Throwable t = throwable.get();
+ if (t != null)
+ {
+ if (t instanceof Runnable)
+ {
+ throw (RuntimeException) t;
+ }
+ else if (t instanceof Error)
+ {
+ throw (Error) t;
+ }
+ throw new RuntimeException(t);
+ }
}
}
=====================================
src/main/java/org/osgi/service/resolver/HostedCapability.java
=====================================
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2012, 2015). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.osgi.service.resolver;
+import org.osgi.annotation.versioning.ProviderType;
import org.osgi.resource.Capability;
import org.osgi.resource.Resource;
@@ -32,9 +33,9 @@ import org.osgi.resource.Resource;
* capability can actually be hosted multiple times.
*
* @ThreadSafe
- * @noimplement
- * @version $Id: db698baa07e2ee8b5467871239adb5f0806dc183 $
+ * @author $Id: e6a6917f6cdb5021a7a5cf858a08a98677183606 $
*/
+ at ProviderType
public interface HostedCapability extends Capability {
/**
@@ -42,6 +43,7 @@ public interface HostedCapability extends Capability {
*
* @return The Resource that hosts this Capability.
*/
+ @Override
Resource getResource();
/**
=====================================
src/main/java/org/osgi/service/resolver/ResolutionException.java
=====================================
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2011, 2012). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2011, 2013). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,13 +34,13 @@ import org.osgi.resource.Requirement;
* Resolver implementations may extend this class to provide extra state
* information about the reason for the resolution failure.
*
- * @version $Id: 42e5773e3b7e240673874329e5d9e705d0b698c5 $
+ * @author $Id: 2bcc0ac8ebfaf169dd301493303d23ce613ac8b9 $
*/
public class ResolutionException extends Exception {
private static final long serialVersionUID = 1L;
- private final Collection<Requirement> unresolvedRequirements;
+ private final transient Collection<Requirement> unresolvedRequirements;
/**
* Create a {@code ResolutionException} with the specified message, cause
@@ -55,7 +55,7 @@ public class ResolutionException extends Exception {
public ResolutionException(String message, Throwable cause, Collection<Requirement> unresolvedRequirements) {
super(message, cause);
if ((unresolvedRequirements == null) || unresolvedRequirements.isEmpty()) {
- this.unresolvedRequirements = emptyCollection();
+ this.unresolvedRequirements = null;
} else {
this.unresolvedRequirements = Collections.unmodifiableCollection(new ArrayList<Requirement>(unresolvedRequirements));
}
@@ -68,7 +68,7 @@ public class ResolutionException extends Exception {
*/
public ResolutionException(String message) {
super(message);
- unresolvedRequirements = emptyCollection();
+ unresolvedRequirements = null;
}
/**
@@ -78,10 +78,11 @@ public class ResolutionException extends Exception {
*/
public ResolutionException(Throwable cause) {
super(cause);
- unresolvedRequirements = emptyCollection();
+ unresolvedRequirements = null;
}
- private static <T> Collection<T> emptyCollection() {
+ @SuppressWarnings("unchecked")
+ private static Collection<Requirement> emptyCollection() {
return Collections.EMPTY_LIST;
}
@@ -95,9 +96,9 @@ public class ResolutionException extends Exception {
*
* @return A collection of the unresolved requirements for this exception.
* The returned collection may be empty if no unresolved
- * requirements information is provided.
+ * requirements information is available.
*/
public Collection<Requirement> getUnresolvedRequirements() {
- return unresolvedRequirements;
+ return (unresolvedRequirements != null) ? unresolvedRequirements : emptyCollection();
}
}
=====================================
src/main/java/org/osgi/service/resolver/ResolveContext.java
=====================================
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2011, 2012). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2011, 2017). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,20 +16,29 @@
package org.osgi.service.resolver;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CancellationException;
+
+import org.osgi.annotation.versioning.ConsumerType;
+import org.osgi.framework.namespace.BundleNamespace;
+import org.osgi.framework.namespace.HostNamespace;
+import org.osgi.framework.namespace.PackageNamespace;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
+import org.osgi.resource.Wire;
import org.osgi.resource.Wiring;
/**
* A resolve context provides resources, options and constraints to the
* potential solution of a {@link Resolver#resolve(ResolveContext) resolve}
* operation.
- *
* <p>
* Resolve Contexts:
* <ul>
@@ -45,21 +54,21 @@ import org.osgi.resource.Wiring;
* <li>Filter requirements that are part of a resolve operation via the
* {@link #isEffective(Requirement)}.</li>
* </ul>
- *
* <p>
* A resolver may call the methods on the resolve context any number of times
* during a resolve operation using any thread. Implementors should ensure that
* this class is properly thread safe.
- *
* <p>
- * Except for {@link #insertHostedCapability(List, HostedCapability)}, the
- * resolve context methods must be <i>idempotent</i>. This means that resources
- * must have constant capabilities and requirements and the resolve context must
- * return a consistent set of capabilities, wires and effective requirements.
+ * Except for {@link #insertHostedCapability(List, HostedCapability)} and
+ * {@link #onCancel(Runnable)}, the resolve context methods must be
+ * <i>idempotent</i>. This means that resources must have constant capabilities
+ * and requirements and the resolve context must return a consistent set of
+ * capabilities, wires and effective requirements.
*
* @ThreadSafe
- * @version $Id: f92eae32ab6fadb25e13d226458d6af50e8dcbba $
+ * @author $Id: 5a3d32eb947b703bcca36f00d1ba6a86ae4a8e4b $
*/
+ at ConsumerType
public abstract class ResolveContext {
/**
* Return the resources that must be resolved for this resolve context.
@@ -67,8 +76,9 @@ public abstract class ResolveContext {
* <p>
* The default implementation returns an empty collection.
*
- * @return The resources that must be resolved for this resolve context. May
- * be empty if there are no mandatory resources.
+ * @return A collection of the resources that must be resolved for this
+ * resolve context. May be empty if there are no mandatory
+ * resources. The returned collection may be unmodifiable.
*/
public Collection<Resource> getMandatoryResources() {
return emptyCollection();
@@ -82,14 +92,15 @@ public abstract class ResolveContext {
* <p>
* The default implementation returns an empty collection.
*
- * @return The resources that the resolver should attempt to resolve for
- * this resolve context. May be empty if there are no mandatory
- * resources.
+ * @return A collection of the resources that the resolver should attempt to
+ * resolve for this resolve context. May be empty if there are no
+ * optional resources. The returned collection may be unmodifiable.
*/
public Collection<Resource> getOptionalResources() {
return emptyCollection();
}
+ @SuppressWarnings("unchecked")
private static <T> Collection<T> emptyCollection() {
return Collections.EMPTY_LIST;
}
@@ -115,7 +126,7 @@ public abstract class ResolveContext {
* that must originate from an attached host.
*
* <p>
- * Each returned Capability must match the given Requirement. This implies
+ * Each returned Capability must match the given Requirement. This means
* that the filter in the Requirement must match as well as any namespace
* specific directives. For example, the mandatory attributes for the
* {@code osgi.wiring.package} namespace.
@@ -181,4 +192,141 @@ public abstract class ResolveContext {
* unmodifiable.
*/
public abstract Map<Resource, Wiring> getWirings();
+
+ /**
+ * Find resources that are related to the given resource.
+ * <p>
+ * The resolver attempts to resolve related resources during the current
+ * resolve operation. Failing to resolve one of the related resources will
+ * not result in a resolution exception unless the related resource is also
+ * a {@link #getMandatoryResources() mandatory} resource.
+ * <p>
+ * The resolve context is asked to return related resources for each
+ * resource that is pulled into a resolve operation. This includes the
+ * {@link #getMandatoryResources() mandatory} and
+ * {@link #getOptionalResources() optional} resources and each related
+ * resource returned by this method.
+ * <p>
+ * For example, a fragment can be considered a related resource for a host
+ * bundle. When a host is being resolved the resolve context will be asked
+ * if any related 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.
+ *
+ * @param resource The Resource that a resolver is attempting to find
+ * related resources for. Must not be {@code null}.
+ * @return A collection of the resources that the resolver should attempt to
+ * resolve for this resolve context. May be empty if there are no
+ * related resources. The returned collection may be unmodifiable.
+ * @since 1.1
+ */
+ public Collection<Resource> findRelatedResources(Resource resource) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Registers a callback with the resolve context that is associated with the
+ * currently running resolve operation. The callback can be executed in
+ * order to cancel the currently running resolve operation.
+ * <p>
+ * When a resolve operation begins, the resolver must call this method once
+ * and only once for the duration of the resolve operation and that call
+ * must happen before calling any other method on this resolve context. If
+ * the specified callback is executed then the resolver must cancel the
+ * currently running resolve operation and throw a
+ * {@link ResolutionException} with a cause of type
+ * {@link CancellationException}.
+ * <p>
+ * The callback allows a resolve context to cancel a long running resolve
+ * operation that appears to be running endlessly or at risk of running out
+ * of resources. The resolve context may then decide to give up on resolve
+ * operation or attempt to try another resolve operation with a smaller set
+ * of resources which may allow the resolve operation to complete normally.
+ *
+ * @param callback the callback to execute in order to cancel the resolve
+ * operation. Must not be {@code null}.
+ * @throws IllegalStateException if the resolver attempts to register more
+ * than one callback for a resolve operation
+ * @since 1.1
+ */
+ public void onCancel(Runnable callback) {
+ // do nothing by default
+ }
+
+ /**
+ * Returns the subset of {@link Wiring#getRequiredResourceWires(String)
+ * required} wires that provide wires to {@link Capability capabilities}
+ * which substitute capabilities of the 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
+ * provided by a different wiring then the package capability is considered
+ * to be substituted.
+ * <p>
+ * The resolver asks the resolve context to return substitution wires for
+ * each wiring that {@link Wiring#getResourceCapabilities(String) provides}
+ * a {@link BundleNamespace bundle} namespace capability that is used to
+ * resolve one or more bundle requirements.
+ * <p>
+ * Note that this method searches all the {@link PackageNamespace package}
+ * capabilities declared as {@link Resource#getCapabilities(String)
+ * provided} by the resource associated with the wiring and fragment
+ * resources wired to the wiring with the {@link HostNamespace host}
+ * namespace. The provided package names are compared against the
+ * {@link Wiring#getRequiredResourceWires(String) required} package wires to
+ * determine which wires are substitution wires. Subclasses of
+ * <code>ResolveContext</code> should provide a more efficient
+ * implementation of this method.
+ *
+ * @param wiring the wiring to get the substitution wires for. Must not be
+ * {@code null}.
+ * @return A list containing a snapshot of the substitution {@link Wire}s
+ * for the {@link Requirement requirements} of the wiring, or an
+ * empty list if the wiring has no substitution wires. The list
+ * contains the wires in the order they are found in the
+ * {@link Wiring#getRequiredResourceWires(String) required} wires of
+ * the wiring.
+ * @since 1.1
+ */
+ public List<Wire> getSubstitutionWires(Wiring wiring) {
+ // Keep track of the declared capability package names
+ Set<String> exportNames = new HashSet<String>();
+
+ // Add packages declared as provided by the wiring host
+ for (Capability cap : wiring.getResource().getCapabilities(null)) {
+ if (PackageNamespace.PACKAGE_NAMESPACE.equals(cap.getNamespace())) {
+ exportNames.add((String) cap.getAttributes()
+ .get(PackageNamespace.PACKAGE_NAMESPACE));
+ }
+ }
+
+ // Add packages declared as provided by the attached fragments
+ for (Wire wire : wiring.getProvidedResourceWires(null)) {
+ if (HostNamespace.HOST_NAMESPACE
+ .equals(wire.getCapability().getNamespace())) {
+ Resource fragment = wire.getRequirement().getResource();
+ for (Capability cap : fragment.getCapabilities(null)) {
+ if (PackageNamespace.PACKAGE_NAMESPACE
+ .equals(cap.getNamespace())) {
+ exportNames.add((String) cap.getAttributes()
+ .get(PackageNamespace.PACKAGE_NAMESPACE));
+ }
+ }
+ }
+ }
+
+ // collect the package wires that substitute one of the declared
+ // export package names
+ List<Wire> substitutionWires = new ArrayList<Wire>();
+ for (Wire wire : wiring.getRequiredResourceWires(null)) {
+ if (PackageNamespace.PACKAGE_NAMESPACE
+ .equals(wire.getCapability().getNamespace())) {
+ if (exportNames
+ .contains(wire.getCapability().getAttributes().get(
+ PackageNamespace.PACKAGE_NAMESPACE))) {
+ substitutionWires.add(wire);
+ }
+ }
+ }
+ return substitutionWires;
+ }
}
=====================================
src/main/java/org/osgi/service/resolver/Resolver.java
=====================================
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2006, 2012). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2006, 2019). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,25 +14,27 @@
* limitations under the License.
*/
-// This document is an experimental draft to enable interoperability
-// between bundle repositories. There is currently no commitment to
-// turn this draft into an official specification.
-
package org.osgi.service.resolver;
import java.util.List;
import java.util.Map;
+
+import org.osgi.annotation.versioning.ProviderType;
+import org.osgi.framework.namespace.PackageNamespace;
+import org.osgi.resource.Namespace;
+import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
import org.osgi.resource.Wire;
+import org.osgi.resource.Wiring;
/**
* A resolver service resolves the specified resources in the context supplied
* by the caller.
*
* @ThreadSafe
- * @noimplement
- * @version $Id: dfb89b8d09af62ecf62321b80d7e2310512f27a1 $
+ * @author $Id: e4011e12a98088d382bb7f5b27817213734f6504 $
*/
+ at ProviderType
public interface Resolver {
/**
* Resolve the specified resolve context and return any new resources and
@@ -69,4 +71,62 @@ public interface Resolver {
* @throws ResolutionException If the resolution cannot be satisfied.
*/
Map<Resource, List<Wire>> resolve(ResolveContext context) throws ResolutionException;
+
+ /**
+ * Resolves a given requirement dynamically for the given host wiring using
+ * the given resolve context and return any new resources and wires to the
+ * caller.
+ * <p>
+ * The requirement must be a {@link Wiring#getResourceRequirements(String)
+ * requirement} of the wiring and must use the
+ * {@link PackageNamespace#PACKAGE_NAMESPACE package} namespace with a
+ * {@link Namespace#REQUIREMENT_RESOLUTION_DIRECTIVE resolution} of type
+ * {@link PackageNamespace#RESOLUTION_DYNAMIC dynamic}.
+ * <p>
+ * The resolve context is not asked for
+ * {@link ResolveContext#getMandatoryResources() mandatory} resources or for
+ * {@link ResolveContext#getMandatoryResources() optional} resources. The
+ * resolve context is asked to
+ * {@link ResolveContext#findProviders(Requirement) find providers} for the
+ * given requirement. The matching {@link PackageNamespace#PACKAGE_NAMESPACE
+ * package} capabilities returned by the resolve context must not have a
+ * {@link PackageNamespace#PACKAGE_NAMESPACE osgi.wiring.package} attribute
+ * equal to a {@link PackageNamespace#PACKAGE_NAMESPACE package} capability
+ * already {@link Wiring#getRequiredResourceWires(String) wired to} by the
+ * wiring or equal a {@link PackageNamespace#PACKAGE_NAMESPACE package}
+ * capability {@link Wiring#getResourceCapabilities(String) provided} by the
+ * wiring. The resolve context may be requested to
+ * {@link ResolveContext#findProviders(Requirement) find providers} for
+ * other requirements in order to resolve the resources that provide the
+ * matching capabilities to the given requirement.
+ * <p>
+ * If the requirement {@link Namespace#REQUIREMENT_CARDINALITY_DIRECTIVE
+ * cardinality} is not {@link Namespace#CARDINALITY_MULTIPLE multiple} then
+ * no new wire must be created if the
+ * {@link Wiring#getRequiredResourceWires(String) wires} of the wiring
+ * already contain a wire that uses the {@link Wire#getRequirement()
+ * requirement}
+ * <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 wiring
+ * {@link Wiring#getResource() resource}. The wire list for the wiring
+ * resource will only contain one wire which is for the dynamic requirement.
+ *
+ * @param context The resolve context for the resolve operation. Must not be
+ * {@code null}.
+ * @param hostWiring The wiring with the dynamic
+ * {@link Wiring#getResourceRequirements(String) requirement}.
+ * Must not be {@code null}.
+ * @param dynamicRequirement The dynamic requirement. Must not be
+ * {@code null}.
+ * @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. If no new wires were
+ * created then a ResolutionException is thrown.
+ * @throws ResolutionException if the dynamic requirement cannot be resolved
+ */
+ public Map<Resource,List<Wire>> resolveDynamic(ResolveContext context,
+ Wiring hostWiring, Requirement dynamicRequirement)
+ throws ResolutionException;
}
=====================================
src/main/java/org/osgi/service/resolver/package-info.java
=====================================
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2010, 2012). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2010, 2020). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,25 +15,26 @@
*/
/**
- * Resolver Service Package Version 1.0.
- *
+ * Resolver Service Package Version 1.1.
* <p>
* Bundles wishing to use this package must list the package in the
* Import-Package header of the bundle's manifest. This package has two types of
* users: the consumers that use the API in this package and the providers that
* implement the API in this package.
- *
* <p>
* Example import for consumers using the API in this package:
* <p>
- * {@code Import-Package: org.osgi.service.resolver; version="[1.0,2.0)"}
+ * {@code Import-Package: org.osgi.service.resolver; version="[1.1,2.0)"}
* <p>
* Example import for providers implementing the API in this package:
* <p>
- * {@code Import-Package: org.osgi.service.resolver; version="[1.0,1.1)"}
+ * {@code Import-Package: org.osgi.service.resolver; version="[1.1,1.2)"}
*
- * @version $Id: db1706d83ca104187f77cb1feb7cf52b92b3740d $
+ * @author $Id: 260072a99b71d2c4e6cfd174fd6acc1d20768e25 $
*/
+ at Version("1.1.1")
package org.osgi.service.resolver;
+import org.osgi.annotation.versioning.Version;
+
=====================================
src/main/java/org/osgi/service/resolver/packageinfo deleted
=====================================
@@ -1 +0,0 @@
-version 1.0
=====================================
src/test/java/org/apache/felix/resolver/test/ResolverTest.java
=====================================
@@ -476,7 +476,7 @@ public class ResolverTest
List<Capability> caps = new ArrayList<Capability>();
caps.add(f1_pkgCap);
- Map<Resource, List<Wire>> wireMap = resolver.resolve(rci, b1, b_pkgReq1, caps);
+ Map<Resource, List<Wire>> wireMap = resolver.resolveDynamic(rci, wirings.get(b1), b_pkgReq1);
assertEquals(1, wireMap.size());
List<Wire> wiresB = wireMap.get(b1);
@@ -527,7 +527,7 @@ public class ResolverTest
List<Capability> caps = new ArrayList<Capability>();
caps.add(f1_pkgCap);
try {
- resolver.resolve(rci, b1, b_pkgReq1, caps);
+ resolver.resolveDynamic(rci, wirings.get(b1), b_pkgReq1);
fail("Should fail to dynamic requirement to fragment when host is resolved already.");
} catch (ResolutionException e) {
// expected
@@ -538,7 +538,7 @@ public class ResolverTest
wirings.remove(a1);
caps.clear();
caps.add(f1_pkgCap);
- Map<Resource, List<Wire>> wireMap = resolver.resolve(rci, b1, b_pkgReq1, caps);
+ Map<Resource, List<Wire>> wireMap = resolver.resolveDynamic(rci, wirings.get(b1), b_pkgReq1);
assertEquals(3, wireMap.size());
List<Wire> wiresB = wireMap.get(b1);
@@ -589,7 +589,7 @@ public class ResolverTest
List<Capability> caps = new ArrayList<Capability>();
caps.add(c_pkgCap);
- Map<Resource, List<Wire>> wireMap = resolver.resolve(rci, b1, b_pkgReq1, caps);
+ Map<Resource, List<Wire>> wireMap = resolver.resolveDynamic(rci, wirings.get(b1), b_pkgReq1);
assertEquals(0, wireMap.size());
}
@@ -913,6 +913,16 @@ public class ResolverTest
resolver.resolve(rci);
}
+ @Test
+ public void testScenario19() throws Exception
+ {
+ ResolveContext rci = populateScenario19();
+ ResolverImpl resolver = new ResolverImpl(new Logger(Logger.LOG_DEBUG), 1);
+ Map<Resource, List<Wire>> result = resolver.resolve(rci);
+
+ assertEquals("Wrong number of resolved bundles", 9, result.size());
+ }
+
private ResolveContext populateScenario17(boolean realSubstitute,
boolean felixResolveContext, boolean existingWirings)
{
@@ -991,7 +1001,7 @@ public class ResolverTest
}
Collection<Resource> mandatory = Collections.<Resource> singletonList(requiresMisc);
if (felixResolveContext) {
- Map<Wiring, Collection<Wire>> substitutions = new HashMap<Wiring, Collection<Wire>>();
+ Map<Wiring, List<Wire>> substitutions = new HashMap<Wiring, List<Wire>>();
if (realSubstitute && coreWiring != null)
{
substitutions.put(coreWiring, Arrays.<Wire> asList(
@@ -1092,6 +1102,97 @@ public class ResolverTest
mandatory, Collections.<Resource> emptyList());
}
+ private ResolveContext populateScenario19()
+ {
+ Map<Requirement, List<Capability>> candMap = new HashMap<Requirement, List<Capability>>();
+
+ ResourceImpl split1 = new ResourceImpl("split1");
+ Capability split1_bundle = addCap(split1, BundleNamespace.BUNDLE_NAMESPACE, "splil1");
+ Capability split1_pkg = addCap(split1, PackageNamespace.PACKAGE_NAMESPACE,
+ "split.pkg");
+
+ ResourceImpl split2 = new ResourceImpl("split2");
+ Capability split2_bundle = addCap(split2, BundleNamespace.BUNDLE_NAMESPACE, "splil2");
+ Capability split2_pkg = addCap(split2, PackageNamespace.PACKAGE_NAMESPACE,
+ "split.pkg");
+
+ ResourceImpl split3 = new ResourceImpl("split3");
+ Capability split3_bundle = addCap(split3, BundleNamespace.BUNDLE_NAMESPACE, "splil3");
+ Capability split3_pkg = addCap(split3, PackageNamespace.PACKAGE_NAMESPACE,
+ "split.pkg");
+
+ ResourceImpl split4 = new ResourceImpl("split4");
+ Capability split4_bundle = addCap(split4, BundleNamespace.BUNDLE_NAMESPACE,
+ "splil4");
+ Capability split4_pkg = addCap(split4, PackageNamespace.PACKAGE_NAMESPACE,
+ "split.pkg");
+
+ GenericRequirement split3_split1Req = (GenericRequirement) addReq(split3,
+ BundleNamespace.BUNDLE_NAMESPACE, "split1");
+ split3_split1Req.addDirective(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE,
+ BundleNamespace.VISIBILITY_REEXPORT);
+ GenericRequirement split3_split2Req = (GenericRequirement) addReq(split3,
+ BundleNamespace.BUNDLE_NAMESPACE, "split2");
+ split3_split2Req.addDirective(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE,
+ BundleNamespace.VISIBILITY_REEXPORT);
+
+ ResourceImpl reexportSplit1 = new ResourceImpl("reexportSplit1");
+ Capability reexportSplit1_bundle = addCap(reexportSplit1, BundleNamespace.BUNDLE_NAMESPACE, "reexportSplit1");
+ GenericRequirement reexportSplit1_split1Req = (GenericRequirement) addReq(
+ reexportSplit1, BundleNamespace.BUNDLE_NAMESPACE, "split1");
+ reexportSplit1_split1Req.addDirective(
+ BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE,
+ BundleNamespace.VISIBILITY_REEXPORT);
+
+ ResourceImpl reexportSplit3 = new ResourceImpl("reexportSplit3");
+ Capability reexportSplit3_bundle = addCap(reexportSplit3, BundleNamespace.BUNDLE_NAMESPACE, "reexportSplit3");
+ GenericRequirement reexportSplit3_split3Req = (GenericRequirement) addReq(
+ reexportSplit3, BundleNamespace.BUNDLE_NAMESPACE, "split3");
+ reexportSplit3_split3Req.addDirective(
+ BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE,
+ BundleNamespace.VISIBILITY_REEXPORT);
+
+ ResourceImpl exportUsesSplit3 = new ResourceImpl("exportUsesSplit3");
+ Capability exportUsesSplit3_bundle = addCap(exportUsesSplit3, BundleNamespace.BUNDLE_NAMESPACE, "exportUsesSplit3");
+ GenericCapability exportUsesSplit_pkg = (GenericCapability) addCap(
+ exportUsesSplit3, PackageNamespace.PACKAGE_NAMESPACE, "export.pkg");
+ exportUsesSplit_pkg.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE,
+ "split.pkg");
+ GenericRequirement exportUsesSplit3_split3Req = (GenericRequirement) addReq(
+ exportUsesSplit3, BundleNamespace.BUNDLE_NAMESPACE, "reexportSplit3");
+
+ ResourceImpl requireExportAndSplit1 = new ResourceImpl("requireExportAndSplit1");
+ Requirement requireExportAndSplit1_split1Req = addReq(requireExportAndSplit1,
+ BundleNamespace.BUNDLE_NAMESPACE, "reexportSplit1");
+ Requirement requireExportAndSplit1_exportReq = addReq(requireExportAndSplit1,
+ BundleNamespace.BUNDLE_NAMESPACE, "exportUsesSplit3");
+
+ ResourceImpl importExportAndSplit = new ResourceImpl("importExportAndSplit");
+ Requirement importExportAndSplit_importExport = addReq(importExportAndSplit,
+ PackageNamespace.PACKAGE_NAMESPACE, "export.pkg");
+ Requirement importExportAndSplit_importSplit = addReq(importExportAndSplit,
+ PackageNamespace.PACKAGE_NAMESPACE, "split.pkg");
+
+ candMap.put(split3_split1Req, Arrays.asList(split1_bundle));
+ candMap.put(split3_split2Req, Arrays.asList(split2_bundle));
+ candMap.put(reexportSplit1_split1Req, Arrays.asList(split1_bundle));
+ candMap.put(reexportSplit3_split3Req, Arrays.asList(split3_bundle));
+ candMap.put(exportUsesSplit3_split3Req, Arrays.asList(reexportSplit3_bundle));
+ candMap.put(requireExportAndSplit1_split1Req, Arrays.asList(reexportSplit1_bundle));
+ candMap.put(requireExportAndSplit1_exportReq,
+ Arrays.asList(exportUsesSplit3_bundle));
+ candMap.put(importExportAndSplit_importSplit,
+ Arrays.asList(split4_pkg, split3_pkg));
+ candMap.put(importExportAndSplit_importExport,
+ Arrays.asList((Capability) exportUsesSplit_pkg));
+
+ Collection<Resource> mandatory = Arrays.<Resource> asList(split1, split2,
+ split3, split4, reexportSplit1, reexportSplit3, exportUsesSplit3,
+ requireExportAndSplit1, importExportAndSplit);
+ return new ResolveContextImpl(Collections.<Resource, Wiring> emptyMap(), candMap,
+ mandatory, Collections.<Resource> emptyList());
+ }
+
private static String getResourceName(Resource r)
{
return r.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).get(0).getAttributes()
=====================================
src/test/java/org/apache/felix/resolver/test/util/IterativeResolver.java
=====================================
@@ -192,4 +192,9 @@ public class IterativeResolver implements Resolver {
}
}
+ public Map<Resource, List<Wire>> resolveDynamic(ResolveContext context,
+ Wiring hostWiring, Requirement dynamicRequirement) throws ResolutionException
+ {
+ throw new UnsupportedOperationException();
+ }
}
=====================================
src/test/java/org/apache/felix/resolver/test/util/ResolveContextImpl.java
=====================================
@@ -24,7 +24,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.apache.felix.resolver.FelixResolveContext;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
@@ -93,11 +92,11 @@ public class ResolveContextImpl extends ResolveContext
return m_wirings;
}
- public static class FelixResolveContextImpl extends ResolveContextImpl implements FelixResolveContext
+ public static class FelixResolveContextImpl extends ResolveContextImpl
{
- private final Map<Wiring, Collection<Wire>> m_substitutions;
+ private final Map<Wiring, List<Wire>> m_substitutions;
- public FelixResolveContextImpl(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap, Collection<Resource> mandatory, Collection<Resource> optional, Map<Wiring, Collection<Wire>> substitutions)
+ public FelixResolveContextImpl(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap, Collection<Resource> mandatory, Collection<Resource> optional, Map<Wiring, List<Wire>> substitutions)
{
super(wirings, candMap, mandatory, optional);
this.m_substitutions = substitutions;
@@ -108,9 +107,9 @@ public class ResolveContextImpl extends ResolveContext
return Collections.emptyList();
}
- public Collection<Wire> getSubstitutionWires(Wiring wiring)
+ public List<Wire> getSubstitutionWires(Wiring wiring)
{
- Collection<Wire> result = m_substitutions.get(wiring);
+ List<Wire> result = m_substitutions.get(wiring);
return result == null ? Collections.<Wire> emptyList() : result;
}
View it on GitLab: https://salsa.debian.org/java-team/felix-resolver/-/compare/071524089a8d858f53331c2137d13b0618527302...9c1f6e34b5d3dfc7e706ec73df319ea4c8e4ff01
--
View it on GitLab: https://salsa.debian.org/java-team/felix-resolver/-/compare/071524089a8d858f53331c2137d13b0618527302...9c1f6e34b5d3dfc7e706ec73df319ea4c8e4ff01
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20261120/5a057f1e/attachment.htm>
More information about the pkg-java-commits
mailing list