You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2011/05/13 16:57:59 UTC

svn commit: r1102776 [2/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...

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java Fri May 13 14:57:58 2011
@@ -30,11 +30,10 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeMap;
 import java.util.TreeSet;
-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.Resolver.ResolverState;
 import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 
@@ -45,14 +44,15 @@ class Candidates
     // Set of all candidate modules.
     private final Set<Module> m_candidateModules;
     // Maps a capability to requirements that match it.
-    private final Map<Capability, Set<Requirement>> m_dependentMap;
+    private final Map<BundleCapabilityImpl, Set<BundleRequirementImpl>> m_dependentMap;
     // Maps a requirement to the capability it matches.
-    private final Map<Requirement, SortedSet<Capability>> m_candidateMap;
+    private final Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> m_candidateMap;
     // Maps a host capability to a map containing its potential fragments;
     // the fragment map maps a fragment symbolic name to a map that maps
     // a version to a list of fragments requirements matching that symbolic
     // name and version.
-    private final Map<Capability, Map<String, Map<Version, List<Requirement>>>> m_hostFragments;
+    private final Map<BundleCapabilityImpl,
+        Map<String, Map<Version, List<BundleRequirementImpl>>>> m_hostFragments;
     // Maps a module to its associated wrapped module; this only happens
     // when a module being resolved has fragments to attach to it.
     private final Map<Module, HostModule> m_allWrappedHosts;
@@ -73,9 +73,9 @@ class Candidates
     private Candidates(
         Module root,
         Set<Module> candidateModules,
-        Map<Capability, Set<Requirement>> dependentMap,
-        Map<Requirement, SortedSet<Capability>> candidateMap,
-        Map<Capability, Map<String, Map<Version, List<Requirement>>>> hostFragments,
+        Map<BundleCapabilityImpl, Set<BundleRequirementImpl>> dependentMap,
+        Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> candidateMap,
+        Map<BundleCapabilityImpl, Map<String, Map<Version, List<BundleRequirementImpl>>>> hostFragments,
         Map<Module, HostModule> wrappedHosts, Map<Module, Object> populateResultCache,
         boolean fragmentsPresent)
     {
@@ -98,10 +98,10 @@ class Candidates
     {
         m_root = root;
         m_candidateModules = new HashSet<Module>();
-        m_dependentMap = new HashMap<Capability, Set<Requirement>>();
-        m_candidateMap = new HashMap<Requirement, SortedSet<Capability>>();
+        m_dependentMap = new HashMap<BundleCapabilityImpl, Set<BundleRequirementImpl>>();
+        m_candidateMap = new HashMap<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>>();
         m_hostFragments =
-            new HashMap<Capability, Map<String, Map<Version, List<Requirement>>>>();
+            new HashMap<BundleCapabilityImpl, Map<String, Map<Version, List<BundleRequirementImpl>>>>();
         m_allWrappedHosts = new HashMap<Module, HostModule>();
         m_populateResultCache = new HashMap<Module, Object>();
 
@@ -119,14 +119,14 @@ class Candidates
      * @param candidates the potential candidates matching the requirement.
     **/
     public Candidates(ResolverState state, Module root,
-        Requirement req, SortedSet<Capability> candidates)
+        BundleRequirementImpl req, SortedSet<BundleCapabilityImpl> candidates)
     {
         m_root = root;
         m_candidateModules = new HashSet<Module>();
-        m_dependentMap = new HashMap<Capability, Set<Requirement>>();
-        m_candidateMap = new HashMap<Requirement, SortedSet<Capability>>();
+        m_dependentMap = new HashMap<BundleCapabilityImpl, Set<BundleRequirementImpl>>();
+        m_candidateMap = new HashMap<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>>();
         m_hostFragments =
-            new HashMap<Capability, Map<String, Map<Version, List<Requirement>>>>();
+            new HashMap<BundleCapabilityImpl, Map<String, Map<Version, List<BundleRequirementImpl>>>>();
         m_allWrappedHosts = new HashMap<Module, HostModule>();
         m_populateResultCache = new HashMap<Module, Object>();
 
@@ -163,11 +163,11 @@ class Candidates
 
         // Keeps track of the candidates we've already calculated for the
         // current module's requirements.
-        Map<Requirement, SortedSet<Capability>> localCandidateMap = null;
+        Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> localCandidateMap = null;
 
         // Keeps track of the current module's requirements for which we
         // haven't yet found candidates.
-        List<Requirement> remainingReqs = null;
+        List<BundleRequirementImpl> remainingReqs = null;
 
         // Get the cache value for the current module.
         Object cacheValue = m_populateResultCache.get(module);
@@ -226,14 +226,15 @@ class Candidates
         // If we have requirements remaining, then find candidates for them.
         while (remainingReqs.size() > 0)
         {
-            Requirement req = remainingReqs.remove(0);
+            BundleRequirementImpl req = remainingReqs.remove(0);
 
             // Get satisfying candidates and populate their candidates if necessary.
             ResolveException rethrow = null;
-            SortedSet<Capability> candidates = state.getCandidates(req, true);
-            for (Iterator<Capability> itCandCap = candidates.iterator(); itCandCap.hasNext(); )
+            SortedSet<BundleCapabilityImpl> candidates = state.getCandidates(req, true);
+            for (Iterator<BundleCapabilityImpl> itCandCap = candidates.iterator();
+                itCandCap.hasNext(); )
             {
-                Capability candCap = itCandCap.next();
+                BundleCapabilityImpl candCap = itCandCap.next();
 
                 // If the candidate module is a fragment, then always attempt
                 // to populate candidates for its dependency, since it must be
@@ -328,14 +329,14 @@ class Candidates
                 if (cacheValue == null)
                 {
                     // Create a modifiable list of the module's requirements.
-                    List<Requirement> remainingReqs = new ArrayList(module.getRequirements());
+                    List<BundleRequirementImpl> remainingReqs = new ArrayList(module.getRequirements());
 
                     // Find the host requirement.
-                    Requirement hostReq = null;
-                    for (Iterator<Requirement> it = remainingReqs.iterator(); it.hasNext(); )
+                    BundleRequirementImpl hostReq = null;
+                    for (Iterator<BundleRequirementImpl> it = remainingReqs.iterator(); it.hasNext(); )
                     {
-                        Requirement r = it.next();
-                        if (r.getNamespace().equals(Capability.HOST_NAMESPACE))
+                        BundleRequirementImpl r = it.next();
+                        if (r.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
                         {
                             hostReq = r;
                             it.remove();
@@ -343,10 +344,10 @@ class Candidates
                     }
 
                     // Get candidates hosts and keep any that have been populated.
-                    SortedSet<Capability> hosts = state.getCandidates(hostReq, false);
-                    for (Iterator<Capability> it = hosts.iterator(); it.hasNext(); )
+                    SortedSet<BundleCapabilityImpl> hosts = state.getCandidates(hostReq, false);
+                    for (Iterator<BundleCapabilityImpl> it = hosts.iterator(); it.hasNext(); )
                     {
-                        Capability host = it.next();
+                        BundleCapabilityImpl host = it.next();
                         if (!isPopulated(host.getModule()))
                         {
                             it.remove();
@@ -376,7 +377,8 @@ class Candidates
 
                     // Create a local map for populating candidates first, just in case
                     // the module is not resolvable.
-                    Map<Requirement, SortedSet<Capability>> localCandidateMap = new HashMap();
+                    Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> localCandidateMap =
+                        new HashMap<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>>();
 
                     // Add the discovered host candidates to the local candidate map.
                     localCandidateMap.put(hostReq, hosts);
@@ -410,13 +412,14 @@ class Candidates
         // the candidates for the matching dynamic requirement. Get the
         // matching candidates and populate their candidates if necessary.
         ResolveException rethrow = null;
-        Entry<Requirement, SortedSet<Capability>> entry =
+        Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry =
             m_candidateMap.entrySet().iterator().next();
-        Requirement dynReq = entry.getKey();
-        SortedSet<Capability> candidates = entry.getValue();
-        for (Iterator<Capability> itCandCap = candidates.iterator(); itCandCap.hasNext(); )
+        BundleRequirementImpl dynReq = entry.getKey();
+        SortedSet<BundleCapabilityImpl> candidates = entry.getValue();
+        for (Iterator<BundleCapabilityImpl> itCandCap = candidates.iterator();
+            itCandCap.hasNext(); )
         {
-            Capability candCap = itCandCap.next();
+            BundleCapabilityImpl candCap = itCandCap.next();
             if (!candCap.getModule().isResolved())
             {
                 try
@@ -453,9 +456,9 @@ class Candidates
      * @param req the requirement to add.
      * @param candidates the candidates matching the requirement.
     **/
-    private void add(Requirement req, SortedSet<Capability> candidates)
+    private void add(BundleRequirementImpl req, SortedSet<BundleCapabilityImpl> candidates)
     {
-        if (req.getNamespace().equals(Capability.HOST_NAMESPACE))
+        if (req.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
         {
             m_fragmentsPresent = true;
         }
@@ -466,7 +469,7 @@ class Candidates
         // Make a list of all candidate modules for determining singetons.
         // Add the requirement as a dependent on the candidates. Keep track
         // of fragments for hosts.
-        for (Capability cap : candidates)
+        for (BundleCapabilityImpl cap : candidates)
         {
             // Remember the module for all capabilities so we can
             // determine which ones are singletons.
@@ -480,9 +483,9 @@ class Candidates
      * be further modified by the caller.
      * @param candidates the bulk requirements and candidates to add.
     **/
-    private void add(Map<Requirement, SortedSet<Capability>> candidates)
+    private void add(Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> candidates)
     {
-        for (Entry<Requirement, SortedSet<Capability>> entry : candidates.entrySet())
+        for (Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry : candidates.entrySet())
         {
             add(entry.getKey(), entry.getValue());
         }
@@ -506,7 +509,7 @@ class Candidates
      * @param req the requirement whose candidates are desired.
      * @return the matching candidates or null.
     **/
-    public SortedSet<Capability> getCandidates(Requirement req)
+    public SortedSet<BundleCapabilityImpl> getCandidates(BundleRequirementImpl req)
     {
         return m_candidateMap.get(req);
     }
@@ -626,22 +629,24 @@ class Candidates
         //      with host's attached fragment capabilities.
 
         // Steps 1 and 2
-        List<HostModule> wrappedHosts = new ArrayList<HostModule>();
+        List<HostModule> hostModules = new ArrayList<HostModule>();
         List<Module> unselectedFragments = new ArrayList<Module>();
-        for (Entry<Capability, Map<String, Map<Version, List<Requirement>>>> hostEntry :
-            m_hostFragments.entrySet())
+        for (Entry<BundleCapabilityImpl, Map<String, Map<Version, List<BundleRequirementImpl>>>>
+            hostEntry : m_hostFragments.entrySet())
         {
             // Step 1
-            Capability hostCap = hostEntry.getKey();
-            Map<String, Map<Version, List<Requirement>>> fragments = hostEntry.getValue();
+            BundleCapabilityImpl hostCap = hostEntry.getKey();
+            Map<String, Map<Version, List<BundleRequirementImpl>>> fragments
+                = hostEntry.getValue();
             List<Module> selectedFragments = new ArrayList<Module>();
-            for (Entry<String, Map<Version, List<Requirement>>> fragEntry : fragments.entrySet())
+            for (Entry<String, Map<Version, List<BundleRequirementImpl>>> fragEntry
+                : fragments.entrySet())
             {
                 boolean isFirst = true;
-                for (Entry<Version, List<Requirement>> versionEntry
+                for (Entry<Version, List<BundleRequirementImpl>> versionEntry
                     : fragEntry.getValue().entrySet())
                 {
-                    for (Requirement hostReq : versionEntry.getValue())
+                    for (BundleRequirementImpl hostReq : versionEntry.getValue())
                     {
                         // Select the highest version of the fragment that
                         // is not removal pending.
@@ -658,7 +663,7 @@ class Candidates
                         else
                         {
                             m_dependentMap.get(hostCap).remove(hostReq);
-                            SortedSet<Capability> hosts = m_candidateMap.get(hostReq);
+                            SortedSet<BundleCapabilityImpl> hosts = m_candidateMap.get(hostReq);
                             hosts.remove(hostCap);
                             if (hosts.isEmpty())
                             {
@@ -671,7 +676,7 @@ class Candidates
 
             // Step 2
             HostModule wrappedHost = new HostModule(hostCap.getModule(), selectedFragments);
-            wrappedHosts.add(wrappedHost);
+            hostModules.add(wrappedHost);
             m_allWrappedHosts.put(hostCap.getModule(), wrappedHost);
         }
 
@@ -682,19 +687,19 @@ class Candidates
         }
 
         // Step 4
-        for (HostModule wrappedHost : wrappedHosts)
+        for (HostModule hostModule : hostModules)
         {
             // Replaces capabilities from fragments with the capabilities
             // from the merged host.
-            for (Capability c : wrappedHost.getCapabilities())
+            for (BundleCapabilityImpl c : hostModule.getCapabilities())
             {
-                Set<Requirement> dependents =
+                Set<BundleRequirementImpl> dependents =
                     m_dependentMap.get(((HostedCapability) c).getDeclaredCapability());
                 if (dependents != null)
                 {
-                    for (Requirement r : dependents)
+                    for (BundleRequirementImpl r : dependents)
                     {
-                        Set<Capability> cands = m_candidateMap.get(r);
+                        Set<BundleCapabilityImpl> cands = m_candidateMap.get(r);
                         cands.remove(((HostedCapability) c).getDeclaredCapability());
                         cands.add(c);
                     }
@@ -704,13 +709,13 @@ class Candidates
             // Copies candidates for fragment requirements to the host.
             // This doesn't record the reverse dependency, but that
             // information should not be needed at this point anymore.
-            for (Requirement r : wrappedHost.getRequirements())
+            for (BundleRequirementImpl r : hostModule.getRequirements())
             {
-                SortedSet<Capability> cands =
+                SortedSet<BundleCapabilityImpl> cands =
                     m_candidateMap.get(((HostedRequirement) r).getDeclaredRequirement());
                 if (cands != null)
                 {
-                    m_candidateMap.put(r, new TreeSet<Capability>(cands));
+                    m_candidateMap.put(r, new TreeSet<BundleCapabilityImpl>(cands));
                 }
             }
         }
@@ -718,43 +723,44 @@ class Candidates
 
     private void populateDependents()
     {
-        for (Entry<Requirement, SortedSet<Capability>> entry : m_candidateMap.entrySet())
+        for (Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry
+            : m_candidateMap.entrySet())
         {
-            Requirement req = entry.getKey();
-            SortedSet<Capability> caps = entry.getValue();
-            for (Capability cap : caps)
+            BundleRequirementImpl req = entry.getKey();
+            SortedSet<BundleCapabilityImpl> caps = entry.getValue();
+            for (BundleCapabilityImpl cap : caps)
             {
                 // Record the requirement as dependent on the capability.
-                Set<Requirement> dependents = m_dependentMap.get(cap);
+                Set<BundleRequirementImpl> dependents = m_dependentMap.get(cap);
                 if (dependents == null)
                 {
-                    dependents = new HashSet<Requirement>();
+                    dependents = new HashSet<BundleRequirementImpl>();
                     m_dependentMap.put(cap, dependents);
                 }
                 dependents.add(req);
 
                 // Keep track of hosts and associated fragments.
-                if (req.getNamespace().equals(Capability.HOST_NAMESPACE))
+                if (req.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
                 {
-                    Map<String, Map<Version, List<Requirement>>>
+                    Map<String, Map<Version, List<BundleRequirementImpl>>>
                         fragments = m_hostFragments.get(cap);
                     if (fragments == null)
                     {
-                        fragments = new HashMap<String, Map<Version, List<Requirement>>>();
+                        fragments = new HashMap<String, Map<Version, List<BundleRequirementImpl>>>();
                         m_hostFragments.put(cap, fragments);
                     }
-                    Map<Version, List<Requirement>> fragmentVersions =
+                    Map<Version, List<BundleRequirementImpl>> fragmentVersions =
                         fragments.get(req.getModule().getSymbolicName());
                     if (fragmentVersions == null)
                     {
                         fragmentVersions =
-                            new TreeMap<Version, List<Requirement>>(Collections.reverseOrder());
+                            new TreeMap<Version, List<BundleRequirementImpl>>(Collections.reverseOrder());
                         fragments.put(req.getModule().getSymbolicName(), fragmentVersions);
                     }
-                    List<Requirement> actual = fragmentVersions.get(req.getModule().getVersion());
+                    List<BundleRequirementImpl> actual = fragmentVersions.get(req.getModule().getVersion());
                     if (actual == null)
                     {
-                        actual = new ArrayList<Requirement>();
+                        actual = new ArrayList<BundleRequirementImpl>();
                         fragmentVersions.put(req.getModule().getVersion(), actual);
                     }
                     actual.add(req);
@@ -803,12 +809,12 @@ class Candidates
     **/
     private void remove(Module m, Set<Module> unresolvedModules) throws ResolveException
     {
-        for (Requirement r : m.getRequirements())
+        for (BundleRequirementImpl r : m.getRequirements())
         {
             remove(r);
         }
 
-        for (Capability c : m.getCapabilities())
+        for (BundleCapabilityImpl c : m.getCapabilities())
         {
             remove(c, unresolvedModules);
         }
@@ -818,16 +824,16 @@ class Candidates
      * Removes a requirement from the internal data structures.
      * @param req the requirement to remove.
     **/
-    private void remove(Requirement req)
+    private void remove(BundleRequirementImpl req)
     {
-        boolean isFragment = req.getNamespace().equals(Capability.HOST_NAMESPACE);
+        boolean isFragment = req.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE);
 
-        SortedSet<Capability> candidates = m_candidateMap.remove(req);
+        SortedSet<BundleCapabilityImpl> candidates = m_candidateMap.remove(req);
         if (candidates != null)
         {
-            for (Capability cap : candidates)
+            for (BundleCapabilityImpl cap : candidates)
             {
-                Set<Requirement> dependents = m_dependentMap.get(cap);
+                Set<BundleRequirementImpl> dependents = m_dependentMap.get(cap);
                 if (dependents != null)
                 {
                     dependents.remove(req);
@@ -835,15 +841,15 @@ class Candidates
 
                 if (isFragment)
                 {
-                    Map<String, Map<Version, List<Requirement>>>
+                    Map<String, Map<Version, List<BundleRequirementImpl>>>
                         fragments = m_hostFragments.get(cap);
                     if (fragments != null)
                     {
-                        Map<Version, List<Requirement>> fragmentVersions =
+                        Map<Version, List<BundleRequirementImpl>> fragmentVersions =
                             fragments.get(req.getModule().getSymbolicName());
                         if (fragmentVersions != null)
                         {
-                            List<Requirement> actual =
+                            List<BundleRequirementImpl> actual =
                                 fragmentVersions.get(req.getModule().getVersion());
                             if (actual != null)
                             {
@@ -877,14 +883,15 @@ class Candidates
      *        also need to be removed.
      * @throws ResolveException if removing the module caused the resolve to fail.
     **/
-    private void remove(Capability c, Set<Module> unresolvedModules) throws ResolveException
+    private void remove(BundleCapabilityImpl c, Set<Module> unresolvedModules)
+        throws ResolveException
     {
-        Set<Requirement> dependents = m_dependentMap.remove(c);
+        Set<BundleRequirementImpl> dependents = m_dependentMap.remove(c);
         if (dependents != null)
         {
-            for (Requirement r : dependents)
+            for (BundleRequirementImpl r : dependents)
             {
-                SortedSet<Capability> candidates = m_candidateMap.get(r);
+                SortedSet<BundleCapabilityImpl> candidates = m_candidateMap.get(r);
                 candidates.remove(c);
                 if (candidates.isEmpty())
                 {
@@ -912,19 +919,21 @@ class Candidates
     **/
     public Candidates copy()
     {
-        Map<Capability, Set<Requirement>> dependentMap =
-            new HashMap<Capability, Set<Requirement>>();
-        for (Entry<Capability, Set<Requirement>> entry : m_dependentMap.entrySet())
+        Map<BundleCapabilityImpl, Set<BundleRequirementImpl>> dependentMap =
+            new HashMap<BundleCapabilityImpl, Set<BundleRequirementImpl>>();
+        for (Entry<BundleCapabilityImpl, Set<BundleRequirementImpl>> entry : m_dependentMap.entrySet())
         {
-            Set<Requirement> dependents = new HashSet<Requirement>(entry.getValue());
+            Set<BundleRequirementImpl> dependents = new HashSet<BundleRequirementImpl>(entry.getValue());
             dependentMap.put(entry.getKey(), dependents);
         }
 
-        Map<Requirement, SortedSet<Capability>> candidateMap =
-            new HashMap<Requirement, SortedSet<Capability>>();
-        for (Entry<Requirement, SortedSet<Capability>> entry : m_candidateMap.entrySet())
+        Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> candidateMap =
+            new HashMap<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>>();
+        for (Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry
+            : m_candidateMap.entrySet())
         {
-            SortedSet<Capability> candidates = new TreeSet<Capability>(entry.getValue());
+            SortedSet<BundleCapabilityImpl> candidates =
+                new TreeSet<BundleCapabilityImpl>(entry.getValue());
             candidateMap.put(entry.getKey(), candidates);
         }
 
@@ -938,7 +947,7 @@ class Candidates
     {
         // Create set of all modules from requirements.
         Set<Module> modules = new HashSet();
-        for (Entry<Requirement, SortedSet<Capability>> entry
+        for (Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry
             : m_candidateMap.entrySet())
         {
             modules.add(entry.getKey().getModule());
@@ -949,17 +958,17 @@ class Candidates
         {
             System.out.println("  " + module
                  + " (" + (module.isResolved() ? "RESOLVED)" : "UNRESOLVED)"));
-            for (Requirement req : module.getRequirements())
+            for (BundleRequirementImpl req : module.getRequirements())
             {
-                Set<Capability> candidates = m_candidateMap.get(req);
+                Set<BundleCapabilityImpl> candidates = m_candidateMap.get(req);
                 if ((candidates != null) && (candidates.size() > 0))
                 {
                     System.out.println("    " + req + ": " + candidates);
                 }
             }
-            for (Requirement req : module.getDynamicRequirements())
+            for (BundleRequirementImpl req : module.getDynamicRequirements())
             {
-                Set<Capability> candidates = m_candidateMap.get(req);
+                Set<BundleCapabilityImpl> candidates = m_candidateMap.get(req);
                 if ((candidates != null) && (candidates.size() > 0))
                 {
                     System.out.println("    " + req + ": " + candidates);
@@ -978,21 +987,17 @@ class Candidates
     **/
     private static boolean isSingleton(Module module)
     {
-        final List<Capability> modCaps =
+        final List<BundleCapabilityImpl> modCaps =
             Util.getCapabilityByNamespace(
-                module, Capability.MODULE_NAMESPACE);
+                module, BundleCapabilityImpl.MODULE_NAMESPACE);
         if (modCaps == null || modCaps.isEmpty())
         {
             return false;
         }
-        final List<Directive> dirs = modCaps.get(0).getDirectives();
-        for (int dirIdx = 0; (dirs != null) && (dirIdx < dirs.size()); dirIdx++)
+        String value = modCaps.get(0).getDirectives().get(Constants.SINGLETON_DIRECTIVE);
+        if (value != null)
         {
-            if (dirs.get(dirIdx).getName().equalsIgnoreCase(Constants.SINGLETON_DIRECTIVE)
-                && Boolean.valueOf((String) dirs.get(dirIdx).getValue()))
-            {
-                return true;
-            }
+            return Boolean.valueOf(value);
         }
         return false;
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostModule.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostModule.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostModule.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostModule.java Fri May 13 14:57:58 2011
@@ -26,9 +26,9 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
 import java.util.Map;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Requirement;
 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.Bundle;
 import org.osgi.framework.Version;
 
@@ -36,8 +36,8 @@ class HostModule implements Module
 {
     private final Module m_host;
     private final List<Module> m_fragments;
-    private List<Capability> m_cachedCapabilities = null;
-    private List<Requirement> m_cachedRequirements = null;
+    private List<BundleCapabilityImpl> m_cachedCapabilities = null;
+    private List<BundleRequirementImpl> m_cachedRequirements = null;
 
     public HostModule(Module module, List<Module> fragments)
     {
@@ -60,14 +60,14 @@ class HostModule implements Module
         return m_host.getId();
     }
 
-    public List<Capability> getCapabilities()
+    public List<BundleCapabilityImpl> getCapabilities()
     {
         if (m_cachedCapabilities == null)
         {
-            List<Capability> capList = new ArrayList<Capability>();
+            List<BundleCapabilityImpl> capList = new ArrayList<BundleCapabilityImpl>();
 
             // Wrap host capabilities.
-            List<Capability> caps = m_host.getCapabilities();
+            List<BundleCapabilityImpl> caps = m_host.getCapabilities();
             for (int capIdx = 0;
                 (caps != null) && (capIdx < caps.size());
                 capIdx++)
@@ -86,7 +86,7 @@ class HostModule implements Module
                     (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)));
@@ -98,14 +98,14 @@ class HostModule implements Module
         return m_cachedCapabilities;
     }
 
-    public List<Requirement> getRequirements()
+    public List<BundleRequirementImpl> getRequirements()
     {
         if (m_cachedRequirements == null)
         {
-            List<Requirement> reqList = new ArrayList<Requirement>();
+            List<BundleRequirementImpl> reqList = new ArrayList<BundleRequirementImpl>();
 
             // Wrap host requirements.
-            List<Requirement> reqs = m_host.getRequirements();
+            List<BundleRequirementImpl> reqs = m_host.getRequirements();
             for (int reqIdx = 0;
                 (reqs != null) && (reqIdx < reqs.size());
                 reqIdx++)
@@ -124,8 +124,8 @@ class HostModule implements Module
                     (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)));
@@ -162,7 +162,7 @@ class HostModule implements Module
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
-    public List<Requirement> getDynamicRequirements()
+    public List<BundleRequirementImpl> getDynamicRequirements()
     {
         throw new UnsupportedOperationException("Not supported yet.");
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java Fri May 13 14:57:58 2011
@@ -19,17 +19,17 @@
 package org.apache.felix.framework.resolver;
 
 import java.util.List;
-import org.apache.felix.framework.capabilityset.Attribute;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Directive;
+import java.util.Map;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 
-public class HostedCapability implements Capability
+public class HostedCapability extends BundleCapabilityImpl
 {
     private final Module m_host;
-    private final Capability m_cap;
+    private final BundleCapabilityImpl m_cap;
 
-    public HostedCapability(Module module, Capability cap)
+    public HostedCapability(Module module, BundleCapabilityImpl cap)
     {
+        super(module, cap.getNamespace(), cap.getDirectives(), cap.getAttributes());
         m_host = module;
         m_cap = cap;
     }
@@ -66,41 +66,36 @@ public class HostedCapability implements
         return hash;
     }
 
-    public Capability getDeclaredCapability()
+    public BundleCapabilityImpl getDeclaredCapability()
     {
         return m_cap;
     }
 
+    @Override
     public Module getModule()
     {
         return m_host;
     }
 
+    @Override
     public String getNamespace()
     {
         return m_cap.getNamespace();
     }
 
-    public Directive getDirective(String name)
-    {
-        return m_cap.getDirective(name);
-    }
-
-    public List<Directive> getDirectives()
+    @Override
+    public Map<String, String> getDirectives()
     {
         return m_cap.getDirectives();
     }
 
-    public Attribute getAttribute(String name)
-    {
-        return m_cap.getAttribute(name);
-    }
-
-    public List<Attribute> getAttributes()
+    @Override
+    public Map<String, Object> getAttributes()
     {
         return m_cap.getAttributes();
     }
 
+    @Override
     public List<String> getUses()
     {
         return m_cap.getUses();
@@ -113,10 +108,10 @@ public class HostedCapability implements
         {
             return getAttributes().toString();
         }
-        if (getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+        if (getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
             return "[" + m_host + "] "
-                + getNamespace() + "; " + getAttribute(Capability.PACKAGE_ATTR);
+                + getNamespace() + "; " + getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR);
         }
         return "[" + m_host + "] " + getNamespace() + "; " + getAttributes();
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java Fri May 13 14:57:58 2011
@@ -18,18 +18,18 @@
  */
 package org.apache.felix.framework.resolver;
 
-import java.util.List;
-import org.apache.felix.framework.capabilityset.Directive;
-import org.apache.felix.framework.capabilityset.Requirement;
+import java.util.Map;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 
-public class HostedRequirement implements Requirement
+public class HostedRequirement extends BundleRequirementImpl
 {
     private final Module m_host;
-    private final Requirement m_req;
+    private final BundleRequirementImpl m_req;
 
-    public HostedRequirement(Module module, Requirement req)
+    public HostedRequirement(Module module, BundleRequirementImpl req)
     {
+        super(module, req.getNamespace(), req.getDirectives(), req.getAttributes());
         m_host = module;
         m_req = req;
     }
@@ -66,41 +66,48 @@ public class HostedRequirement implement
         return hash;
     }
 
-    public Requirement getDeclaredRequirement()
+    public BundleRequirementImpl getDeclaredRequirement()
     {
         return m_req;
     }
 
+    @Override
     public Module getModule()
     {
         return m_host;
     }
 
+    @Override
     public String getNamespace()
     {
         return m_req.getNamespace();
     }
 
+    @Override
     public SimpleFilter getFilter()
     {
         return m_req.getFilter();
     }
 
+    @Override
     public boolean isOptional()
     {
         return m_req.isOptional();
     }
 
-    public Directive getDirective(String name)
+    @Override
+    public Map<String, String> getDirectives()
     {
-        return m_req.getDirective(name);
+        return m_req.getDirectives();
     }
 
-    public List<Directive> getDirectives()
+    @Override
+    public Map<String, Object> getAttributes()
     {
-        return m_req.getDirectives();
+        return m_req.getAttributes();
     }
 
+    @Override
     public String toString()
     {
         return "[" + m_host + "] " + getNamespace() + "; " + getFilter().toString();

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Module.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Module.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Module.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Module.java Fri May 13 14:57:58 2011
@@ -24,9 +24,9 @@ import java.net.URL;
 import java.util.Enumeration;
 import java.util.List;
 import java.util.Map;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Requirement;
 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.Bundle;
 import org.osgi.framework.Version;
 
@@ -40,9 +40,9 @@ public interface Module
     boolean isExtension();
     String getSymbolicName();
     Version getVersion();
-    List<Capability> getCapabilities();
-    List<Requirement> getRequirements();
-    List<Requirement> getDynamicRequirements();
+    List<BundleCapabilityImpl> getCapabilities();
+    List<BundleRequirementImpl> getRequirements();
+    List<BundleRequirementImpl> getDynamicRequirements();
     List<R4Library> getNativeLibraries();
     int getDeclaredActivationPolicy();
 

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolveException.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolveException.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolveException.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolveException.java Fri May 13 14:57:58 2011
@@ -18,18 +18,18 @@
  */
 package org.apache.felix.framework.resolver;
 
-import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 
 public class ResolveException extends RuntimeException
 {
     private final Module m_module;
-    private final Requirement m_req;
+    private final BundleRequirementImpl m_req;
 
     /**
      * Constructs an instance of <code>ResolveException</code> with the specified detail message.
      * @param msg the detail message.
      */
-    public ResolveException(String msg, Module module, Requirement req)
+    public ResolveException(String msg, Module module, BundleRequirementImpl req)
     {
         super(msg);
         m_module = module;
@@ -41,7 +41,7 @@ public class ResolveException extends Ru
         return m_module;
     }
 
-    public Requirement getRequirement()
+    public BundleRequirementImpl getRequirement()
     {
         return m_req;
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Resolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Resolver.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Resolver.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Resolver.java Fri May 13 14:57:58 2011
@@ -22,8 +22,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedSet;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 
 public interface Resolver
 {
@@ -33,7 +33,8 @@ public interface Resolver
 
     public static interface ResolverState
     {
-        SortedSet<Capability> getCandidates(Requirement req, boolean obeyMandatory);
+        SortedSet<BundleCapabilityImpl> getCandidates(
+            BundleRequirementImpl req, boolean obeyMandatory);
         void checkExecutionEnvironment(Module module) throws ResolveException;
         void checkNativeLibraries(Module module) throws ResolveException;
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java Fri May 13 14:57:58 2011
@@ -29,13 +29,10 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.SortedSet;
 import org.apache.felix.framework.Logger;
-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.capabilityset.Requirement;
 import org.apache.felix.framework.util.Util;
-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.Constants;
 
 public class ResolverImpl implements Resolver
@@ -88,7 +85,7 @@ public class ResolverImpl implements Res
 
                     // If the requested module is a fragment, then
                     // ultimately we will verify the host.
-                    Requirement hostReq = getHostRequirement(module);
+                    BundleRequirementImpl hostReq = getHostRequirement(module);
                     Module target = module;
 
                     do
@@ -301,14 +298,14 @@ public class ResolverImpl implements Res
 
     private static List<Module> getResolvedSingletons(ResolverState state)
     {
-        Requirement req = new RequirementImpl(
+        BundleRequirementImpl req = new BundleRequirementImpl(
             null,
-            Capability.SINGLETON_NAMESPACE,
-            Collections.EMPTY_LIST,
-            Collections.EMPTY_LIST);
-        SortedSet<Capability> caps = state.getCandidates(req, true);
+            BundleCapabilityImpl.SINGLETON_NAMESPACE,
+            Collections.EMPTY_MAP,
+            Collections.EMPTY_MAP);
+        SortedSet<BundleCapabilityImpl> caps = state.getCandidates(req, true);
         List<Module> singletons = new ArrayList();
-        for (Capability cap : caps)
+        for (BundleCapabilityImpl cap : caps)
         {
             if (cap.getModule().isResolved())
             {
@@ -318,11 +315,11 @@ public class ResolverImpl implements Res
         return singletons;
     }
 
-    private static Capability getHostCapability(Module m)
+    private static BundleCapabilityImpl getHostCapability(Module m)
     {
-        for (Capability c : m.getCapabilities())
+        for (BundleCapabilityImpl c : m.getCapabilities())
         {
-            if (c.getNamespace().equals(Capability.HOST_NAMESPACE))
+            if (c.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
             {
                 return c;
             }
@@ -330,11 +327,11 @@ public class ResolverImpl implements Res
         return null;
     }
 
-    private static Requirement getHostRequirement(Module m)
+    private static BundleRequirementImpl getHostRequirement(Module m)
     {
-        for (Requirement r : m.getRequirements())
+        for (BundleRequirementImpl r : m.getRequirements())
         {
-            if (r.getNamespace().equals(Capability.HOST_NAMESPACE))
+            if (r.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
             {
                 return r;
             }
@@ -354,7 +351,7 @@ public class ResolverImpl implements Res
 
         // 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 null;
@@ -362,11 +359,11 @@ public class ResolverImpl implements Res
 
         // 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 null;
             }
@@ -385,23 +382,23 @@ public class ResolverImpl implements Res
         // 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);
-        SortedSet<Capability> candidates = state.getCandidates(req, false);
+        Map<String, String> dirs = Collections.EMPTY_MAP;
+        Map<String, Object> attrs = new HashMap(1);
+        attrs.put(BundleCapabilityImpl.PACKAGE_ATTR, pkgName);
+        BundleRequirementImpl req = new BundleRequirementImpl(
+            module, BundleCapabilityImpl.PACKAGE_NAMESPACE, dirs, attrs);
+        SortedSet<BundleCapabilityImpl> candidates = state.getCandidates(req, false);
 
         // First find a dynamic requirement that matches the capabilities.
-        Requirement dynReq = null;
+        BundleRequirementImpl dynReq = null;
         for (int dynIdx = 0;
             (candidates.size() > 0) && (dynReq == null) && (dynIdx < dynamics.size());
             dynIdx++)
         {
-            for (Iterator<Capability> itCand = candidates.iterator();
+            for (Iterator<BundleCapabilityImpl> itCand = candidates.iterator();
                 (dynReq == null) && itCand.hasNext(); )
             {
-                Capability cap = itCand.next();
+                BundleCapabilityImpl cap = itCand.next();
                 if (CapabilitySet.matches(cap, dynamics.get(dynIdx).getFilter()))
                 {
                     dynReq = dynamics.get(dynIdx);
@@ -413,9 +410,9 @@ public class ResolverImpl implements Res
         // any candidates that do not match it.
         if (dynReq != null)
         {
-            for (Iterator<Capability> itCand = candidates.iterator(); itCand.hasNext(); )
+            for (Iterator<BundleCapabilityImpl> itCand = candidates.iterator(); itCand.hasNext(); )
             {
-                Capability cap = itCand.next();
+                BundleCapabilityImpl cap = itCand.next();
                 if (!CapabilitySet.matches(cap, dynReq.getFilter()))
                 {
                     itCand.remove();
@@ -441,7 +438,7 @@ public class ResolverImpl implements Res
         Module module,
         Candidates allCandidates,
         Map<Module, Packages> modulePkgMap,
-        Map<Capability, List<Module>> usesCycleMap,
+        Map<BundleCapabilityImpl, List<Module>> usesCycleMap,
         Set<Module> cycle)
     {
         if (cycle.contains(module))
@@ -452,8 +449,8 @@ public class ResolverImpl implements Res
 
         // Create parallel arrays for requirement and proposed candidate
         // capability or actual capability if module is resolved or not.
-        List<Requirement> reqs = new ArrayList();
-        List<Capability> caps = new ArrayList();
+        List<BundleRequirementImpl> reqs = new ArrayList();
+        List<BundleCapabilityImpl> caps = new ArrayList();
         boolean isDynamicImport = false;
         if (module.isResolved())
         {
@@ -463,7 +460,7 @@ public class ResolverImpl implements Res
                 // Wrap the requirement as a hosted requirement
                 // if it comes from a fragment, since we will need
                 // to know the host.
-                Requirement r = wire.getRequirement();
+                BundleRequirementImpl r = wire.getRequirement();
                 if (!r.getModule().equals(wire.getImporter()))
                 {
                     r = new HostedRequirement(wire.getImporter(), r);
@@ -471,7 +468,7 @@ public class ResolverImpl implements Res
                 // Wrap the capability as a hosted capability
                 // if it comes from a fragment, since we will need
                 // to know the host.
-                Capability c = wire.getCapability();
+                BundleCapabilityImpl c = wire.getCapability();
                 if (!c.getModule().equals(wire.getExporter()))
                 {
                     c = new HostedCapability(wire.getExporter(), c);
@@ -483,17 +480,17 @@ public class ResolverImpl implements Res
             // Since the module is resolved, it could be dynamically importing,
             // so check to see if there are candidates for any of its dynamic
             // imports.
-            for (Requirement req : module.getDynamicRequirements())
+            for (BundleRequirementImpl req : module.getDynamicRequirements())
             {
                 // Get the candidates for the current requirement.
-                SortedSet<Capability> candCaps = allCandidates.getCandidates(req);
+                SortedSet<BundleCapabilityImpl> candCaps = allCandidates.getCandidates(req);
                 // Optional requirements may not have any candidates.
                 if (candCaps == null)
                 {
                     continue;
                 }
 
-                Capability cap = candCaps.iterator().next();
+                BundleCapabilityImpl cap = candCaps.iterator().next();
                 reqs.add(req);
                 caps.add(cap);
                 isDynamicImport = true;
@@ -504,17 +501,17 @@ public class ResolverImpl implements Res
         }
         else
         {
-            for (Requirement req : module.getRequirements())
+            for (BundleRequirementImpl req : module.getRequirements())
             {
                 // Get the candidates for the current requirement.
-                SortedSet<Capability> candCaps = allCandidates.getCandidates(req);
+                SortedSet<BundleCapabilityImpl> candCaps = allCandidates.getCandidates(req);
                 // Optional requirements may not have any candidates.
                 if (candCaps == null)
                 {
                     continue;
                 }
 
-                Capability cap = candCaps.iterator().next();
+                BundleCapabilityImpl cap = candCaps.iterator().next();
                 reqs.add(req);
                 caps.add(cap);
             }
@@ -527,8 +524,8 @@ public class ResolverImpl implements Res
         // Second, add all imported packages to the target module's package space.
         for (int i = 0; i < reqs.size(); i++)
         {
-            Requirement req = reqs.get(i);
-            Capability cap = caps.get(i);
+            BundleRequirementImpl req = reqs.get(i);
+            BundleCapabilityImpl cap = caps.get(i);
             calculateExportedPackages(cap.getModule(), allCandidates, modulePkgMap);
             mergeCandidatePackages(module, req, cap, modulePkgMap, allCandidates);
         }
@@ -559,7 +556,7 @@ public class ResolverImpl implements Res
                     // Ignore modules that import from themselves.
                     if (!blame.m_cap.getModule().equals(module))
                     {
-                        List<Requirement> blameReqs = new ArrayList();
+                        List<BundleRequirementImpl> blameReqs = new ArrayList();
                         blameReqs.add(blame.m_reqs.get(0));
 
                         mergeUses(
@@ -577,7 +574,7 @@ public class ResolverImpl implements Res
             {
                 for (Blame blame : entry.getValue())
                 {
-                    List<Requirement> blameReqs = new ArrayList();
+                    List<BundleRequirementImpl> blameReqs = new ArrayList();
                     blameReqs.add(blame.m_reqs.get(0));
 
                     mergeUses(
@@ -594,16 +591,16 @@ public class ResolverImpl implements Res
     }
 
     private void mergeCandidatePackages(
-        Module current, Requirement currentReq, Capability candCap,
+        Module current, BundleRequirementImpl currentReq, BundleCapabilityImpl candCap,
         Map<Module, Packages> modulePkgMap,
         Candidates allCandidates)
     {
-        if (candCap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+        if (candCap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
             mergeCandidatePackage(
                 current, false, currentReq, candCap, modulePkgMap);
         }
-        else if (candCap.getNamespace().equals(Capability.MODULE_NAMESPACE))
+        else if (candCap.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
         {
 // TODO: FELIX3 - THIS NEXT LINE IS A HACK. IMPROVE HOW/WHEN WE CALCULATE EXPORTS.
             calculateExportedPackages(
@@ -627,12 +624,12 @@ public class ResolverImpl implements Res
 
             // If the candidate requires any other bundles with reexport visibility,
             // then we also need to merge their packages too.
-            for (Requirement req : candCap.getModule().getRequirements())
+            for (BundleRequirementImpl req : candCap.getModule().getRequirements())
             {
-                if (req.getNamespace().equals(Capability.MODULE_NAMESPACE))
+                if (req.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
                 {
-                    Directive dir = req.getDirective(Constants.VISIBILITY_DIRECTIVE);
-                    if ((dir != null) && dir.getValue().equals(Constants.VISIBILITY_REEXPORT)
+                    String value = req.getDirectives().get(Constants.VISIBILITY_DIRECTIVE);
+                    if ((value != null) && value.equals(Constants.VISIBILITY_REEXPORT)
                         && (allCandidates.getCandidates(req) != null))
                     {
                         mergeCandidatePackages(
@@ -649,13 +646,13 @@ public class ResolverImpl implements Res
 
     private void mergeCandidatePackage(
         Module current, boolean requires,
-        Requirement currentReq, Capability candCap,
+        BundleRequirementImpl currentReq, BundleCapabilityImpl candCap,
         Map<Module, Packages> modulePkgMap)
     {
-        if (candCap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+        if (candCap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
             String pkgName = (String)
-                candCap.getAttribute(Capability.PACKAGE_ATTR).getValue();
+                candCap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR);
 
             // Since this capability represents a package, it will become
             // a hard constraint on the module's package space, so we need
@@ -699,12 +696,12 @@ public class ResolverImpl implements Res
 
     private void mergeUses(
         Module current, Packages currentPkgs,
-        Capability mergeCap, List<Requirement> blameReqs,
+        BundleCapabilityImpl mergeCap, List<BundleRequirementImpl> blameReqs,
         Map<Module, Packages> modulePkgMap,
         Candidates allCandidates,
-        Map<Capability, List<Module>> cycleMap)
+        Map<BundleCapabilityImpl, List<Module>> cycleMap)
     {
-        if (!mergeCap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+        if (!mergeCap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
             return;
         }
@@ -726,7 +723,7 @@ public class ResolverImpl implements Res
         list.add(current);
         cycleMap.put(mergeCap, list);
 
-        for (Capability candSourceCap : getPackageSources(mergeCap, modulePkgMap))
+        for (BundleCapabilityImpl candSourceCap : getPackageSources(mergeCap, modulePkgMap))
         {
             for (String usedPkgName : candSourceCap.getUses())
             {
@@ -758,7 +755,7 @@ public class ResolverImpl implements Res
                 {
                     if (blame.m_reqs != null)
                     {
-                        List<Requirement> blameReqs2 = new ArrayList(blameReqs);
+                        List<BundleRequirementImpl> blameReqs2 = new ArrayList(blameReqs);
                         blameReqs2.add(blame.m_reqs.get(blame.m_reqs.size() - 1));
                         usedCaps.add(new Blame(blame.m_cap, blameReqs2));
                         mergeUses(current, currentPkgs, blame.m_cap, blameReqs2,
@@ -795,7 +792,7 @@ public class ResolverImpl implements Res
 
         ResolveException rethrow = null;
         Candidates permutation = null;
-        Set<Requirement> mutated = null;
+        Set<BundleRequirementImpl> mutated = null;
 
         // Check for conflicting imports from fragments.
         for (Entry<String, List<Blame>> entry : pkgs.m_importedPkgs.entrySet())
@@ -884,7 +881,7 @@ public class ResolverImpl implements Res
 
                     for (int reqIdx = usedBlame.m_reqs.size() - 1; reqIdx >= 0; reqIdx--)
                     {
-                        Requirement req = usedBlame.m_reqs.get(reqIdx);
+                        BundleRequirementImpl req = usedBlame.m_reqs.get(reqIdx);
 
                         // If we've already permutated this requirement in another
                         // uses constraint, don't permutate it again just continue
@@ -897,7 +894,8 @@ public class ResolverImpl implements Res
                         // See if we can permutate the candidates for blamed
                         // requirement; there may be no candidates if the module
                         // associated with the requirement is already resolved.
-                        SortedSet<Capability> candidates = permutation.getCandidates(req);
+                        SortedSet<BundleCapabilityImpl> candidates =
+                            permutation.getCandidates(req);
                         if ((candidates != null) && (candidates.size() > 1))
                         {
                             mutated.add(req);
@@ -972,7 +970,7 @@ public class ResolverImpl implements Res
 
                         for (int reqIdx = usedBlame.m_reqs.size() - 1; reqIdx >= 0; reqIdx--)
                         {
-                            Requirement req = usedBlame.m_reqs.get(reqIdx);
+                            BundleRequirementImpl req = usedBlame.m_reqs.get(reqIdx);
 
                             // If we've already permutated this requirement in another
                             // uses constraint, don't permutate it again just continue
@@ -985,7 +983,8 @@ public class ResolverImpl implements Res
                             // See if we can permutate the candidates for blamed
                             // requirement; there may be no candidates if the module
                             // associated with the requirement is already resolved.
-                            SortedSet<Capability> candidates = permutation.getCandidates(req);
+                            SortedSet<BundleCapabilityImpl> candidates =
+                                permutation.getCandidates(req);
                             if ((candidates != null) && (candidates.size() > 1))
                             {
                                 mutated.add(req);
@@ -1016,7 +1015,7 @@ public class ResolverImpl implements Res
                     // Try to permutate the candidate for the original
                     // import requirement; only permutate it if we haven't
                     // done so already.
-                    Requirement req = importBlame.m_reqs.get(0);
+                    BundleRequirementImpl req = importBlame.m_reqs.get(0);
                     if (!mutated.contains(req))
                     {
                         // Since there may be lots of uses constraint violations
@@ -1063,7 +1062,7 @@ public class ResolverImpl implements Res
                         // to backtrack on our current candidate selection.
                         if (permCount == (m_usesPermutations.size() + m_importPermutations.size()))
                         {
-                            Requirement req = importBlame.m_reqs.get(0);
+                            BundleRequirementImpl req = importBlame.m_reqs.get(0);
                             permutate(allCandidates, req, m_importPermutations);
                         }
                         throw ex;
@@ -1074,9 +1073,9 @@ public class ResolverImpl implements Res
     }
 
     private static void permutate(
-        Candidates allCandidates, Requirement req, List<Candidates> permutations)
+        Candidates allCandidates, BundleRequirementImpl req, List<Candidates> permutations)
     {
-        SortedSet<Capability> candidates = allCandidates.getCandidates(req);
+        SortedSet<BundleCapabilityImpl> candidates = allCandidates.getCandidates(req);
         if (candidates.size() > 1)
         {
             Candidates perm = allCandidates.copy();
@@ -1089,9 +1088,9 @@ public class ResolverImpl implements Res
     }
 
     private static void permutateIfNeeded(
-        Candidates allCandidates, Requirement req, List<Candidates> permutations)
+        Candidates allCandidates, BundleRequirementImpl req, List<Candidates> permutations)
     {
-        SortedSet<Capability> candidates = allCandidates.getCandidates(req);
+        SortedSet<BundleCapabilityImpl> candidates = allCandidates.getCandidates(req);
         if (candidates.size() > 1)
         {
             // Check existing permutations to make sure we haven't
@@ -1103,7 +1102,7 @@ public class ResolverImpl implements Res
             boolean permutated = false;
             for (Candidates existingPerm : permutations)
             {
-                Set<Capability> existingPermCands = existingPerm.getCandidates(req);
+                Set<BundleCapabilityImpl> existingPermCands = existingPerm.getCandidates(req);
                 if (!existingPermCands.iterator().next().equals(candidates.iterator().next()))
                 {
                     permutated = true;
@@ -1131,14 +1130,14 @@ public class ResolverImpl implements Res
         packages = new Packages(module);
 
         // Get all exported packages.
-        Map<String, Capability> exports =
-            new HashMap<String, Capability>(module.getCapabilities().size());
-        for (Capability cap : module.getCapabilities())
+        Map<String, BundleCapabilityImpl> exports =
+            new HashMap<String, BundleCapabilityImpl>(module.getCapabilities().size());
+        for (BundleCapabilityImpl cap : module.getCapabilities())
         {
-            if (cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
             {
                 exports.put(
-                    (String) cap.getAttribute(Capability.PACKAGE_ATTR).getValue(),
+                    (String) cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR),
                     cap);
             }
         }
@@ -1150,32 +1149,32 @@ public class ResolverImpl implements Res
         {
             for (Wire wire : module.getWires())
             {
-                if (wire.getRequirement().getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                if (wire.getRequirement().getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                 {
                     String pkgName = (String) wire.getCapability()
-                        .getAttribute(Capability.PACKAGE_ATTR).getValue();
+                        .getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR);
                     exports.remove(pkgName);
                 }
             }
         }
         else
         {
-            for (Requirement req : module.getRequirements())
+            for (BundleRequirementImpl req : module.getRequirements())
             {
-                if (req.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                 {
-                    Set<Capability> cands = allCandidates.getCandidates(req);
+                    Set<BundleCapabilityImpl> cands = allCandidates.getCandidates(req);
                     if ((cands != null) && !cands.isEmpty())
                     {
                         String pkgName = (String) cands.iterator().next()
-                            .getAttribute(Capability.PACKAGE_ATTR).getValue();
+                            .getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR);
                         exports.remove(pkgName);
                     }
                 }
             }
         }
         // Add all non-substituted exports to the module's package space.
-        for (Entry<String, Capability> entry : exports.entrySet())
+        for (Entry<String, BundleCapabilityImpl> entry : exports.entrySet())
         {
             packages.m_exportedPkgs.put(
                 entry.getKey(), new Blame(entry.getValue(), null));
@@ -1185,7 +1184,8 @@ public class ResolverImpl implements Res
     }
 
     private boolean isCompatible(
-        Capability currentCap, Capability candCap, Map<Module, Packages> modulePkgMap)
+        BundleCapabilityImpl currentCap, BundleCapabilityImpl candCap,
+        Map<Module, Packages> modulePkgMap)
     {
         if ((currentCap != null) && (candCap != null))
         {
@@ -1194,28 +1194,30 @@ public class ResolverImpl implements Res
                 return true;
             }
 
-            List<Capability> currentSources =
+            List<BundleCapabilityImpl> currentSources =
                 getPackageSources(
                     currentCap,
                     modulePkgMap);
-            List<Capability> candSources =
+            List<BundleCapabilityImpl> candSources =
                 getPackageSources(
                     candCap,
                     modulePkgMap);
 
-            return currentSources.containsAll(candSources) || candSources.containsAll(currentSources);
+            return currentSources.containsAll(candSources)
+                || candSources.containsAll(currentSources);
         }
         return true;
     }
 
-    private Map<Capability, List<Capability>> m_packageSourcesCache = new HashMap();
+    private Map<BundleCapabilityImpl, List<BundleCapabilityImpl>> m_packageSourcesCache
+        = new HashMap();
 
-    private List<Capability> getPackageSources(
-        Capability cap, Map<Module, Packages> modulePkgMap)
+    private List<BundleCapabilityImpl> getPackageSources(
+        BundleCapabilityImpl cap, Map<Module, Packages> modulePkgMap)
     {
-        if (cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+        if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
-            List<Capability> sources = m_packageSourcesCache.get(cap);
+            List<BundleCapabilityImpl> sources = m_packageSourcesCache.get(cap);
             if (sources == null)
             {
                 sources = getPackageSourcesInternal(
@@ -1228,11 +1230,11 @@ public class ResolverImpl implements Res
         return Collections.EMPTY_LIST;
     }
 
-    private static List<Capability> getPackageSourcesInternal(
-        Capability cap, Map<Module, Packages> modulePkgMap, List<Capability> sources,
-        Set<Capability> cycleMap)
+    private static List<BundleCapabilityImpl> getPackageSourcesInternal(
+        BundleCapabilityImpl cap, Map<Module, Packages> modulePkgMap,
+        List<BundleCapabilityImpl> sources, Set<BundleCapabilityImpl> cycleMap)
     {
-        if (cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+        if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
             if (cycleMap.contains(cap))
             {
@@ -1241,15 +1243,16 @@ public class ResolverImpl implements Res
             cycleMap.add(cap);
 
             // Get the package name associated with the capability.
-            String pkgName = cap.getAttribute(Capability.PACKAGE_ATTR).getValue().toString();
+            String pkgName = cap.getAttributes()
+                .get(BundleCapabilityImpl.PACKAGE_ATTR).toString();
 
             // Since a module can export the same package more than once, get
             // all package capabilities for the specified package name.
-            List<Capability> caps = cap.getModule().getCapabilities();
+            List<BundleCapabilityImpl> caps = cap.getModule().getCapabilities();
             for (int capIdx = 0; capIdx < caps.size(); capIdx++)
             {
-                if (caps.get(capIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE)
-                    && caps.get(capIdx).getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+                if (caps.get(capIdx).getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE)
+                    && caps.get(capIdx).getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName))
                 {
                     sources.add(caps.get(capIdx));
                 }
@@ -1279,7 +1282,7 @@ public class ResolverImpl implements Res
         return m;
     }
 
-    private static Capability getActualCapability(Capability c)
+    private static BundleCapabilityImpl getActualCapability(BundleCapabilityImpl c)
     {
         if (c instanceof HostedCapability)
         {
@@ -1288,7 +1291,7 @@ public class ResolverImpl implements Res
         return c;
     }
 
-    private static Requirement getActualRequirement(Requirement r)
+    private static BundleRequirementImpl getActualRequirement(BundleRequirementImpl r)
     {
         if (r instanceof HostedRequirement)
         {
@@ -1310,19 +1313,19 @@ public class ResolverImpl implements Res
             List<Wire> packageWires = new ArrayList<Wire>();
             List<Wire> moduleWires = new ArrayList<Wire>();
 
-            for (Requirement req : module.getRequirements())
+            for (BundleRequirementImpl req : module.getRequirements())
             {
-                SortedSet<Capability> cands = allCandidates.getCandidates(req);
+                SortedSet<BundleCapabilityImpl> cands = allCandidates.getCandidates(req);
                 if ((cands != null) && (cands.size() > 0))
                 {
-                    Capability cand = cands.iterator().next();
+                    BundleCapabilityImpl cand = cands.iterator().next();
                     if (!cand.getModule().isResolved())
                     {
                         populateWireMap(cand.getModule(),
                             modulePkgMap, wireMap, allCandidates);
                     }
                     // Ignore modules that import themselves.
-                    if (req.getNamespace().equals(Capability.PACKAGE_NAMESPACE)
+                    if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE)
                         && !module.equals(cand.getModule()))
                     {
                         packageWires.add(
@@ -1332,7 +1335,7 @@ public class ResolverImpl implements Res
                                 getActualModule(cand.getModule()),
                                 getActualCapability(cand)));
                     }
-                    else if (req.getNamespace().equals(Capability.MODULE_NAMESPACE))
+                    else if (req.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
                     {
                         Packages candPkgs = modulePkgMap.get(cand.getModule());
                         moduleWires.add(
@@ -1390,8 +1393,7 @@ public class ResolverImpl implements Res
             {
                 // Ignore modules that import themselves.
                 if (!module.equals(blame.m_cap.getModule())
-                    && blame.m_cap.getAttribute(
-                        Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+                    && blame.m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName))
                 {
                     if (!blame.m_cap.getModule().isResolved())
                     {
@@ -1399,18 +1401,18 @@ public class ResolverImpl implements Res
                             allCandidates);
                     }
 
-                    List<Attribute> attrs = new ArrayList();
-                    attrs.add(new Attribute(Capability.PACKAGE_ATTR, pkgName, false));
+                    Map<String, Object> attrs = new HashMap(1);
+                    attrs.put(BundleCapabilityImpl.PACKAGE_ATTR, pkgName);
                     packageWires.add(
                         new WireImpl(
                             module,
                             // We need an unique requirement here or else subsequent
                             // dynamic imports for the same dynamic requirement will
                             // conflict with previous ones.
-                            new RequirementImpl(
+                            new BundleRequirementImpl(
                                 module,
-                                Capability.PACKAGE_NAMESPACE,
-                                new ArrayList(0),
+                                BundleCapabilityImpl.PACKAGE_NAMESPACE,
+                                Collections.EMPTY_MAP,
                                 attrs),
                             getActualModule(blame.m_cap.getModule()),
                             getActualCapability(blame.m_cap)));
@@ -1464,13 +1466,13 @@ public class ResolverImpl implements Res
         {
             for (int i = 0; i < blame.m_reqs.size(); i++)
             {
-                Requirement req = blame.m_reqs.get(i);
+                BundleRequirementImpl req = blame.m_reqs.get(i);
                 sb.append("  ");
                 sb.append(req.getModule().getSymbolicName());
                 sb.append(" [");
                 sb.append(req.getModule().toString());
                 sb.append("]\n");
-                if (req.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                 {
                     sb.append("    import: ");
                 }
@@ -1480,7 +1482,7 @@ public class ResolverImpl implements Res
                 }
                 sb.append(req.getFilter().toString());
                 sb.append("\n     |");
-                if (req.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                 {
                     sb.append("\n    export: ");
                 }
@@ -1490,13 +1492,15 @@ public class ResolverImpl implements Res
                 }
                 if ((i + 1) < blame.m_reqs.size())
                 {
-                    Capability cap = Util.getSatisfyingCapability(
+                    BundleCapabilityImpl cap = Util.getSatisfyingCapability(
                         blame.m_reqs.get(i + 1).getModule(),
                         blame.m_reqs.get(i));
-                    if (cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                    if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                     {
-                        sb.append(cap.getAttribute(Capability.PACKAGE_ATTR).toString());
-                        Capability usedCap;
+                        sb.append(BundleCapabilityImpl.PACKAGE_ATTR);
+                        sb.append("=");
+                        sb.append(cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).toString());
+                        BundleCapabilityImpl usedCap;
                         if ((i + 2) < blame.m_reqs.size())
                         {
                             usedCap = Util.getSatisfyingCapability(
@@ -1510,7 +1514,7 @@ public class ResolverImpl implements Res
                                 blame.m_reqs.get(i + 1));
                         }
                         sb.append("; uses:=");
-                        sb.append(usedCap.getAttribute(Capability.PACKAGE_ATTR).getValue());
+                        sb.append(usedCap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR));
                     }
                     else
                     {
@@ -1520,17 +1524,21 @@ public class ResolverImpl implements Res
                 }
                 else
                 {
-                    Capability export = Util.getSatisfyingCapability(
+                    BundleCapabilityImpl export = Util.getSatisfyingCapability(
                         blame.m_cap.getModule(),
                         blame.m_reqs.get(i));
-                    sb.append(export.getAttribute(Capability.PACKAGE_ATTR).toString());
-                    if (!export.getAttribute(Capability.PACKAGE_ATTR).getValue()
-                        .equals(blame.m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue()))
+                    sb.append(BundleCapabilityImpl.PACKAGE_ATTR);
+                    sb.append("=");
+                    sb.append(export.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).toString());
+                    if (!export.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR)
+                        .equals(blame.m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR)))
                     {
                         sb.append("; uses:=");
-                        sb.append(blame.m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue());
+                        sb.append(blame.m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR));
                         sb.append("\n    export: ");
-                        sb.append(blame.m_cap.getAttribute(Capability.PACKAGE_ATTR).toString());
+                        sb.append(BundleCapabilityImpl.PACKAGE_ATTR);
+                        sb.append("=");
+                        sb.append(blame.m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).toString());
                     }
                     sb.append("\n  ");
                     sb.append(blame.m_cap.getModule().getSymbolicName());
@@ -1568,12 +1576,12 @@ public class ResolverImpl implements Res
             // because bundles that import their own exports still continue
             // to provide access to their exports when they are required; i.e.,
             // the implicitly reexport the packages if wired to another provider.
-            for (Capability cap : m_module.getCapabilities())
+            for (BundleCapabilityImpl cap : m_module.getCapabilities())
             {
-                if (cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                 {
                     pkgs.add((String)
-                        cap.getAttribute(Capability.PACKAGE_ATTR).getValue());
+                        cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR));
                 }
             }
             // Grab all required and reexported required packages.
@@ -1581,13 +1589,13 @@ public class ResolverImpl implements Res
             {
                 for (Blame blame : entry.getValue())
                 {
-                    Directive dir = blame.m_reqs.get(
-                        blame.m_reqs.size() - 1).getDirective(Constants.VISIBILITY_DIRECTIVE);
-                    if ((dir != null)
-                        && dir.getValue().equals(Constants.VISIBILITY_REEXPORT))
+                    String value = blame.m_reqs.get(
+                        blame.m_reqs.size() - 1).getDirectives().get(Constants.VISIBILITY_DIRECTIVE);
+                    if ((value != null)
+                        && value.equals(Constants.VISIBILITY_REEXPORT))
                     {
                         pkgs.add((String)
-                            blame.m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue());
+                            blame.m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR));
                         break;
                     }
                 }
@@ -1598,24 +1606,26 @@ public class ResolverImpl implements Res
 
     private static class Blame
     {
-        public final Capability m_cap;
-        public final List<Requirement> m_reqs;
+        public final BundleCapabilityImpl m_cap;
+        public final List<BundleRequirementImpl> m_reqs;
 
-        public Blame(Capability cap, List<Requirement> reqs)
+        public Blame(BundleCapabilityImpl cap, List<BundleRequirementImpl> reqs)
         {
             m_cap = cap;
             m_reqs = reqs;
         }
 
+        @Override
         public String toString()
         {
             return m_cap.getModule()
-                + "." + m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue()
-                + (((m_reqs == null) || (m_reqs.size() == 0))
+                + "." + m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR)
+                + (((m_reqs == null) || m_reqs.isEmpty())
                     ? " NO BLAME"
                     : " BLAMED ON " + m_reqs);
         }
 
+        @Override
         public boolean equals(Object o)
         {
             return (o instanceof Blame) && m_reqs.equals(((Blame) o).m_reqs)

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Wire.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Wire.java?rev=1102776&r1=1102775&r2=1102776&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Wire.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Wire.java Fri May 13 14:57:58 2011
@@ -20,8 +20,8 @@ package org.apache.felix.framework.resol
 
 import java.net.URL;
 import java.util.Enumeration;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 
 public interface Wire
 {
@@ -35,7 +35,7 @@ public interface Wire
      * resulted in the creation of this wire.
      * @return
     **/
-    public Requirement getRequirement();
+    public BundleRequirementImpl getRequirement();
     /**
      * Returns the exporting module.
      * @return The exporting module.
@@ -46,7 +46,7 @@ public interface Wire
      * satisfies the requirement of the importing module.
      * @return
     **/
-    public Capability getCapability();
+    public BundleCapabilityImpl getCapability();
     /**
      * Returns whether or not the wire has a given package name. For some
      * wires, such as ones for Require-Bundle, there may be many packages.