felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1102776 [1/4] - in /felix/trunk/framework: ./ src/main/java/org/apache/felix/framework/ src/main/java/org/apache/felix/framework/capabilityset/ src/main/java/org/apache/felix/framework/resolver/ src/main/java/org/apache/felix/framework/uti...
Date Fri, 13 May 2011 14:57:59 GMT
Author: rickhall
Date: Fri May 13 14:57:58 2011
New Revision: 1102776

URL: http://svn.apache.org/viewvc?rev=1102776&view=rev
Log:
Use BundleCapability/BundleRequirement. (FELIX-2950)

Added:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/wiring/
    felix/trunk/framework/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java
    felix/trunk/framework/src/main/java/org/osgi/framework/wiring/
    felix/trunk/framework/src/main/java/org/osgi/framework/wiring/BundleCapability.java
    felix/trunk/framework/src/main/java/org/osgi/framework/wiring/BundleRequirement.java
    felix/trunk/framework/src/main/java/org/osgi/framework/wiring/BundleRevision.java
    felix/trunk/framework/src/main/java/org/osgi/framework/wiring/BundleWire.java
    felix/trunk/framework/src/main/java/org/osgi/framework/wiring/BundleWiring.java
Removed:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Attribute.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Capability.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Directive.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/Requirement.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/RequirementImpl.java
Modified:
    felix/trunk/framework/pom.xml
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/FilterImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostModule.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Module.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolveException.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Resolver.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Wire.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ParsedHeaderClause.java

Modified: felix/trunk/framework/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/framework/pom.xml?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/pom.xml (original)
+++ felix/trunk/framework/pom.xml Fri May 13 14:57:58 2011
@@ -55,7 +55,7 @@
             <Bundle-Name>Apache Felix Framework</Bundle-Name>
             <Bundle-Description>OSGi R4 framework implementation.</Bundle-Description>
             <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
-            <Export-Package>org.osgi.framework;-split-package:=merge-first,org.osgi.framework.launch,org.osgi.framework.hooks.service,org.osgi.service.packageadmin,org.osgi.service.url,org.osgi.service.startlevel,org.osgi.util.tracker</Export-Package>
+            <Export-Package>org.osgi.framework.*;-split-package:=merge-first,org.osgi.service.packageadmin,org.osgi.service.url,org.osgi.service.startlevel,org.osgi.util.tracker</Export-Package>
             <Private-Package>org.apache.felix.framework.*</Private-Package>
             <Import-Package>!*</Import-Package>
             <Include-Resource>META-INF/LICENSE=LICENSE,META-INF/NOTICE=NOTICE,META-INF/DEPENDENCIES=DEPENDENCIES,{src/main/resources/}</Include-Resource> 

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java Fri May 13 14:57:58 2011
@@ -19,8 +19,8 @@
 package org.apache.felix.framework;
 
 import java.util.List;
-import org.apache.felix.framework.capabilityset.Capability;
 import org.apache.felix.framework.resolver.Module;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Version;
 import org.osgi.service.packageadmin.ExportedPackage;
@@ -30,21 +30,21 @@ class ExportedPackageImpl implements Exp
     private final Felix m_felix;
     private final BundleImpl m_exportingBundle;
     private final Module m_exportingModule;
-    private final Capability m_export;
+    private final BundleCapabilityImpl m_export;
     private final String m_pkgName;
     private final Version m_version;
 
     public ExportedPackageImpl(
-        Felix felix, BundleImpl exporter, Module module, Capability export)
+        Felix felix, BundleImpl exporter, Module module, BundleCapabilityImpl export)
     {
         m_felix = felix;
         m_exportingBundle = exporter;
         m_exportingModule = module;
         m_export = export;
-        m_pkgName = (String) m_export.getAttribute(Capability.PACKAGE_ATTR).getValue();
-        m_version = (m_export.getAttribute(Capability.VERSION_ATTR) == null)
+        m_pkgName = (String) m_export.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR);
+        m_version = (!m_export.getAttributes().containsKey(BundleCapabilityImpl.VERSION_ATTR))
             ? Version.emptyVersion
-            : (Version) m_export.getAttribute(Capability.VERSION_ATTR).getValue();
+            : (Version) m_export.getAttributes().get(BundleCapabilityImpl.VERSION_ATTR);
     }
 
     public Bundle getExportingBundle()

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java Fri May 13 14:57:58 2011
@@ -33,20 +33,18 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.NoSuchElementException;
 import java.util.Set;
 
 import org.apache.felix.framework.Felix.StatefulResolver;
-import org.apache.felix.framework.capabilityset.Attribute;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Directive;
 import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.framework.util.StringMap;
 import org.apache.felix.framework.util.Util;
-import org.apache.felix.framework.util.manifestparser.CapabilityImpl;
 import org.apache.felix.framework.util.manifestparser.ManifestParser;
 import org.apache.felix.framework.resolver.Content;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.osgi.framework.AdminPermission;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
@@ -118,7 +116,7 @@ class ExtensionManager extends URLStream
     private final Logger m_logger;
     private final Map m_headerMap = new StringMap(false);
     private final Module m_systemBundleModule;
-    private List<Capability> m_capabilities = null;
+    private List<BundleCapabilityImpl> m_capabilities = null;
     private Set m_exportNames = null;
     private Object m_securityContext = null;
     private final List m_extensions;
@@ -192,12 +190,12 @@ class ExtensionManager extends URLStream
         {
             ManifestParser mp = new ManifestParser(
                 m_logger, felix.getConfig(), m_systemBundleModule, m_headerMap);
-            List<Capability> caps = aliasSymbolicName(mp.getCapabilities());
+            List<BundleCapabilityImpl> caps = aliasSymbolicName(mp.getCapabilities());
             setCapabilities(caps);
         }
         catch (Exception ex)
         {
-            m_capabilities = new ArrayList<Capability>(0);
+            m_capabilities = new ArrayList<BundleCapabilityImpl>(0);
             m_logger.log(
                 Logger.LOG_ERROR,
                 "Error parsing system bundle export statement: "
@@ -205,35 +203,35 @@ class ExtensionManager extends URLStream
         }
     }
 
-    private static List<Capability> aliasSymbolicName(List<Capability> caps)
+    private static List<BundleCapabilityImpl> aliasSymbolicName(List<BundleCapabilityImpl> caps)
     {
         if (caps == null)
         {
-            return new ArrayList<Capability>(0);
+            return new ArrayList<BundleCapabilityImpl>(0);
         }
 
-        List<Capability> aliasCaps = new ArrayList<Capability>(caps);
+        List<BundleCapabilityImpl> aliasCaps = new ArrayList<BundleCapabilityImpl>(caps);
 
         for (int capIdx = 0; capIdx < aliasCaps.size(); capIdx++)
         {
             // Get the attributes and search for bundle symbolic name.
-            List<Attribute> attrs = aliasCaps.get(capIdx).getAttributes();
-            for (int i = 0; i < attrs.size(); i++)
+            for (Entry<String, Object> entry : aliasCaps.get(capIdx).getAttributes().entrySet())
             {
                 // If there is a bundle symbolic name attribute, add the
                 // standard alias as a value.
-                if (attrs.get(i).getName().equalsIgnoreCase(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
+                if (entry.getKey().equalsIgnoreCase(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
                 {
                     // Make a copy of the attribute array.
-                    List<Attribute> aliasAttrs = new ArrayList<Attribute>(attrs);
+                    Map<String, Object> aliasAttrs =
+                        new HashMap<String, Object>(aliasCaps.get(capIdx).getAttributes());
                     // Add the aliased value.
-                    aliasAttrs.set(i, new Attribute(
+                    aliasAttrs.put(
                         Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE,
                         new String[] {
-                            (String) attrs.get(i).getValue(), Constants.SYSTEM_BUNDLE_SYMBOLICNAME},
-                        false));
+                            (String) entry.getValue(),
+                            Constants.SYSTEM_BUNDLE_SYMBOLICNAME});
                     // Create the aliased capability to replace the old capability.
-                    aliasCaps.set(capIdx, new CapabilityImpl(
+                    aliasCaps.set(capIdx, new BundleCapabilityImpl(
                         caps.get(capIdx).getModule(),
                         caps.get(capIdx).getNamespace(),
                         caps.get(capIdx).getDirectives(),
@@ -299,21 +297,21 @@ class ExtensionManager extends URLStream
             throw new SecurityException("Extension Bundles must have AllPermission");
         }
 
-        Directive dir = ManifestParser.parseExtensionBundleHeader((String)
+        String directive = ManifestParser.parseExtensionBundleHeader((String)
             bundle.getCurrentModule().getHeaders().get(Constants.FRAGMENT_HOST));
 
         // We only support classpath extensions (not bootclasspath).
-        if (!Constants.EXTENSION_FRAMEWORK.equals(dir.getValue()))
+        if (!Constants.EXTENSION_FRAMEWORK.equals(directive))
         {
             throw new BundleException("Unsupported Extension Bundle type: " +
-                dir.getValue(), new UnsupportedOperationException(
+                directive, new UnsupportedOperationException(
                 "Unsupported Extension Bundle type!"));
         }
 
         try
         {
             // Merge the exported packages with the exported packages of the systembundle.
-            List<Capability> exports = null;
+            List<BundleCapabilityImpl> exports = null;
             try
             {
                 exports = ManifestParser.parseExportHeader(
@@ -346,7 +344,8 @@ class ExtensionManager extends URLStream
                 throw new UnsupportedOperationException(
                     "Unable to add extension bundle to FrameworkClassLoader - Maybe not an URLClassLoader?");
             }
-            List<Capability> temp = new ArrayList<Capability>(m_capabilities.size() + exports.size());
+            List<BundleCapabilityImpl> temp =
+                new ArrayList<BundleCapabilityImpl>(m_capabilities.size() + exports.size());
             temp.addAll(m_capabilities);
             temp.addAll(exports);
             setCapabilities(temp);
@@ -416,7 +415,7 @@ class ExtensionManager extends URLStream
         }
     }
 
-    private void setCapabilities(List<Capability> capabilities)
+    private void setCapabilities(List<BundleCapabilityImpl> capabilities)
     {
         m_capabilities = capabilities;
         m_headerMap.put(Constants.EXPORT_PACKAGE, convertCapabilitiesToHeaders(m_headerMap));
@@ -429,7 +428,7 @@ class ExtensionManager extends URLStream
 
         for (int i = 0; (m_capabilities != null) && (i < m_capabilities.size()); i++)
         {
-            if (m_capabilities.get(i).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            if (m_capabilities.get(i).getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
             {
                 // Add a comma separate if there is an existing package.
                 if (exportSB.length() > 0)
@@ -438,31 +437,35 @@ class ExtensionManager extends URLStream
                 }
 
                 // Append exported package information.
-                exportSB.append(m_capabilities.get(i).getAttribute(Capability.PACKAGE_ATTR).getValue());
-                for (Directive dir : m_capabilities.get(i).getDirectives())
+                exportSB.append(m_capabilities.get(i)
+                    .getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR));
+                for (Entry<String, String> entry
+                    : m_capabilities.get(i).getDirectives().entrySet())
                 {
                     exportSB.append("; ");
-                    exportSB.append(dir.getName());
+                    exportSB.append(entry.getKey());
                     exportSB.append(":=\"");
-                    exportSB.append(dir.getValue());
+                    exportSB.append(entry.getValue());
                     exportSB.append("\"");
                 }
-                for (Attribute attr : m_capabilities.get(i).getAttributes())
+                for (Entry<String, Object> entry
+                    : m_capabilities.get(i).getAttributes().entrySet())
                 {
-                    if (!attr.getName().equals(Capability.PACKAGE_ATTR)
-                        && !attr.getName().equals(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE)
-                        && !attr.getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
+                    if (!entry.getKey().equals(BundleCapabilityImpl.PACKAGE_ATTR)
+                        && !entry.getKey().equals(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE)
+                        && !entry.getKey().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
                     {
                         exportSB.append("; ");
-                        exportSB.append(attr.getName());
+                        exportSB.append(entry.getKey());
                         exportSB.append("=\"");
-                        exportSB.append(attr.getValue());
+                        exportSB.append(entry.getValue());
                         exportSB.append("\"");
                     }
                 }
 
                 // Remember exported packages.
-                exportNames.add(m_capabilities.get(i).getAttribute(Capability.PACKAGE_ATTR).getValue());
+                exportNames.add(m_capabilities.get(i)
+                    .getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR));
             }
         }
 
@@ -643,7 +646,7 @@ class ExtensionManager extends URLStream
             }
         }
 
-        public List<Capability> getCapabilities()
+        public List<BundleCapabilityImpl> getCapabilities()
         {
             synchronized (ExtensionManager.this)
             {

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Fri May 13 14:57:58 2011
@@ -27,12 +27,8 @@ import java.util.Map.Entry;
 import org.apache.felix.framework.ServiceRegistry.ServiceRegistryCallbacks;
 import org.apache.felix.framework.cache.BundleArchive;
 import org.apache.felix.framework.cache.BundleCache;
-import org.apache.felix.framework.capabilityset.Attribute;
-import org.apache.felix.framework.capabilityset.Capability;
 import org.apache.felix.framework.capabilityset.CapabilitySet;
-import org.apache.felix.framework.capabilityset.Directive;
 import org.apache.felix.framework.resolver.Module;
-import org.apache.felix.framework.capabilityset.Requirement;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
 import org.apache.felix.framework.resolver.Wire;
 import org.apache.felix.framework.ext.SecurityProvider;
@@ -49,7 +45,8 @@ import org.apache.felix.framework.util.S
 import org.apache.felix.framework.util.ThreadGate;
 import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.util.manifestparser.R4LibraryClause;
-import org.apache.felix.framework.util.manifestparser.RequirementImpl;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 import org.osgi.framework.AdminPermission;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
@@ -3249,14 +3246,17 @@ public class Felix extends BundleImpl im
     ExportedPackage[] getExportedPackages(String pkgName)
     {
         // First, get all exporters of the package.
-        List<Directive> dirs = new ArrayList<Directive>(0);
-        List<Attribute> attrs = new ArrayList<Attribute>(1);
-        attrs.add(new Attribute(Capability.PACKAGE_ATTR, pkgName, false));
-        Requirement req = new RequirementImpl(null, Capability.PACKAGE_NAMESPACE, dirs, attrs);
-        Set<Capability> exports = m_resolver.getCandidates(req, false);
+        Map<String, Object> attrs = new HashMap<String, Object>(1);
+        attrs.put(BundleCapabilityImpl.PACKAGE_ATTR, pkgName);
+        BundleRequirementImpl req = new BundleRequirementImpl(
+            null,
+            BundleCapabilityImpl.PACKAGE_NAMESPACE,
+            Collections.EMPTY_MAP,
+            attrs);
+        Set<BundleCapabilityImpl> exports = m_resolver.getCandidates(req, false);
 
         // We only want resolved capabilities.
-        for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
+        for (Iterator<BundleCapabilityImpl> it = exports.iterator(); it.hasNext(); )
         {
             if (!it.next().getModule().isResolved())
             {
@@ -3268,7 +3268,7 @@ public class Felix extends BundleImpl im
         {
             List pkgs = new ArrayList();
 
-            for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
+            for (Iterator<BundleCapabilityImpl> it = exports.iterator(); it.hasNext(); )
             {
                 // Get the bundle associated with the current exporting module.
                 BundleImpl bundle = (BundleImpl) it.next().getModule().getBundle();
@@ -3286,7 +3286,7 @@ public class Felix extends BundleImpl im
                 List<Module> modules = bundle.getModules();
                 for (int modIdx = 0; modIdx < modules.size(); modIdx++)
                 {
-                    List<Capability> ec = modules.get(modIdx).getCapabilities();
+                    List<BundleCapabilityImpl> ec = modules.get(modIdx).getCapabilities();
                     for (int i = 0; (ec != null) && (i < ec.size()); i++)
                     {
                         if (ec.get(i).getNamespace().equals(req.getNamespace())
@@ -3384,25 +3384,28 @@ public class Felix extends BundleImpl im
         List<Module> modules = bundle.getModules();
         for (int modIdx = 0; modIdx < modules.size(); modIdx++)
         {
-            List<Capability> caps = modules.get(modIdx).getCapabilities();
+            List<BundleCapabilityImpl> caps = modules.get(modIdx).getCapabilities();
             if ((caps != null) && (caps.size() > 0))
             {
                 for (int capIdx = 0; capIdx < caps.size(); capIdx++)
                 {
                     // See if the target bundle's module is one of the
                     // resolved exporters of the package.
-                    if (caps.get(capIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                    if (caps.get(capIdx).getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                     {
                         String pkgName = (String)
-                            caps.get(capIdx).getAttribute(Capability.PACKAGE_ATTR).getValue();
-                        List<Directive> dirs = new ArrayList<Directive>(0);
-                        List<Attribute> attrs = new ArrayList<Attribute>(1);
-                        attrs.add(new Attribute(Capability.PACKAGE_ATTR, pkgName, false));
-                        Requirement req =
-                            new RequirementImpl(null, Capability.PACKAGE_NAMESPACE, dirs, attrs);
-                        Set<Capability> exports = m_resolver.getCandidates(req, false);
+                            caps.get(capIdx).getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR);
+                        Map<String, Object> attrs = new HashMap<String, Object>(1);
+                        attrs.put(BundleCapabilityImpl.PACKAGE_ATTR, pkgName);
+                        BundleRequirementImpl req =
+                            new BundleRequirementImpl(
+                            null,
+                            BundleCapabilityImpl.PACKAGE_NAMESPACE,
+                            Collections.EMPTY_MAP,
+                            attrs);
+                        Set<BundleCapabilityImpl> exports = m_resolver.getCandidates(req, false);
                         // We only want resolved capabilities.
-                        for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
+                        for (Iterator<BundleCapabilityImpl> it = exports.iterator(); it.hasNext(); )
                         {
                             if (!it.next().getModule().isResolved())
                             {
@@ -3412,7 +3415,7 @@ public class Felix extends BundleImpl im
 
 
                         // Search through the current providers to find the target module.
-                        for (Capability cap : exports)
+                        for (BundleCapabilityImpl cap : exports)
                         {
                             if (cap == caps.get(capIdx))
                             {
@@ -4113,7 +4116,7 @@ public class Felix extends BundleImpl im
             m_resolverState.removeModule(m);
         }
 
-        Set<Capability> getCandidates(Requirement req, boolean obeyMandatory)
+        Set<BundleCapabilityImpl> getCandidates(BundleRequirementImpl req, boolean obeyMandatory)
         {
             return m_resolverState.getCandidates(req, obeyMandatory);
         }
@@ -4246,7 +4249,7 @@ public class Felix extends BundleImpl im
 
             // If the module doesn't have dynamic imports, then just return
             // immediately.
-            List<Requirement> dynamics = module.getDynamicRequirements();
+            List<BundleRequirementImpl> dynamics = module.getDynamicRequirements();
             if ((dynamics == null) || dynamics.isEmpty())
             {
                 return false;
@@ -4254,11 +4257,11 @@ public class Felix extends BundleImpl im
 
             // If any of the module exports this package, then we cannot
             // attempt to dynamically import it.
-            List<Capability> caps = module.getCapabilities();
+            List<BundleCapabilityImpl> caps = module.getCapabilities();
             for (int i = 0; (caps != null) && (i < caps.size()); i++)
             {
-                if (caps.get(i).getNamespace().equals(Capability.PACKAGE_NAMESPACE)
-                    && caps.get(i).getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+                if (caps.get(i).getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE)
+                    && caps.get(i).getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName))
                 {
                     return false;
                 }
@@ -4277,12 +4280,14 @@ public class Felix extends BundleImpl im
             // Loop through the importer's dynamic requirements to determine if
             // there is a matching one for the package from which we want to
             // load a class.
-            List<Directive> dirs = Collections.EMPTY_LIST;
-            List<Attribute> attrs = new ArrayList(1);
-            attrs.add(new Attribute(Capability.PACKAGE_ATTR, pkgName, false));
-            Requirement req = new RequirementImpl(
-                module, Capability.PACKAGE_NAMESPACE, dirs, attrs);
-            Set<Capability> candidates = m_resolverState.getCandidates(req, false);
+            Map<String, Object> attrs = new HashMap(1);
+            attrs.put(BundleCapabilityImpl.PACKAGE_ATTR, pkgName);
+            BundleRequirementImpl req = new BundleRequirementImpl(
+                module,
+                BundleCapabilityImpl.PACKAGE_NAMESPACE,
+                Collections.EMPTY_MAP,
+                attrs);
+            Set<BundleCapabilityImpl> candidates = m_resolverState.getCandidates(req, false);
 
             return !candidates.isEmpty();
         }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/FilterImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/FilterImpl.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/FilterImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/FilterImpl.java Fri May 13 14:57:58 2011
@@ -18,17 +18,20 @@
  */
 package org.apache.felix.framework;
 
-import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.List;
-import org.apache.felix.framework.capabilityset.Attribute;
-import org.apache.felix.framework.capabilityset.Capability;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.apache.felix.framework.ServiceRegistrationImpl.ServiceReferenceImpl;
 import org.apache.felix.framework.capabilityset.CapabilitySet;
-import org.apache.felix.framework.capabilityset.Directive;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
 import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.util.StringMap;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.osgi.framework.Filter;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
@@ -51,7 +54,7 @@ public class FilterImpl implements Filte
 
     public boolean match(ServiceReference sr)
     {
-        return CapabilitySet.matches(new ServiceReferenceCapability(sr), m_filter);
+        return CapabilitySet.matches((ServiceReferenceImpl) sr, m_filter);
     }
 
     public boolean match(Dictionary dctnr)
@@ -79,12 +82,53 @@ public class FilterImpl implements Filte
         return m_filter.toString();
     }
 
-    static class DictionaryCapability implements Capability
+    static class DictionaryCapability extends BundleCapabilityImpl
+    {
+        private final Map m_map;
+
+        public DictionaryCapability(Dictionary dict, boolean caseSensitive)
+        {
+            super(null, null, Collections.EMPTY_MAP, Collections.EMPTY_MAP);
+            m_map = new DictionaryMap(dict, caseSensitive);
+        }
+
+        @Override
+        public Module getModule()
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public String getNamespace()
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public Map<String, String> getDirectives()
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public Map<String, Object> getAttributes()
+        {
+            return m_map;
+        }
+
+        @Override
+        public List<String> getUses()
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+    }
+
+    private static class DictionaryMap implements Map
     {
         private final StringMap m_map;
         private final Dictionary m_dict;
 
-        public DictionaryCapability(Dictionary dict, boolean caseSensitive)
+        public DictionaryMap(Dictionary dict, boolean caseSensitive)
         {
             m_dict = dict;
             if (!caseSensitive)
@@ -114,29 +158,29 @@ public class FilterImpl implements Filte
             }
         }
 
-        public Module getModule()
+        public int size()
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
-        public String getNamespace()
+        public boolean isEmpty()
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
-        public Directive getDirective(String name)
+        public boolean containsKey(Object o)
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
-        public List<Directive> getDirectives()
+        public boolean containsValue(Object o)
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
-        public Attribute getAttribute(String name)
+        public Object get(Object o)
         {
-            String key = name;
+            String key = (String) o;
             Object value = null;
             if (m_dict != null)
             {
@@ -145,7 +189,7 @@ public class FilterImpl implements Filte
                 // the key.
                 if (m_map != null)
                 {
-                    key = (String) m_map.get(name);
+                    key = (String) m_map.get(o);
                 }
                 // If the key could not be found in the case insensitive
                 // key map, then avoid doing the dictionary lookup on it.
@@ -154,63 +198,42 @@ public class FilterImpl implements Filte
                     value = m_dict.get(key);
                 }
             }
-            return (value == null) ? null : new Attribute(key, value, false);
+            return value;
         }
 
-        public List<Attribute> getAttributes()
-        {
-            return new ArrayList();
-        }
-
-        public List<String> getUses()
+        public Object put(Object k, Object v)
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
-    }
 
-    static class ServiceReferenceCapability implements Capability
-    {
-        private final ServiceReference m_sr;
-
-        public ServiceReferenceCapability(ServiceReference sr)
-        {
-            m_sr = sr;
-        }
-
-        public Module getModule()
+        public Object remove(Object o)
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
-        public String getNamespace()
+        public void putAll(Map map)
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
-        public Directive getDirective(String name)
+        public void clear()
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
-        public List<Directive> getDirectives()
+        public Set<Object> keySet()
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
-        public Attribute getAttribute(String name)
+        public Collection<Object> values()
         {
-            Object value = m_sr.getProperty(name);
-            return (value == null) ? null : new Attribute(name, value, false);
-        }
-
-        public List<Attribute> getAttributes()
-        {
-            return new ArrayList();
+            throw new UnsupportedOperationException("Not supported yet.");
         }
 
-        public List<String> getUses()
+        public Set<Entry<Object, Object>> entrySet()
         {
-            throw new UnsupportedOperationException("Not supported yet.");
+            return Collections.EMPTY_SET;
         }
     }
-}
+}
\ No newline at end of file

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java Fri May 13 14:57:58 2011
@@ -44,10 +44,6 @@ import java.util.TreeMap;
 
 import org.apache.felix.framework.Felix.StatefulResolver;
 import org.apache.felix.framework.cache.JarContent;
-import org.apache.felix.framework.capabilityset.Attribute;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Directive;
-import org.apache.felix.framework.capabilityset.Requirement;
 import org.apache.felix.framework.resolver.Content;
 import org.apache.felix.framework.resolver.HostedCapability;
 import org.apache.felix.framework.resolver.HostedRequirement;
@@ -62,7 +58,8 @@ import org.apache.felix.framework.util.S
 import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.util.manifestparser.ManifestParser;
 import org.apache.felix.framework.util.manifestparser.R4Library;
-import org.apache.felix.framework.util.manifestparser.RequirementImpl;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleReference;
@@ -84,12 +81,12 @@ public class ModuleImpl implements Modul
     private final String m_symbolicName;
     private final Version m_version;
 
-    private final List<Capability> m_capabilities;
-    private List<Capability> m_cachedCapabilities = null;
-    private final List<Requirement> m_requirements;
-    private List<Requirement> m_cachedRequirements = null;
-    private final List<Requirement> m_dynamicRequirements;
-    private List<Requirement> m_cachedDynamicRequirements = null;
+    private final List<BundleCapabilityImpl> m_capabilities;
+    private List<BundleCapabilityImpl> m_cachedCapabilities = null;
+    private final List<BundleRequirementImpl> m_requirements;
+    private List<BundleRequirementImpl> m_cachedRequirements = null;
+    private final List<BundleRequirementImpl> m_dynamicRequirements;
+    private List<BundleRequirementImpl> m_cachedDynamicRequirements = null;
     private final List<R4Library> m_nativeLibraries;
     private final int m_declaredActivationPolicy;
     private final List<String> m_activationIncludes;
@@ -291,23 +288,23 @@ public class ModuleImpl implements Modul
         return m_version;
     }
 
-    public synchronized List<Capability> getCapabilities()
+    public synchronized List<BundleCapabilityImpl> getCapabilities()
     {
         if (m_cachedCapabilities == null)
         {
             List capList = (m_capabilities == null)
-                ? new ArrayList<Capability>()
-                : new ArrayList<Capability>(m_capabilities);
+                ? new ArrayList<BundleCapabilityImpl>()
+                : new ArrayList<BundleCapabilityImpl>(m_capabilities);
             for (int fragIdx = 0;
                 (m_fragments != null) && (fragIdx < m_fragments.size());
                 fragIdx++)
             {
-                List<Capability> caps = m_fragments.get(fragIdx).getCapabilities();
+                List<BundleCapabilityImpl> caps = m_fragments.get(fragIdx).getCapabilities();
                 for (int capIdx = 0;
                     (caps != null) && (capIdx < caps.size());
                     capIdx++)
                 {
-                    if (caps.get(capIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                    if (caps.get(capIdx).getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                     {
                         capList.add(
                             new HostedCapability(this, caps.get(capIdx)));
@@ -319,23 +316,23 @@ public class ModuleImpl implements Modul
         return m_cachedCapabilities;
     }
 
-    public synchronized List<Requirement> getRequirements()
+    public synchronized List<BundleRequirementImpl> getRequirements()
     {
         if (m_cachedRequirements == null)
         {
-            List<Requirement> reqList = (m_requirements == null)
+            List<BundleRequirementImpl> reqList = (m_requirements == null)
                 ? new ArrayList() : new ArrayList(m_requirements);
             for (int fragIdx = 0;
                 (m_fragments != null) && (fragIdx < m_fragments.size());
                 fragIdx++)
             {
-                List<Requirement> reqs = m_fragments.get(fragIdx).getRequirements();
+                List<BundleRequirementImpl> reqs = m_fragments.get(fragIdx).getRequirements();
                 for (int reqIdx = 0;
                     (reqs != null) && (reqIdx < reqs.size());
                     reqIdx++)
                 {
-                    if (reqs.get(reqIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE)
-                        || reqs.get(reqIdx).getNamespace().equals(Capability.MODULE_NAMESPACE))
+                    if (reqs.get(reqIdx).getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE)
+                        || reqs.get(reqIdx).getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
                     {
                         reqList.add(
                             new HostedRequirement(this, reqs.get(reqIdx)));
@@ -347,22 +344,22 @@ public class ModuleImpl implements Modul
         return m_cachedRequirements;
     }
 
-    public synchronized List<Requirement> getDynamicRequirements()
+    public synchronized List<BundleRequirementImpl> getDynamicRequirements()
     {
         if (m_cachedDynamicRequirements == null)
         {
-            List<Requirement> reqList = (m_dynamicRequirements == null)
+            List<BundleRequirementImpl> reqList = (m_dynamicRequirements == null)
                 ? new ArrayList() : new ArrayList(m_dynamicRequirements);
             for (int fragIdx = 0;
                 (m_fragments != null) && (fragIdx < m_fragments.size());
                 fragIdx++)
             {
-                List<Requirement> reqs = m_fragments.get(fragIdx).getDynamicRequirements();
+                List<BundleRequirementImpl> reqs = m_fragments.get(fragIdx).getDynamicRequirements();
                 for (int reqIdx = 0;
                     (reqs != null) && (reqIdx < reqs.size());
                     reqIdx++)
                 {
-                    if (reqs.get(reqIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                    if (reqs.get(reqIdx).getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                     {
                         reqList.add(reqs.get(reqIdx));
                     }
@@ -482,11 +479,11 @@ public class ModuleImpl implements Modul
         // from the old wires.
         for (int i = 0; !isFragment && (m_wires != null) && (i < m_wires.size()); i++)
         {
-            if (m_wires.get(i).getCapability().getNamespace().equals(Capability.MODULE_NAMESPACE))
+            if (m_wires.get(i).getCapability().getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
             {
                 ((ModuleImpl) m_wires.get(i).getExporter()).removeDependentRequirer(this);
             }
-            else if (m_wires.get(i).getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            else if (m_wires.get(i).getCapability().getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
             {
                 ((ModuleImpl) m_wires.get(i).getExporter()).removeDependentImporter(this);
             }
@@ -497,11 +494,11 @@ public class ModuleImpl implements Modul
         // Add ourself as a dependent to the new wires' modules.
         for (int i = 0; !isFragment && (m_wires != null) && (i < m_wires.size()); i++)
         {
-            if (m_wires.get(i).getCapability().getNamespace().equals(Capability.MODULE_NAMESPACE))
+            if (m_wires.get(i).getCapability().getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
             {
                 ((ModuleImpl) m_wires.get(i).getExporter()).addDependentRequirer(this);
             }
-            else if (m_wires.get(i).getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            else if (m_wires.get(i).getCapability().getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
             {
                 ((ModuleImpl) m_wires.get(i).getExporter()).addDependentImporter(this);
             }
@@ -936,7 +933,7 @@ public class ModuleImpl implements Modul
         for (int i = 0; (wires != null) && (i < wires.size()); i++)
         {
             if (wires.get(i).getRequirement().getNamespace()
-                .equals(Capability.PACKAGE_NAMESPACE))
+                .equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
             {
                 try
                 {
@@ -962,7 +959,7 @@ public class ModuleImpl implements Modul
         for (int i = 0; (wires != null) && (i < wires.size()); i++)
         {
             if (wires.get(i).getRequirement().getNamespace()
-                .equals(Capability.MODULE_NAMESPACE))
+                .equals(BundleCapabilityImpl.MODULE_NAMESPACE))
             {
                 try
                 {
@@ -2214,8 +2211,8 @@ public class ModuleImpl implements Modul
         List<Wire> wires = module.getWires();
         for (int i = 0; (wires != null) && (i < wires.size()); i++)
         {
-            if (wires.get(i).getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
-                wires.get(i).getCapability().getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+            if (wires.get(i).getCapability().getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE) &&
+                wires.get(i).getCapability().getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName))
             {
                 String exporter = wires.get(i).getExporter().getBundle().toString();
 
@@ -2241,7 +2238,7 @@ public class ModuleImpl implements Modul
 
         // Next, check to see if the package was optionally imported and
         // whether or not there is an exporter available.
-        List<Requirement> reqs = module.getRequirements();
+        List<BundleRequirementImpl> reqs = module.getRequirements();
 /*
 * TODO: RB - Fix diagnostic message for optional imports.
         for (int i = 0; (reqs != null) && (i < reqs.length); i++)
@@ -2304,12 +2301,12 @@ public class ModuleImpl implements Modul
         if (resolver.isAllowedDynamicImport(module, pkgName))
         {
             // Try to see if there is an exporter available.
-            List<Directive> dirs = Collections.EMPTY_LIST;
-            List<Attribute> attrs = new ArrayList(1);
-            attrs.add(new Attribute(Capability.PACKAGE_ATTR, pkgName, false));
-            Requirement req = new RequirementImpl(
-                module, Capability.PACKAGE_NAMESPACE, dirs, attrs);
-            Set<Capability> exporters = resolver.getCandidates(req, false);
+            Map<String, String> dirs = Collections.EMPTY_MAP;
+            Map<String, Object> attrs = new HashMap<String, Object>(1);
+            attrs.put(BundleCapabilityImpl.PACKAGE_ATTR, pkgName);
+            BundleRequirementImpl req = new BundleRequirementImpl(
+                module, BundleCapabilityImpl.PACKAGE_NAMESPACE, dirs, attrs);
+            Set<BundleCapabilityImpl> exporters = resolver.getCandidates(req, false);
 
             Wire wire = null;
             try
@@ -2343,12 +2340,12 @@ public class ModuleImpl implements Modul
         }
 
         // Next, check to see if there are any exporters for the package at all.
-        List<Directive> dirs = Collections.EMPTY_LIST;
-        List<Attribute> attrs = new ArrayList(1);
-        attrs.add(new Attribute(Capability.PACKAGE_ATTR, pkgName, false));
-        Requirement req = new RequirementImpl(
-            module, Capability.PACKAGE_NAMESPACE, dirs, attrs);
-        Set<Capability> exports = resolver.getCandidates(req, false);
+        Map<String, String> dirs = Collections.EMPTY_MAP;
+        Map<String, Object> attrs = new HashMap<String, Object>(1);
+        attrs.put(BundleCapabilityImpl.PACKAGE_ATTR, pkgName);
+        BundleRequirementImpl req = new BundleRequirementImpl(
+            module, BundleCapabilityImpl.PACKAGE_NAMESPACE, dirs, attrs);
+        Set<BundleCapabilityImpl> exports = resolver.getCandidates(req, false);
         if (exports.size() > 0)
         {
             boolean classpath = false;

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ResolverStateImpl.java Fri May 13 14:57:58 2011
@@ -27,9 +27,7 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.StringTokenizer;
 import java.util.TreeSet;
-import org.apache.felix.framework.capabilityset.Capability;
 import org.apache.felix.framework.capabilityset.CapabilitySet;
-import org.apache.felix.framework.capabilityset.Requirement;
 import org.apache.felix.framework.resolver.CandidateComparator;
 import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.resolver.ResolveException;
@@ -37,6 +35,8 @@ import org.apache.felix.framework.resolv
 import org.apache.felix.framework.resolver.Wire;
 import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.util.manifestparser.R4Library;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 import org.osgi.framework.BundlePermission;
 import org.osgi.framework.Constants;
 import org.osgi.framework.PackagePermission;
@@ -67,24 +67,24 @@ class ResolverStateImpl implements Resol
 
         List<String> indices = new ArrayList<String>();
         indices.add(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
-        m_capSets.put(Capability.MODULE_NAMESPACE, new CapabilitySet(indices, true));
+        m_capSets.put(BundleCapabilityImpl.MODULE_NAMESPACE, new CapabilitySet(indices, true));
 
         indices = new ArrayList<String>();
-        indices.add(Capability.PACKAGE_ATTR);
-        m_capSets.put(Capability.PACKAGE_NAMESPACE, new CapabilitySet(indices, true));
+        indices.add(BundleCapabilityImpl.PACKAGE_ATTR);
+        m_capSets.put(BundleCapabilityImpl.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, true));
+        m_capSets.put(BundleCapabilityImpl.HOST_NAMESPACE,  new CapabilitySet(indices, true));
     }
 
     synchronized void addModule(Module m)
     {
         m_modules.add(m);
-        List<Capability> caps = m.getCapabilities();
+        List<BundleCapabilityImpl> caps = m.getCapabilities();
         if (caps != null)
         {
-            for (Capability cap : caps)
+            for (BundleCapabilityImpl cap : caps)
             {
                 CapabilitySet capSet = m_capSets.get(cap.getNamespace());
                 if (capSet == null)
@@ -105,10 +105,10 @@ class ResolverStateImpl implements Resol
     synchronized void removeModule(Module m)
     {
         m_modules.remove(m);
-        List<Capability> caps = m.getCapabilities();
+        List<BundleCapabilityImpl> caps = m.getCapabilities();
         if (caps != null)
         {
-            for (Capability cap : caps)
+            for (BundleCapabilityImpl cap : caps)
             {
                 CapabilitySet capSet = m_capSets.get(cap.getNamespace());
                 if (capSet != null)
@@ -139,21 +139,21 @@ class ResolverStateImpl implements Resol
             // import rather than export the package, so we need to remove the
             // corresponding package capability from the package capability set.
             List<Wire> wires = module.getWires();
-            List<Capability> caps = module.getCapabilities();
+            List<BundleCapabilityImpl> caps = module.getCapabilities();
             for (int wireIdx = 0; (wires != null) && (wireIdx < wires.size()); wireIdx++)
             {
                 Wire wire = wires.get(wireIdx);
-                if (wire.getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                if (wire.getCapability().getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                 {
                     for (int capIdx = 0;
                         (caps != null) && (capIdx < caps.size());
                         capIdx++)
                     {
-                        if (caps.get(capIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE)
-                            && wire.getCapability().getAttribute(Capability.PACKAGE_ATTR).getValue()
-                                .equals(caps.get(capIdx).getAttribute(Capability.PACKAGE_ATTR).getValue()))
+                        if (caps.get(capIdx).getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE)
+                            && wire.getCapability().getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR)
+                                .equals(caps.get(capIdx).getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR)))
                         {
-                            m_capSets.get(Capability.PACKAGE_NAMESPACE).removeCapability(caps.get(capIdx));
+                            m_capSets.get(BundleCapabilityImpl.PACKAGE_NAMESPACE).removeCapability(caps.get(capIdx));
                             break;
                         }
                     }
@@ -166,27 +166,27 @@ class ResolverStateImpl implements Resol
     // ResolverState methods.
     //
 
-    public synchronized SortedSet<Capability> getCandidates(
-        Requirement req, boolean obeyMandatory)
+    public synchronized SortedSet<BundleCapabilityImpl> getCandidates(
+        BundleRequirementImpl req, boolean obeyMandatory)
     {
         Module module = req.getModule();
-        SortedSet<Capability> result = new TreeSet<Capability>(new CandidateComparator());
+        SortedSet<BundleCapabilityImpl> result = new TreeSet<BundleCapabilityImpl>(new CandidateComparator());
 
         CapabilitySet capSet = m_capSets.get(req.getNamespace());
         if (capSet != null)
         {
-            Set<Capability> matches = capSet.match(req.getFilter(), obeyMandatory);
-            for (Capability cap : matches)
+            Set<BundleCapabilityImpl> matches = capSet.match(req.getFilter(), obeyMandatory);
+            for (BundleCapabilityImpl cap : matches)
             {
                 if (System.getSecurityManager() != null)
                 {
-                    if (req.getNamespace().equals(Capability.PACKAGE_NAMESPACE) && (
+                    if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE) && (
                         !((BundleProtectionDomain) cap.getModule().getSecurityContext()).impliesDirect(
-                            new PackagePermission((String) cap.getAttribute(Capability.PACKAGE_ATTR).getValue(),
+                            new PackagePermission((String) cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR),
                             PackagePermission.EXPORTONLY)) ||
                             !((module == null) ||
                                 ((BundleProtectionDomain) module.getSecurityContext()).impliesDirect(
-                                    new PackagePermission((String) cap.getAttribute(Capability.PACKAGE_ATTR).getValue(),
+                                    new PackagePermission((String) cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR),
                                     cap.getModule().getBundle(),PackagePermission.IMPORT))
                             )))
                     {
@@ -195,7 +195,7 @@ class ResolverStateImpl implements Resol
                             continue;
                         }
                     }
-                    else if (req.getNamespace().equals(Capability.MODULE_NAMESPACE) && (
+                    else if (req.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE) && (
                         !((BundleProtectionDomain) cap.getModule().getSecurityContext()).impliesDirect(
                             new BundlePermission(cap.getModule().getSymbolicName(), BundlePermission.PROVIDE)) ||
                             !((module == null) ||
@@ -205,7 +205,7 @@ class ResolverStateImpl implements Resol
                     {
                         continue;
                     }
-                    else if (req.getNamespace().equals(Capability.HOST_NAMESPACE) &&
+                    else if (req.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE) &&
                         (!((BundleProtectionDomain) req.getModule().getSecurityContext())
                             .impliesDirect(new BundlePermission(
                                 req.getModule().getSymbolicName(),
@@ -219,7 +219,7 @@ class ResolverStateImpl implements Resol
                     }
                 }
 
-                if (req.getNamespace().equals(Capability.HOST_NAMESPACE)
+                if (req.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE)
                     && cap.getModule().isResolved())
                 {
                     continue;

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java Fri May 13 14:57:58 2011
@@ -22,15 +22,13 @@ import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.*;
-import org.apache.felix.framework.capabilityset.Attribute;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Directive;
 import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.resolver.Wire;
 
 import org.apache.felix.framework.util.MapToDictionary;
 import org.apache.felix.framework.util.StringMap;
 import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.osgi.framework.*;
 import org.osgi.framework.BundleReference;
 
@@ -385,9 +383,15 @@ class ServiceRegistrationImpl implements
     // ServiceReference implementation
     //
 
-    class ServiceReferenceImpl implements ServiceReference, Capability
+    class ServiceReferenceImpl extends BundleCapabilityImpl implements ServiceReference
     {
-        private ServiceReferenceImpl() {}
+        private final ServiceReferenceMap m_map;
+
+        private ServiceReferenceImpl()
+        {
+            super(null, null, Collections.EMPTY_MAP, Collections.EMPTY_MAP);
+            m_map = new ServiceReferenceMap();
+        }
 
         ServiceRegistrationImpl getRegistration()
         {
@@ -398,42 +402,40 @@ class ServiceRegistrationImpl implements
         // Capability methods.
         //
 
+        @Override
         public Module getModule()
         {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
+        @Override
         public String getNamespace()
         {
             return "service-reference";
         }
 
-        public Directive getDirective(String name)
-        {
-            return null;
-        }
-
-        public List<Directive> getDirectives()
-        {
-            return Collections.EMPTY_LIST;
-        }
-
-        public Attribute getAttribute(String name)
+        @Override
+        public Map<String, String> getDirectives()
         {
-            Object value = ServiceRegistrationImpl.this.getProperty(name);
-            return (value == null) ? null : new Attribute(name, value, false);
+            return Collections.EMPTY_MAP;
         }
 
-        public List<Attribute> getAttributes()
+        @Override
+        public Map<String, Object> getAttributes()
         {
-            return Collections.EMPTY_LIST;
+            return m_map;
         }
 
+        @Override
         public List<String> getUses()
         {
             return Collections.EMPTY_LIST;
         }
 
+        //
+        // ServiceReference methods.
+        //
+
         public Object getProperty(String s)
         {
             return ServiceRegistrationImpl.this.getProperty(s);
@@ -642,4 +644,67 @@ class ServiceRegistrationImpl implements
             return (id.compareTo(otherId) < 0) ? 1 : -1;
         }
     }
+
+    private class ServiceReferenceMap implements Map
+    {
+        public int size()
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public boolean isEmpty()
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public boolean containsKey(Object o)
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public boolean containsValue(Object o)
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public Object get(Object o)
+        {
+            return ServiceRegistrationImpl.this.getProperty((String) o);
+        }
+
+        public Object put(Object k, Object v)
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public Object remove(Object o)
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public void putAll(Map map)
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public void clear()
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public Set<Object> keySet()
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public Collection<Object> values()
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public Set<Entry<Object, Object>> entrySet()
+        {
+            return Collections.EMPTY_SET;
+        }
+    }
 }
\ No newline at end of file

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java Fri May 13 14:57:58 2011
@@ -19,9 +19,9 @@
 package org.apache.felix.framework;
 
 import java.util.*;
-import org.apache.felix.framework.capabilityset.Capability;
 import org.apache.felix.framework.capabilityset.CapabilitySet;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 
 import org.osgi.framework.*;
 import org.osgi.framework.hooks.service.*;
@@ -98,7 +98,7 @@ public class ServiceRegistry
             // Get the bundles current registered services.
             ServiceRegistration[] regs = (ServiceRegistration[]) m_regsMap.get(bundle);
             m_regsMap.put(bundle, addServiceRegistration(regs, reg));
-            m_regCapSet.addCapability((Capability) reg.getReference());
+            m_regCapSet.addCapability((BundleCapabilityImpl) reg.getReference());
         }
 
         // Notify callback objects about registered service.
@@ -126,7 +126,7 @@ public class ServiceRegistry
             // Now remove the registered service.
             ServiceRegistration[] regs = (ServiceRegistration[]) m_regsMap.get(bundle);
             m_regsMap.put(bundle, removeServiceRegistration(regs, reg));
-            m_regCapSet.removeCapability((Capability) reg.getReference());
+            m_regCapSet.removeCapability((BundleCapabilityImpl) reg.getReference());
         }
 
         // Notify callback objects about unregistering service.
@@ -208,7 +208,7 @@ public class ServiceRegistry
         }
         // else just use the specified filter.
 
-        Set<Capability> matches = m_regCapSet.match(filter, false);
+        Set<BundleCapabilityImpl> matches = m_regCapSet.match(filter, false);
 
         return new ArrayList(matches);
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java Fri May 13 14:57:58 2011
@@ -32,45 +32,47 @@ import java.util.Set;
 import java.util.TreeMap;
 import org.apache.felix.framework.util.SecureAction;
 import org.apache.felix.framework.util.StringComparator;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 
 public class CapabilitySet
 {
-    private final Map<String, Map<Object, Set<Capability>>> m_indices;
-    private final Set<Capability> m_capSet = new HashSet<Capability>();
+    private final Map<String, Map<Object, Set<BundleCapabilityImpl>>> m_indices;
+    private final Set<BundleCapabilityImpl> m_capSet = new HashSet<BundleCapabilityImpl>();
     private final static SecureAction m_secureAction = new SecureAction();
 
     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));
+            ? new TreeMap<String, Map<Object, Set<BundleCapabilityImpl>>>()
+            : new TreeMap<String, Map<Object, Set<BundleCapabilityImpl>>>(
+                new StringComparator(false));
         for (int i = 0; (indexProps != null) && (i < indexProps.size()); i++)
         {
-            m_indices.put(indexProps.get(i), new HashMap<Object, Set<Capability>>());
+            m_indices.put(
+                indexProps.get(i), new HashMap<Object, Set<BundleCapabilityImpl>>());
         }
     }
 
-    public void addCapability(Capability cap)
+    public void addCapability(BundleCapabilityImpl cap)
     {
         m_capSet.add(cap);
 
         // Index capability.
-        for (Entry<String, Map<Object, Set<Capability>>> entry : m_indices.entrySet())
+        for (Entry<String, Map<Object, Set<BundleCapabilityImpl>>> entry : m_indices.entrySet())
         {
-            Attribute capAttr = cap.getAttribute(entry.getKey());
-            if (capAttr != null)
+            Object value = cap.getAttributes().get(entry.getKey());
+            if (value != null)
             {
-                Object capValue = capAttr.getValue();
-                if (capValue.getClass().isArray())
+                if (value.getClass().isArray())
                 {
-                    capValue = convertArrayToList(capValue);
+                    value = convertArrayToList(value);
                 }
 
-                Map<Object, Set<Capability>> index = entry.getValue();
+                Map<Object, Set<BundleCapabilityImpl>> index = entry.getValue();
 
-                if (capValue instanceof Collection)
+                if (value instanceof Collection)
                 {
-                    Collection c = (Collection) capValue;
+                    Collection c = (Collection) value;
                     for (Object o : c)
                     {
                         indexCapability(index, cap, o);
@@ -78,44 +80,43 @@ public class CapabilitySet
                 }
                 else
                 {
-                    indexCapability(index, cap, capValue);
+                    indexCapability(index, cap, value);
                 }
             }
         }
     }
 
     private void indexCapability(
-        Map<Object, Set<Capability>> index, Capability cap, Object capValue)
+        Map<Object, Set<BundleCapabilityImpl>> index, BundleCapabilityImpl cap, Object capValue)
     {
-        Set<Capability> caps = index.get(capValue);
+        Set<BundleCapabilityImpl> caps = index.get(capValue);
         if (caps == null)
         {
-            caps = new HashSet<Capability>();
+            caps = new HashSet<BundleCapabilityImpl>();
             index.put(capValue, caps);
         }
         caps.add(cap);
     }
 
-    public void removeCapability(Capability cap)
+    public void removeCapability(BundleCapabilityImpl cap)
     {
         if (m_capSet.remove(cap))
         {
-            for (Entry<String, Map<Object, Set<Capability>>> entry : m_indices.entrySet())
+            for (Entry<String, Map<Object, Set<BundleCapabilityImpl>>> entry : m_indices.entrySet())
             {
-                Attribute capAttr = cap.getAttribute(entry.getKey());
-                if (capAttr != null)
+                Object value = cap.getAttributes().get(entry.getKey());
+                if (value != null)
                 {
-                    Object capValue = capAttr.getValue();
-                    if (capValue.getClass().isArray())
+                    if (value.getClass().isArray())
                     {
-                        capValue = convertArrayToList(capValue);
+                        value = convertArrayToList(value);
                     }
 
-                    Map<Object, Set<Capability>> index = entry.getValue();
+                    Map<Object, Set<BundleCapabilityImpl>> index = entry.getValue();
 
-                    if (capValue instanceof Collection)
+                    if (value instanceof Collection)
                     {
-                        Collection c = (Collection) capValue;
+                        Collection c = (Collection) value;
                         for (Object o : c)
                         {
                             deindexCapability(index, cap, o);
@@ -123,7 +124,7 @@ public class CapabilitySet
                     }
                     else
                     {
-                        deindexCapability(index, cap, capValue);
+                        deindexCapability(index, cap, value);
                     }
                 }
             }
@@ -131,30 +132,30 @@ public class CapabilitySet
     }
 
     private void deindexCapability(
-        Map<Object, Set<Capability>> index, Capability cap, Object capValue)
+        Map<Object, Set<BundleCapabilityImpl>> index, BundleCapabilityImpl cap, Object value)
     {
-        Set<Capability> caps = index.get(capValue);
+        Set<BundleCapabilityImpl> caps = index.get(value);
         if (caps != null)
         {
             caps.remove(cap);
             if (caps.isEmpty())
             {
-                index.remove(capValue);
+                index.remove(value);
             }
         }
     }
 
-    public Set<Capability> match(SimpleFilter sf, boolean obeyMandatory)
+    public Set<BundleCapabilityImpl> match(SimpleFilter sf, boolean obeyMandatory)
     {
-        Set<Capability> matches = match(m_capSet, sf);
+        Set<BundleCapabilityImpl> matches = match(m_capSet, sf);
         return (obeyMandatory)
             ? matchMandatory(matches, sf)
             : matches;
     }
 
-    private Set<Capability> match(Set<Capability> caps, SimpleFilter sf)
+    private Set<BundleCapabilityImpl> match(Set<BundleCapabilityImpl> caps, SimpleFilter sf)
     {
-        Set<Capability> matches = new HashSet<Capability>();
+        Set<BundleCapabilityImpl> matches = new HashSet<BundleCapabilityImpl>();
 
         if (sf.getOperation() == SimpleFilter.MATCH_ALL)
         {
@@ -196,10 +197,10 @@ public class CapabilitySet
         }
         else
         {
-            Map<Object, Set<Capability>> index = m_indices.get(sf.getName());
+            Map<Object, Set<BundleCapabilityImpl>> index = m_indices.get(sf.getName());
             if ((sf.getOperation() == SimpleFilter.EQ) && (index != null))
             {
-                Set<Capability> existingCaps = index.get(sf.getValue());
+                Set<BundleCapabilityImpl> existingCaps = index.get(sf.getValue());
                 if (existingCaps != null)
                 {
                     matches.addAll(existingCaps);
@@ -208,13 +209,12 @@ public class CapabilitySet
             }
             else
             {
-                for (Iterator<Capability> it = caps.iterator(); it.hasNext(); )
+                for (Iterator<BundleCapabilityImpl> it = caps.iterator(); it.hasNext(); )
                 {
-                    Capability cap = it.next();
-                    Attribute attr = cap.getAttribute(sf.getName());
-                    if (attr != null)
+                    BundleCapabilityImpl cap = it.next();
+                    Object lhs = cap.getAttributes().get(sf.getName());
+                    if (lhs != null)
                     {
-                        Object lhs = attr.getValue();
                         if (compare(lhs, sf.getValue(), sf.getOperation()))
                         {
                             matches.add(cap);
@@ -227,12 +227,12 @@ public class CapabilitySet
         return matches;
     }
 
-    public static boolean matches(Capability cap, SimpleFilter sf)
+    public static boolean matches(BundleCapabilityImpl cap, SimpleFilter sf)
     {
         return matchesInternal(cap, sf) && matchMandatory(cap, sf);
     }
 
-    private static boolean matchesInternal(Capability cap, SimpleFilter sf)
+    private static boolean matchesInternal(BundleCapabilityImpl cap, SimpleFilter sf)
     {
         boolean matched = true;
 
@@ -272,10 +272,9 @@ public class CapabilitySet
         else
         {
             matched = false;
-            Attribute attr = cap.getAttribute(sf.getName());
-            if (attr != null)
+            Object lhs = cap.getAttributes().get(sf.getName());
+            if (lhs != null)
             {
-                Object lhs = attr.getValue();
                 matched = compare(lhs, sf.getValue(), sf.getOperation());
             }
         }
@@ -283,11 +282,12 @@ public class CapabilitySet
         return matched;
     }
 
-    private static Set<Capability> matchMandatory(Set<Capability> caps, SimpleFilter sf)
+    private static Set<BundleCapabilityImpl> matchMandatory(
+        Set<BundleCapabilityImpl> caps, SimpleFilter sf)
     {
-        for (Iterator<Capability> it = caps.iterator(); it.hasNext(); )
+        for (Iterator<BundleCapabilityImpl> it = caps.iterator(); it.hasNext(); )
         {
-            Capability cap = it.next();
+            BundleCapabilityImpl cap = it.next();
             if (!matchMandatory(cap, sf))
             {
                 it.remove();
@@ -296,13 +296,13 @@ public class CapabilitySet
         return caps;
     }
 
-    private static boolean matchMandatory(Capability cap, SimpleFilter sf)
+    private static boolean matchMandatory(BundleCapabilityImpl cap, SimpleFilter sf)
     {
-        List<Attribute> attrs = cap.getAttributes();
-        for (int attrIdx = 0; attrIdx < attrs.size(); attrIdx++)
+        Map<String, Object> attrs = cap.getAttributes();
+        for (Entry<String, Object> entry : attrs.entrySet())
         {
-            if (attrs.get(attrIdx).isMandatory()
-                && !matchMandatory(attrs.get(attrIdx), sf))
+            if (cap.isAttributeMandatory(entry.getKey())
+                && !matchMandatoryAttrbute(entry.getKey(), sf))
             {
                 return false;
             }
@@ -310,9 +310,9 @@ public class CapabilitySet
         return true;
     }
 
-    private static boolean matchMandatory(Attribute attr, SimpleFilter sf)
+    private static boolean matchMandatoryAttrbute(String attrName, SimpleFilter sf)
     {
-        if ((sf.getName() != null) && sf.getName().equals(attr.getName()))
+        if ((sf.getName() != null) && sf.getName().equals(attrName))
         {
             return true;
         }
@@ -323,7 +323,7 @@ public class CapabilitySet
             {
                 SimpleFilter sf2 = (SimpleFilter) list.get(i);
                 if ((sf2.getName() != null)
-                    && sf2.getName().equals(attr.getName()))
+                    && sf2.getName().equals(attrName))
                 {
                     return true;
                 }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java Fri May 13 14:57:58 2011
@@ -19,13 +19,13 @@
 package org.apache.felix.framework.resolver;
 
 import java.util.Comparator;
-import org.apache.felix.framework.capabilityset.Capability;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 
-public class CandidateComparator implements Comparator<Capability>
+public class CandidateComparator implements Comparator<BundleCapabilityImpl>
 {
-    public int compare(Capability cap1, Capability cap2)
+    public int compare(BundleCapabilityImpl cap1, BundleCapabilityImpl cap2)
     {
         // First check resolved state, since resolved capabilities have priority
         // over unresolved ones. Compare in reverse order since we want to sort
@@ -41,37 +41,36 @@ public class CandidateComparator impleme
         }
 
         // Compare module capabilities.
-        if ((c == 0) && cap1.getNamespace().equals(Capability.MODULE_NAMESPACE))
+        if ((c == 0) && cap1.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
         {
-            c = ((Comparable) cap1.getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE)
-                .getValue()).compareTo(cap2.getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE)
-                    .getValue());
+            c = ((Comparable) cap1.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
+                .compareTo(cap2.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE));
             if (c == 0)
             {
-                Version v1 = (cap1.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE) == null)
+                Version v1 = (!cap1.getAttributes().containsKey(Constants.BUNDLE_VERSION_ATTRIBUTE))
                     ? Version.emptyVersion
-                    : (Version) cap1.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE).getValue();
-                Version v2 = (cap2.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE) == null)
+                    : (Version) cap1.getAttributes().get(Constants.BUNDLE_VERSION_ATTRIBUTE);
+                Version v2 = (!cap2.getAttributes().containsKey(Constants.BUNDLE_VERSION_ATTRIBUTE))
                     ? Version.emptyVersion
-                    : (Version) cap2.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE).getValue();
+                    : (Version) cap2.getAttributes().get(Constants.BUNDLE_VERSION_ATTRIBUTE);
                 // Compare these in reverse order, since we want
                 // highest version to have priority.
                 c = v2.compareTo(v1);
             }
         }
         // Compare package capabilities.
-        else if ((c == 0) && cap1.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+        else if ((c == 0) && cap1.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
-            c = ((Comparable) cap1.getAttribute(Capability.PACKAGE_ATTR).getValue())
-                .compareTo(cap2.getAttribute(Capability.PACKAGE_ATTR).getValue());
+            c = ((Comparable) cap1.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR))
+                .compareTo(cap2.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR));
             if (c == 0)
             {
-                Version v1 = (cap1.getAttribute(Capability.VERSION_ATTR) == null)
+                Version v1 = (!cap1.getAttributes().containsKey(BundleCapabilityImpl.VERSION_ATTR))
                     ? Version.emptyVersion
-                    : (Version) cap1.getAttribute(Capability.VERSION_ATTR).getValue();
-                Version v2 = (cap2.getAttribute(Capability.VERSION_ATTR) == null)
+                    : (Version) cap1.getAttributes().get(BundleCapabilityImpl.VERSION_ATTR);
+                Version v2 = (!cap2.getAttributes().containsKey(BundleCapabilityImpl.VERSION_ATTR))
                     ? Version.emptyVersion
-                    : (Version) cap2.getAttribute(Capability.VERSION_ATTR).getValue();
+                    : (Version) cap2.getAttributes().get(BundleCapabilityImpl.VERSION_ATTR);
                 // Compare these in reverse order, since we want
                 // highest version to have priority.
                 c = v2.compareTo(v1);



Mime
View raw message