Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-01-21 20:05:05 +0000
committerThomas Watson2016-01-21 20:05:05 +0000
commit777d131c705f84847747c2eaae120d3a01c39846 (patch)
treeb4b97fa2d1353d3bbf7fd5b1a12e0289d07153c9
parenta48c2a720f024dce6cd92b96c26c746442a10d87 (diff)
downloadrt.equinox.framework-777d131c705f84847747c2eaae120d3a01c39846.tar.gz
rt.equinox.framework-777d131c705f84847747c2eaae120d3a01c39846.tar.xz
rt.equinox.framework-777d131c705f84847747c2eaae120d3a01c39846.zip
incremental refresh - Fix getOndemandResources to properly lookup fragments with alias host names Change-Id: I7a64ce41706525b5ed21aafc4e07e9e026738d51 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java61
1 files changed, 45 insertions, 16 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index 69de82799..4f32d8220 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -834,31 +834,60 @@ final class ModuleResolver {
@Override
public Collection<Resource> getOndemandResources(Resource host) {
- String hostBSN = ((ModuleRevision) host).getSymbolicName();
- if (hostBSN == null) {
- return Collections.emptyList();
- }
List<ModuleCapability> hostCaps = ((ModuleRevision) host).getModuleCapabilities(HostNamespace.HOST_NAMESPACE);
if (hostCaps.isEmpty()) {
return Collections.emptyList();
}
- ModuleCapability hostCap = hostCaps.get(0);
- String matchFilter = "(" + EquinoxFragmentNamespace.FRAGMENT_NAMESPACE + "=" + hostBSN + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- Requirement fragmentRequirement = ModuleContainer.createRequirement(EquinoxFragmentNamespace.FRAGMENT_NAMESPACE, Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, matchFilter), Collections.<String, Object> emptyMap());
- List<ModuleCapability> candidates = moduleDatabase.findCapabilities(fragmentRequirement);
- // filter out disabled fragments and singletons
- filterDisabled(candidates.listIterator());
- Collection<Resource> ondemandFragments = new ArrayList<Resource>(candidates.size());
- for (Iterator<ModuleCapability> iCandidates = candidates.iterator(); iCandidates.hasNext();) {
- ModuleCapability candidate = iCandidates.next();
- ModuleRequirement hostReq = candidate.getRevision().getModuleRequirements(HostNamespace.HOST_NAMESPACE).get(0);
- if (hostReq.matches(hostCap)) {
- ondemandFragments.add(candidate.getResource());
+
+ Collection<Resource> ondemandFragments = new ArrayList<Resource>();
+ for (String hostBSN : getHostBSNs(hostCaps)) {
+ String matchFilter = "(" + EquinoxFragmentNamespace.FRAGMENT_NAMESPACE + "=" + hostBSN + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ Requirement fragmentRequirement = ModuleContainer.createRequirement(EquinoxFragmentNamespace.FRAGMENT_NAMESPACE, Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, matchFilter), Collections.<String, Object> emptyMap());
+ List<ModuleCapability> candidates = moduleDatabase.findCapabilities(fragmentRequirement);
+ // filter out disabled fragments and singletons
+ filterDisabled(candidates.listIterator());
+ for (Iterator<ModuleCapability> iCandidates = candidates.iterator(); iCandidates.hasNext();) {
+ ModuleCapability candidate = iCandidates.next();
+ ModuleRequirement hostReq = candidate.getRevision().getModuleRequirements(HostNamespace.HOST_NAMESPACE).get(0);
+ for (ModuleCapability hostCap : hostCaps) {
+ if (hostReq.matches(hostCap)) {
+ ondemandFragments.add(candidate.getResource());
+ break;
+ }
+ }
}
}
+
return ondemandFragments;
}
+ private Collection<String> getHostBSNs(List<ModuleCapability> hostCaps) {
+ if (hostCaps.size() == 1) {
+ // optimization and likely the only case since you are not supposed to have multiple host caps
+ return getHostBSNs(hostCaps.get(0));
+ }
+ Set<String> result = new HashSet<String>();
+ for (ModuleCapability hostCap : hostCaps) {
+ result.addAll(getHostBSNs(hostCap));
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Collection<String> getHostBSNs(ModuleCapability moduleCapability) {
+ Object namesAttr = moduleCapability.getAttributes().get(HostNamespace.HOST_NAMESPACE);
+ if (namesAttr instanceof String) {
+ return Collections.singletonList((String) namesAttr);
+ }
+ if (namesAttr instanceof String[]) {
+ return Arrays.asList((String[]) namesAttr);
+ }
+ if (namesAttr instanceof Collection) {
+ return (Collection<String>) namesAttr;
+ }
+ return Collections.emptyList();
+ }
+
ModuleResolutionReport resolve() {
if (threadResolving()) {
// throw up a runtime exception, if this is caused by a resolver hook

Back to the top