Modify CapabilitySet to have a flag indicating whether its indexing
is case sensitive or not. (FELIX-2548)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@987219 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java b/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
index 2201cfd..d7b5854 100644
--- a/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
+++ b/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
@@ -70,15 +70,15 @@
List<String> indices = new ArrayList<String>();
indices.add(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
- m_capSets.put(Capability.MODULE_NAMESPACE, new CapabilitySet(indices));
+ m_capSets.put(Capability.MODULE_NAMESPACE, new CapabilitySet(indices, true));
indices = new ArrayList<String>();
indices.add(Capability.PACKAGE_ATTR);
- m_capSets.put(Capability.PACKAGE_NAMESPACE, new CapabilitySet(indices));
+ m_capSets.put(Capability.PACKAGE_NAMESPACE, new CapabilitySet(indices, true));
indices = new ArrayList<String>();
indices.add(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
- m_capSets.put(Capability.HOST_NAMESPACE, new CapabilitySet(indices));
+ m_capSets.put(Capability.HOST_NAMESPACE, new CapabilitySet(indices, true));
}
public synchronized void addModule(Module module)
@@ -139,7 +139,7 @@
if (modules != null)
{
modules.remove(module);
- if (modules.size() == 0)
+ if (modules.isEmpty())
{
m_singletons.remove(module.getSymbolicName());
}
@@ -381,7 +381,7 @@
CapabilitySet capSet = m_capSets.get(cap.getNamespace());
if (capSet == null)
{
- capSet = new CapabilitySet(null);
+ capSet = new CapabilitySet(null, true);
m_capSets.put(cap.getNamespace(), capSet);
}
capSet.addCapability(cap);
diff --git a/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java b/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
index 758d1df..6ec6ee4 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
@@ -56,7 +56,7 @@
List indices = new ArrayList();
indices.add(Constants.OBJECTCLASS);
- m_regCapSet = new CapabilitySet(indices);
+ m_regCapSet = new CapabilitySet(indices, false);
}
public ServiceReference[] getRegisteredServices(Bundle bundle)
diff --git a/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java b/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
index 270088c..e718b49 100644
--- a/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
+++ b/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
@@ -35,13 +35,15 @@
public class CapabilitySet
{
- private final Map<String, Map<Object, Set<Capability>>> m_indices =
- new TreeMap<String, Map<Object, Set<Capability>>>(new StringComparator(false));
+ private final Map<String, Map<Object, Set<Capability>>> m_indices;
private final Set<Capability> m_capList = new HashSet<Capability>();
private final static SecureAction m_secureAction = new SecureAction();
- public CapabilitySet(List<String> indexProps)
+ public CapabilitySet(List<String> indexProps, boolean caseSensitive)
{
+ m_indices = (caseSensitive)
+ ? new TreeMap<String, Map<Object, Set<Capability>>>()
+ : new TreeMap<String, Map<Object, Set<Capability>>>(new StringComparator(false));
for (int i = 0; (indexProps != null) && (i < indexProps.size()); i++)
{
m_indices.put(indexProps.get(i), new HashMap<Object, Set<Capability>>());
@@ -135,7 +137,7 @@
if (caps != null)
{
caps.remove(cap);
- if (caps.size() == 0)
+ if (caps.isEmpty())
{
index.remove(capValue);
}