Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-01-12 22:11:07 +0000
committerThomas Watson2016-01-12 22:11:07 +0000
commit5475c78a2681e45c7e6a2faf268abdb77204c0cd (patch)
tree879a9c51098fec7f0b3acccd56dcfcc695b6f0a6 /bundles/org.eclipse.osgi/felix/src
parentf66c5fe3d72aa35196d7de82a270c9a4bed181fc (diff)
downloadrt.equinox.framework-5475c78a2681e45c7e6a2faf268abdb77204c0cd.tar.gz
rt.equinox.framework-5475c78a2681e45c7e6a2faf268abdb77204c0cd.tar.xz
rt.equinox.framework-5475c78a2681e45c7e6a2faf268abdb77204c0cd.zip
Bug 485695 - WrappedResource getCapabilities and getRequirements are incorrectI20160112-1800
Diffstat (limited to 'bundles/org.eclipse.osgi/felix/src')
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/WrappedResource.java114
1 files changed, 62 insertions, 52 deletions
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/WrappedResource.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/WrappedResource.java
index 3f80ae343..f338cac61 100755
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/WrappedResource.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/WrappedResource.java
@@ -18,9 +18,7 @@
*/
package org.apache.felix.resolver;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
import org.osgi.framework.namespace.ExecutionEnvironmentNamespace;
import org.osgi.framework.namespace.HostNamespace;
import org.osgi.framework.namespace.IdentityNamespace;
@@ -32,13 +30,60 @@ class WrappedResource implements Resource
{
private final Resource m_host;
private final List<Resource> m_fragments;
- private List<Capability> m_cachedCapabilities = null;
- private List<Requirement> m_cachedRequirements = null;
+ private final List<Capability> m_cachedCapabilities;
+ private final List<Requirement> m_cachedRequirements;
public WrappedResource(Resource host, List<Resource> fragments)
{
m_host = host;
m_fragments = fragments;
+
+ // Wrap host capabilities.
+ List<Capability> caps = new ArrayList<Capability>();
+ for (Capability cap : m_host.getCapabilities(null))
+ {
+ caps.add(new WrappedCapability(this, cap));
+ }
+
+ // Wrap fragment capabilities.
+ if (m_fragments != null)
+ {
+ for (Resource fragment : m_fragments)
+ {
+ for (Capability cap : fragment.getCapabilities(null))
+ {
+ caps.add(new WrappedCapability(this, cap));
+ }
+ }
+ }
+ m_cachedCapabilities = Collections.unmodifiableList(caps);
+
+ // Wrap host requirements.
+ List<Requirement> reqs = new ArrayList<Requirement>();
+ for (Requirement req : m_host.getRequirements(null))
+ {
+ reqs.add(new WrappedRequirement(this, req));
+ }
+
+ // Wrap fragment requirements.
+ if (m_fragments != null)
+ {
+ for (Resource fragment : m_fragments)
+ {
+ for (Requirement req : fragment.getRequirements(null))
+ {
+ // Filter out host and execution environment requirements,
+ // since they are not part of the fragment payload.
+ if (!req.getNamespace().equals(HostNamespace.HOST_NAMESPACE)
+ && !req.getNamespace().equals(
+ ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE))
+ {
+ reqs.add(new WrappedRequirement(this, req));
+ }
+ }
+ }
+ }
+ m_cachedRequirements = Collections.unmodifiableList(reqs);
}
public Resource getDeclaredResource()
@@ -53,63 +98,28 @@ class WrappedResource implements Resource
public List<Capability> getCapabilities(String namespace)
{
- if (m_cachedCapabilities == null)
- {
- List<Capability> caps = new ArrayList<Capability>();
-
- // Wrap host capabilities.
- for (Capability cap : m_host.getCapabilities(namespace))
- {
- caps.add(new WrappedCapability(this, cap));
- }
-
- // Wrap fragment capabilities.
- if (m_fragments != null)
- {
- for (Resource fragment : m_fragments)
- {
- for (Capability cap : fragment.getCapabilities(namespace))
- {
- caps.add(new WrappedCapability(this, cap));
- }
+ if (namespace != null) {
+ List<Capability> filtered = new ArrayList<Capability>();
+ for (Capability capability : m_cachedCapabilities) {
+ if (namespace.equals(capability.getNamespace())) {
+ filtered.add(capability);
}
}
- m_cachedCapabilities = Collections.unmodifiableList(caps);
+ return Collections.unmodifiableList(filtered);
}
return m_cachedCapabilities;
}
public List<Requirement> getRequirements(String namespace)
{
- if (m_cachedRequirements == null)
- {
- List<Requirement> reqs = new ArrayList<Requirement>();
-
- // Wrap host requirements.
- for (Requirement req : m_host.getRequirements(null))
- {
- reqs.add(new WrappedRequirement(this, req));
- }
-
- // Wrap fragment requirements.
- if (m_fragments != null)
- {
- for (Resource fragment : m_fragments)
- {
- for (Requirement req : fragment.getRequirements(null))
- {
- // Filter out host and execution environment requirements,
- // since they are not part of the fragment payload.
- if (!req.getNamespace().equals(HostNamespace.HOST_NAMESPACE)
- && !req.getNamespace().equals(
- ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE))
- {
- reqs.add(new WrappedRequirement(this, req));
- }
- }
+ if (namespace != null) {
+ List<Requirement> filtered = new ArrayList<Requirement>();
+ for (Requirement requirement : m_cachedRequirements) {
+ if (namespace.equals(requirement.getNamespace())) {
+ filtered.add(requirement);
}
}
- m_cachedRequirements = Collections.unmodifiableList(reqs);
+ return Collections.unmodifiableList(filtered);
}
return m_cachedRequirements;
}

Back to the top