felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1102805 [6/7] - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: ./ capabilityset/ resolver/ util/ util/manifestparser/ wiring/
Date Fri, 13 May 2011 16:27:27 GMT
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=1102805&r1=1102804&r2=1102805&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 16:27:26 2011
@@ -28,12 +28,17 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.SortedSet;
+import org.apache.felix.framework.BundleRevisionImpl;
 import org.apache.felix.framework.Logger;
 import org.apache.felix.framework.capabilityset.CapabilitySet;
 import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.apache.felix.framework.wiring.BundleRequirementImpl;
+import org.apache.felix.framework.wiring.FelixBundleWire;
 import org.osgi.framework.Constants;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
 
 public class ResolverImpl implements Resolver
 {
@@ -51,13 +56,13 @@ public class ResolverImpl implements Res
         m_logger = logger;
     }
 
-    public Map<Module, List<Wire>> resolve(
-        ResolverState state, Module module, Set<Module> fragments)
+    public Map<BundleRevision, List<ResolverWire>> resolve(
+        ResolverState state, BundleRevision revision, Set<BundleRevision> optional)
     {
-        Map<Module, List<Wire>> wireMap = new HashMap<Module, List<Wire>>();
-        Map<Module, Packages> modulePkgMap = new HashMap<Module, Packages>();
+        Map<BundleRevision, List<ResolverWire>> wireMap = new HashMap<BundleRevision, List<ResolverWire>>();
+        Map<BundleRevision, Packages> revisionPkgMap = new HashMap<BundleRevision, Packages>();
 
-        if (!module.isResolved())
+        if (!((BundleRevisionImpl) revision).isResolved())
         {
             boolean retryFragments;
             do
@@ -67,12 +72,12 @@ public class ResolverImpl implements Res
                 try
                 {
                     // Populate all candidates.
-                    Candidates allCandidates = new Candidates(state, module);
+                    Candidates allCandidates = new Candidates(state, revision);
 
                     // Try to populate optional fragments.
-                    for (Module fragment : fragments)
+                    for (BundleRevision br : optional)
                     {
-                        allCandidates.populateOptional(state, fragment);
+                        allCandidates.populateOptional(state, br);
                     }
 
                     // Merge any fragments into hosts.
@@ -83,16 +88,16 @@ public class ResolverImpl implements Res
 
                     ResolveException rethrow = null;
 
-                    // If the requested module is a fragment, then
+                    // If the requested revision is a fragment, then
                     // ultimately we will verify the host.
-                    BundleRequirementImpl hostReq = getHostRequirement(module);
-                    Module target = module;
+                    BundleRequirementImpl hostReq = getHostRequirement(revision);
+                    BundleRevision target = revision;
 
                     do
                     {
                         rethrow = null;
 
-                        modulePkgMap.clear();
+                        revisionPkgMap.clear();
                         m_packageSourcesCache.clear();
 
                         allCandidates = (m_usesPermutations.size() > 0)
@@ -105,21 +110,21 @@ public class ResolverImpl implements Res
                         if (hostReq != null)
                         {
                             target = allCandidates.getCandidates(hostReq)
-                                .iterator().next().getModule();
+                                .iterator().next().getRevision();
                         }
 
                         calculatePackageSpaces(
-                            allCandidates.getWrappedHost(target), allCandidates, modulePkgMap,
+                            allCandidates.getWrappedHost(target), allCandidates, revisionPkgMap,
                             new HashMap(), new HashSet());
 //System.out.println("+++ PACKAGE SPACES START +++");
-//dumpModulePkgMap(modulePkgMap);
+//dumpRevisionPkgMap(revisionPkgMap);
 //System.out.println("+++ PACKAGE SPACES END +++");
 
                         try
                         {
                             checkPackageSpaceConsistency(
                                 false, allCandidates.getWrappedHost(target),
-                                allCandidates, modulePkgMap, new HashMap());
+                                allCandidates, revisionPkgMap, new HashMap());
                         }
                         catch (ResolveException ex)
                         {
@@ -130,19 +135,20 @@ public class ResolverImpl implements Res
                         && ((m_usesPermutations.size() > 0) || (m_importPermutations.size() > 0)));
 
                     // If there is a resolve exception, then determine if an
-                    // optionally resolved module is to blame (typically a fragment).
-                    // If so, then remove the optionally resolved module and try
+                    // optionally resolved revision is to blame (typically a fragment).
+                    // If so, then remove the optionally resolved resolved and try
                     // again; otherwise, rethrow the resolve exception.
                     if (rethrow != null)
                     {
-                        Module faultyModule = getActualModule(rethrow.getModule());
+                        BundleRevision faultyRevision =
+                            getActualBundleRevision(rethrow.getRevision());
                         if (rethrow.getRequirement() instanceof HostedRequirement)
                         {
-                            faultyModule =
+                            faultyRevision =
                                 ((HostedRequirement) rethrow.getRequirement())
-                                    .getDeclaredRequirement().getModule();
+                                    .getDeclaredRequirement().getRevision();
                         }
-                        if (fragments.remove(faultyModule))
+                        if (optional.remove(faultyRevision))
                         {
                             retryFragments = true;
                         }
@@ -158,7 +164,7 @@ public class ResolverImpl implements Res
                         wireMap =
                             populateWireMap(
                                 allCandidates.getWrappedHost(target),
-                                modulePkgMap, wireMap, allCandidates);
+                                revisionPkgMap, wireMap, allCandidates);
                     }
                 }
                 finally
@@ -174,24 +180,25 @@ public class ResolverImpl implements Res
         return wireMap;
     }
 
-    public Map<Module, List<Wire>> resolve(
-        ResolverState state, Module module, String pkgName, Set<Module> fragments)
+    public Map<BundleRevision, List<ResolverWire>> resolve(
+        ResolverState state, BundleRevision revision, String pkgName,
+        Set<BundleRevision> optional)
     {
         // We can only create a dynamic import if the following
         // conditions are met:
-        // 1. The specified module is resolved.
+        // 1. The specified revision is resolved.
         // 2. The package in question is not already imported.
         // 3. The package in question is not accessible via require-bundle.
-        // 4. The package in question is not exported by the bundle.
-        // 5. The package in question matches a dynamic import of the bundle.
+        // 4. The package in question is not exported by the revision.
+        // 5. The package in question matches a dynamic import of the revision.
         // The following call checks all of these conditions and returns
         // the associated dynamic import and matching capabilities.
         Candidates allCandidates =
-            getDynamicImportCandidates(state, module, pkgName);
+            getDynamicImportCandidates(state, revision, pkgName);
         if (allCandidates != null)
         {
-            Map<Module, List<Wire>> wireMap = new HashMap<Module, List<Wire>>();
-            Map<Module, Packages> modulePkgMap = new HashMap<Module, Packages>();
+            Map<BundleRevision, List<ResolverWire>> wireMap = new HashMap<BundleRevision, List<ResolverWire>>();
+            Map<BundleRevision, Packages> revisionPkgMap = new HashMap<BundleRevision, Packages>();
 
             boolean retryFragments;
             do
@@ -201,16 +208,16 @@ public class ResolverImpl implements Res
                 try
                 {
                     // Try to populate optional fragments.
-                    for (Module fragment : fragments)
+                    for (BundleRevision br : optional)
                     {
-                        allCandidates.populateOptional(state, fragment);
+                        allCandidates.populateOptional(state, br);
                     }
 
                     // Merge any fragments into hosts.
                     allCandidates.prepare(getResolvedSingletons(state));
 
                     // Record the initial candidate permutation.
-                     m_usesPermutations.add(allCandidates);
+                    m_usesPermutations.add(allCandidates);
 
                     ResolveException rethrow = null;
 
@@ -218,7 +225,7 @@ public class ResolverImpl implements Res
                     {
                         rethrow = null;
 
-                        modulePkgMap.clear();
+                        revisionPkgMap.clear();
                         m_packageSourcesCache.clear();
 
                         allCandidates = (m_usesPermutations.size() > 0)
@@ -226,23 +233,23 @@ public class ResolverImpl implements Res
                             : m_importPermutations.remove(0);
 //allCandidates.dump();
 
-                        // For a dynamic import, the instigating module
+                        // For a dynamic import, the instigating revision
                         // will never be a fragment since fragments never
                         // execute code, so we don't need to check for
                         // this case like we do for a normal resolve.
 
                         calculatePackageSpaces(
-                            allCandidates.getWrappedHost(module), allCandidates, modulePkgMap,
+                            allCandidates.getWrappedHost(revision), allCandidates, revisionPkgMap,
                             new HashMap(), new HashSet());
 //System.out.println("+++ PACKAGE SPACES START +++");
-//dumpModulePkgMap(modulePkgMap);
+//dumpRevisionPkgMap(revisionPkgMap);
 //System.out.println("+++ PACKAGE SPACES END +++");
 
                         try
                         {
                             checkPackageSpaceConsistency(
-                                false, allCandidates.getWrappedHost(module),
-                                allCandidates, modulePkgMap, new HashMap());
+                                false, allCandidates.getWrappedHost(revision),
+                                allCandidates, revisionPkgMap, new HashMap());
                         }
                         catch (ResolveException ex)
                         {
@@ -253,19 +260,20 @@ public class ResolverImpl implements Res
                         && ((m_usesPermutations.size() > 0) || (m_importPermutations.size() > 0)));
 
                     // If there is a resolve exception, then determine if an
-                    // optionally resolved module is to blame (typically a fragment).
-                    // If so, then remove the optionally resolved module and try
+                    // optionally resolved revision is to blame (typically a fragment).
+                    // If so, then remove the optionally resolved revision and try
                     // again; otherwise, rethrow the resolve exception.
                     if (rethrow != null)
                     {
-                        Module faultyModule = getActualModule(rethrow.getModule());
+                        BundleRevision faultyRevision =
+                            getActualBundleRevision(rethrow.getRevision());
                         if (rethrow.getRequirement() instanceof HostedRequirement)
                         {
-                            faultyModule =
+                            faultyRevision =
                                 ((HostedRequirement) rethrow.getRequirement())
-                                    .getDeclaredRequirement().getModule();
+                                    .getDeclaredRequirement().getRevision();
                         }
-                        if (fragments.remove(faultyModule))
+                        if (optional.remove(faultyRevision))
                         {
                             retryFragments = true;
                         }
@@ -279,7 +287,7 @@ public class ResolverImpl implements Res
                     else
                     {
                         wireMap = populateDynamicWireMap(
-                            module, pkgName, modulePkgMap, wireMap, allCandidates);
+                            revision, pkgName, revisionPkgMap, wireMap, allCandidates);
                         return wireMap;
                     }
                 }
@@ -296,70 +304,71 @@ public class ResolverImpl implements Res
         return null;
     }
 
-    private static List<Module> getResolvedSingletons(ResolverState state)
+    private static List<BundleRevision> getResolvedSingletons(ResolverState state)
     {
         BundleRequirementImpl req = new BundleRequirementImpl(
             null,
             BundleCapabilityImpl.SINGLETON_NAMESPACE,
             Collections.EMPTY_MAP,
             Collections.EMPTY_MAP);
-        SortedSet<BundleCapabilityImpl> caps = state.getCandidates(req, true);
-        List<Module> singletons = new ArrayList();
-        for (BundleCapabilityImpl cap : caps)
+        SortedSet<BundleCapability> caps = state.getCandidates(req, true);
+        List<BundleRevision> singletons = new ArrayList();
+        for (BundleCapability cap : caps)
         {
-            if (cap.getModule().isResolved())
+            if (cap.getRevision().getWiring() != null)
             {
-                singletons.add(cap.getModule());
+                singletons.add(cap.getRevision());
             }
         }
         return singletons;
     }
 
-    private static BundleCapabilityImpl getHostCapability(Module m)
+    private static BundleCapabilityImpl getHostCapability(BundleRevision br)
     {
-        for (BundleCapabilityImpl c : m.getDeclaredCapabilities())
+        for (BundleCapability c : br.getDeclaredCapabilities(null))
         {
             if (c.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
             {
-                return c;
+                return (BundleCapabilityImpl) c;
             }
         }
         return null;
     }
 
-    private static BundleRequirementImpl getHostRequirement(Module m)
+    private static BundleRequirementImpl getHostRequirement(BundleRevision br)
     {
-        for (BundleRequirementImpl r : m.getDeclaredRequirements())
+        for (BundleRequirement r : br.getDeclaredRequirements(null))
         {
             if (r.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
             {
-                return r;
+                return (BundleRequirementImpl) r;
             }
         }
         return null;
     }
 
     private static Candidates getDynamicImportCandidates(
-        ResolverState state, Module module, String pkgName)
+        ResolverState state, BundleRevision revision, String pkgName)
     {
-        // Unresolved modules cannot dynamically import, nor can the default
+        // Unresolved revisions cannot dynamically import, nor can the default
         // package be dynamically imported.
-        if (!module.isResolved() || pkgName.length() == 0)
+        if ((revision.getWiring() == null) || pkgName.length() == 0)
         {
             return null;
         }
 
-        // If the module doesn't have dynamic imports, then just return
+        // If the revision doesn't have dynamic imports, then just return
         // immediately.
-        List<BundleRequirementImpl> dynamics = module.getResolvedDynamicRequirements();
+        List<BundleRequirement> dynamics =
+            ((BundleRevisionImpl) revision).getResolvedDynamicRequirements();
         if ((dynamics == null) || dynamics.isEmpty())
         {
             return null;
         }
 
-        // If any of the module exports this package, then we cannot
+        // If the revision exports this package, then we cannot
         // attempt to dynamically import it.
-        for (BundleCapabilityImpl cap : module.getResolvedCapabilities())
+        for (BundleCapability cap : revision.getWiring().getCapabilities(null))
         {
             if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE)
                 && cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName))
@@ -369,7 +378,7 @@ public class ResolverImpl implements Res
         }
         // If any of our wires have this package, then we cannot
         // attempt to dynamically import it.
-        for (Wire w : module.getWires())
+        for (FelixBundleWire w : ((BundleRevisionImpl) revision).getWires())
         {
             if (w.hasPackage(pkgName))
             {
@@ -383,11 +392,11 @@ public class ResolverImpl implements Res
         Map<String, Object> attrs = new HashMap(1);
         attrs.put(BundleCapabilityImpl.PACKAGE_ATTR, pkgName);
         BundleRequirementImpl req = new BundleRequirementImpl(
-            module,
+            revision,
             BundleCapabilityImpl.PACKAGE_NAMESPACE,
             Collections.EMPTY_MAP,
             attrs);
-        SortedSet<BundleCapabilityImpl> candidates = state.getCandidates(req, false);
+        SortedSet<BundleCapability> candidates = state.getCandidates(req, false);
 
         // First find a dynamic requirement that matches the capabilities.
         BundleRequirementImpl dynReq = null;
@@ -395,13 +404,15 @@ public class ResolverImpl implements Res
             (candidates.size() > 0) && (dynReq == null) && (dynIdx < dynamics.size());
             dynIdx++)
         {
-            for (Iterator<BundleCapabilityImpl> itCand = candidates.iterator();
+            for (Iterator<BundleCapability> itCand = candidates.iterator();
                 (dynReq == null) && itCand.hasNext(); )
             {
-                BundleCapabilityImpl cap = itCand.next();
-                if (CapabilitySet.matches(cap, dynamics.get(dynIdx).getFilter()))
+                BundleCapability cap = itCand.next();
+                if (CapabilitySet.matches(
+                    (BundleCapabilityImpl) cap,
+                    ((BundleRequirementImpl) dynamics.get(dynIdx)).getFilter()))
                 {
-                    dynReq = dynamics.get(dynIdx);
+                    dynReq = (BundleRequirementImpl) dynamics.get(dynIdx);
                 }
             }
         }
@@ -410,10 +421,12 @@ public class ResolverImpl implements Res
         // any candidates that do not match it.
         if (dynReq != null)
         {
-            for (Iterator<BundleCapabilityImpl> itCand = candidates.iterator(); itCand.hasNext(); )
+            for (Iterator<BundleCapability> itCand = candidates.iterator();
+                itCand.hasNext(); )
             {
-                BundleCapabilityImpl cap = itCand.next();
-                if (!CapabilitySet.matches(cap, dynReq.getFilter()))
+                BundleCapability cap = itCand.next();
+                if (!CapabilitySet.matches(
+                    (BundleCapabilityImpl) cap, dynReq.getFilter()))
                 {
                     itCand.remove();
                 }
@@ -428,72 +441,78 @@ public class ResolverImpl implements Res
 
         if (candidates.size() > 0)
         {
-            allCandidates = new Candidates(state, module, dynReq, candidates);
+            allCandidates = new Candidates(state, revision, dynReq, candidates);
         }
 
         return allCandidates;
     }
 
     private void calculatePackageSpaces(
-        Module module,
+        BundleRevision revision,
         Candidates allCandidates,
-        Map<Module, Packages> modulePkgMap,
-        Map<BundleCapabilityImpl, List<Module>> usesCycleMap,
-        Set<Module> cycle)
+        Map<BundleRevision, Packages> revisionPkgMap,
+        Map<BundleCapability, List<BundleRevision>> usesCycleMap,
+        Set<BundleRevision> cycle)
     {
-        if (cycle.contains(module))
+        if (cycle.contains(revision))
         {
             return;
         }
-        cycle.add(module);
+        cycle.add(revision);
 
         // Create parallel arrays for requirement and proposed candidate
-        // capability or actual capability if module is resolved or not.
+        // capability or actual capability if revision is resolved or not.
         List<BundleRequirementImpl> reqs = new ArrayList();
         List<BundleCapabilityImpl> caps = new ArrayList();
-        boolean isDynamicImport = false;
-        if (module.isResolved())
+        boolean isDynamicImporting = false;
+        if (revision.getWiring() != null)
         {
             // Use wires to get actual requirements and satisfying capabilities.
-            for (Wire wire : module.getWires())
+            for (FelixBundleWire wire : ((BundleRevisionImpl) revision).getWires())
             {
                 // Wrap the requirement as a hosted requirement
                 // if it comes from a fragment, since we will need
                 // to know the host.
-                BundleRequirementImpl r = wire.getRequirement();
-                if (!r.getModule().equals(wire.getImporter()))
+                BundleRequirement r = wire.getRequirement();
+                if (!r.getRevision().equals(wire.getRequirerWiring().getRevision()))
                 {
-                    r = new HostedRequirement(wire.getImporter(), r);
+                    r = new HostedRequirement(
+                        wire.getRequirerWiring().getRevision(),
+                        (BundleRequirementImpl) r);
                 }
                 // Wrap the capability as a hosted capability
                 // if it comes from a fragment, since we will need
                 // to know the host.
-                BundleCapabilityImpl c = wire.getCapability();
-                if (!c.getModule().equals(wire.getExporter()))
+                BundleCapability c = wire.getCapability();
+                if (!c.getRevision().equals(wire.getProviderWiring().getRevision()))
                 {
-                    c = new HostedCapability(wire.getExporter(), c);
+                    c = new HostedCapability(
+                        wire.getProviderWiring().getRevision(),
+                        (BundleCapabilityImpl) c);
                 }
-                reqs.add(r);
-                caps.add(c);
+                reqs.add((BundleRequirementImpl) r);
+                caps.add((BundleCapabilityImpl) c);
             }
 
-            // Since the module is resolved, it could be dynamically importing,
+            // Since the revision is resolved, it could be dynamically importing,
             // so check to see if there are candidates for any of its dynamic
             // imports.
-            for (BundleRequirementImpl req : module.getResolvedDynamicRequirements())
+            for (BundleRequirement req
+                : ((BundleRevisionImpl) revision).getResolvedDynamicRequirements())
             {
                 // Get the candidates for the current requirement.
-                SortedSet<BundleCapabilityImpl> candCaps = allCandidates.getCandidates(req);
+                SortedSet<BundleCapability> candCaps =
+                    allCandidates.getCandidates((BundleRequirementImpl) req);
                 // Optional requirements may not have any candidates.
                 if (candCaps == null)
                 {
                     continue;
                 }
 
-                BundleCapabilityImpl cap = candCaps.iterator().next();
-                reqs.add(req);
-                caps.add(cap);
-                isDynamicImport = true;
+                BundleCapability cap = candCaps.iterator().next();
+                reqs.add((BundleRequirementImpl) req);
+                caps.add((BundleCapabilityImpl) cap);
+                isDynamicImporting = true;
                 // Can only dynamically import one at a time, so break
                 // out of the loop after the first.
                 break;
@@ -501,76 +520,77 @@ public class ResolverImpl implements Res
         }
         else
         {
-            for (BundleRequirementImpl req : module.getDeclaredRequirements())
+            for (BundleRequirement req : revision.getDeclaredRequirements(null))
             {
                 // Get the candidates for the current requirement.
-                SortedSet<BundleCapabilityImpl> candCaps = allCandidates.getCandidates(req);
+                SortedSet<BundleCapability> candCaps =
+                    allCandidates.getCandidates((BundleRequirementImpl) req);
                 // Optional requirements may not have any candidates.
                 if (candCaps == null)
                 {
                     continue;
                 }
 
-                BundleCapabilityImpl cap = candCaps.iterator().next();
-                reqs.add(req);
-                caps.add(cap);
+                BundleCapability cap = candCaps.iterator().next();
+                reqs.add((BundleRequirementImpl) req);
+                caps.add((BundleCapabilityImpl) cap);
             }
         }
 
-        // First, add all exported packages to the target module's package space.
-        calculateExportedPackages(module, allCandidates, modulePkgMap);
-        Packages modulePkgs = modulePkgMap.get(module);
+        // First, add all exported packages to the target revision's package space.
+        calculateExportedPackages(revision, allCandidates, revisionPkgMap);
+        Packages revisionPkgs = revisionPkgMap.get(revision);
 
-        // Second, add all imported packages to the target module's package space.
+        // Second, add all imported packages to the target revision's package space.
         for (int i = 0; i < reqs.size(); i++)
         {
             BundleRequirementImpl req = reqs.get(i);
             BundleCapabilityImpl cap = caps.get(i);
-            calculateExportedPackages(cap.getModule(), allCandidates, modulePkgMap);
-            mergeCandidatePackages(module, req, cap, modulePkgMap, allCandidates);
+            calculateExportedPackages(cap.getRevision(), allCandidates, revisionPkgMap);
+            mergeCandidatePackages(revision, req, cap, revisionPkgMap, allCandidates);
         }
 
         // Third, have all candidates to calculate their package spaces.
         for (int i = 0; i < caps.size(); i++)
         {
             calculatePackageSpaces(
-                caps.get(i).getModule(), allCandidates, modulePkgMap,
+                caps.get(i).getRevision(), allCandidates, revisionPkgMap,
                 usesCycleMap, cycle);
         }
 
-        // Fourth, if the target module is unresolved or is dynamically importing,
+        // Fourth, if the target revision is unresolved or is dynamically importing,
         // then add all the uses constraints implied by its imported and required
         // packages to its package space.
-        // NOTE: We do not need to do this for resolved modules because their
+        // NOTE: We do not need to do this for resolved revisions because their
         // package space is consistent by definition and these uses constraints
-        // are only needed to verify the consistency of a resolving module. The
-        // only exception is if a resolve module is dynamically importing, then
+        // are only needed to verify the consistency of a resolving revision. The
+        // only exception is if a resolved revision is dynamically importing, then
         // we need to calculate its uses constraints again to make sure the new
         // import is consistent with the existing package space.
-        if (!module.isResolved() || isDynamicImport)
+        if ((revision.getWiring() == null) || isDynamicImporting)
         {
-            for (Entry<String, List<Blame>> entry : modulePkgs.m_importedPkgs.entrySet())
+            for (Entry<String, List<Blame>> entry : revisionPkgs.m_importedPkgs.entrySet())
             {
                 for (Blame blame : entry.getValue())
                 {
-                    // Ignore modules that import from themselves.
-                    if (!blame.m_cap.getModule().equals(module))
+                    // Ignore revisions that import from themselves.
+                    if (!blame.m_cap.getRevision().equals(revision))
                     {
                         List<BundleRequirementImpl> blameReqs = new ArrayList();
                         blameReqs.add(blame.m_reqs.get(0));
 
                         mergeUses(
-                            module,
-                            modulePkgs,
+                            revision,
+                            revisionPkgs,
                             blame.m_cap,
                             blameReqs,
-                            modulePkgMap,
+                            revisionPkgMap,
                             allCandidates,
                             usesCycleMap);
                     }
                 }
             }
-            for (Entry<String, List<Blame>> entry : modulePkgs.m_requiredPkgs.entrySet())
+            for (Entry<String, List<Blame>> entry : revisionPkgs.m_requiredPkgs.entrySet())
             {
                 for (Blame blame : entry.getValue())
                 {
@@ -578,11 +598,11 @@ public class ResolverImpl implements Res
                     blameReqs.add(blame.m_reqs.get(0));
 
                     mergeUses(
-                        module,
-                        modulePkgs,
+                        revision,
+                        revisionPkgs,
                         blame.m_cap,
                         blameReqs,
-                        modulePkgMap,
+                        revisionPkgMap,
                         allCandidates,
                         usesCycleMap);
                 }
@@ -591,27 +611,27 @@ public class ResolverImpl implements Res
     }
 
     private void mergeCandidatePackages(
-        Module current, BundleRequirementImpl currentReq, BundleCapabilityImpl candCap,
-        Map<Module, Packages> modulePkgMap,
+        BundleRevision current, BundleRequirementImpl currentReq, BundleCapability candCap,
+        Map<BundleRevision, Packages> revisionPkgMap,
         Candidates allCandidates)
     {
         if (candCap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
             mergeCandidatePackage(
-                current, false, currentReq, candCap, modulePkgMap);
+                current, false, currentReq, candCap, revisionPkgMap);
         }
-        else if (candCap.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
+        else if (candCap.getNamespace().equals(BundleCapabilityImpl.BUNDLE_NAMESPACE))
         {
 // TODO: FELIX3 - THIS NEXT LINE IS A HACK. IMPROVE HOW/WHEN WE CALCULATE EXPORTS.
             calculateExportedPackages(
-                candCap.getModule(), allCandidates, modulePkgMap);
+                candCap.getRevision(), allCandidates, revisionPkgMap);
 
             // Get the candidate's package space to determine which packages
-            // will be visible to the current module.
-            Packages candPkgs = modulePkgMap.get(candCap.getModule());
+            // will be visible to the current revision.
+            Packages candPkgs = revisionPkgMap.get(candCap.getRevision());
 
             // We have to merge all exported packages from the candidate,
-            // since the current module requires it.
+            // since the current revision requires it.
             for (Entry<String, Blame> entry : candPkgs.m_exportedPkgs.entrySet())
             {
                 mergeCandidatePackage(
@@ -619,17 +639,17 @@ public class ResolverImpl implements Res
                     true,
                     currentReq,
                     entry.getValue().m_cap,
-                    modulePkgMap);
+                    revisionPkgMap);
             }
 
             // If the candidate requires any other bundles with reexport visibility,
             // then we also need to merge their packages too.
-            List<BundleRequirementImpl> reqs = (candCap.getModule().isResolved())
-                ? candCap.getModule().getResolvedRequirements()
-                : candCap.getModule().getDeclaredRequirements();
-            for (BundleRequirementImpl req : reqs)
+            List<BundleRequirement> reqs = (candCap.getRevision().getWiring() != null)
+                ? candCap.getRevision().getWiring().getRequirements(null)
+                : candCap.getRevision().getDeclaredRequirements(null);
+            for (BundleRequirement req : reqs)
             {
-                if (req.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
+                if (req.getNamespace().equals(BundleCapabilityImpl.BUNDLE_NAMESPACE))
                 {
                     String value = req.getDirectives().get(Constants.VISIBILITY_DIRECTIVE);
                     if ((value != null) && value.equals(Constants.VISIBILITY_REEXPORT)
@@ -639,7 +659,7 @@ public class ResolverImpl implements Res
                             current,
                             currentReq,
                             allCandidates.getCandidates(req).iterator().next(),
-                            modulePkgMap,
+                            revisionPkgMap,
                             allCandidates);
                     }
                 }
@@ -648,9 +668,9 @@ public class ResolverImpl implements Res
     }
 
     private void mergeCandidatePackage(
-        Module current, boolean requires,
-        BundleRequirementImpl currentReq, BundleCapabilityImpl candCap,
-        Map<Module, Packages> modulePkgMap)
+        BundleRevision current, boolean requires,
+        BundleRequirementImpl currentReq, BundleCapability candCap,
+        Map<BundleRevision, Packages> revisionPkgMap)
     {
         if (candCap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
@@ -658,7 +678,7 @@ public class ResolverImpl implements Res
                 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
+            // a hard constraint on the revisions's package space, so we need
             // to make sure it doesn't conflict with any other hard constraints
             // or any other uses constraints.
 
@@ -670,7 +690,7 @@ public class ResolverImpl implements Res
             // any existing hard constraints.
             //
 
-            Packages currentPkgs = modulePkgMap.get(current);
+            Packages currentPkgs = revisionPkgMap.get(current);
 
             if (requires)
             {
@@ -693,44 +713,44 @@ public class ResolverImpl implements Res
                 currentImportedBlames.add(new Blame(candCap, blameReqs));
             }
 
-//dumpModulePkgs(current, currentPkgs);
+//dumpRevisionPkgs(current, currentPkgs);
         }
     }
 
     private void mergeUses(
-        Module current, Packages currentPkgs,
-        BundleCapabilityImpl mergeCap, List<BundleRequirementImpl> blameReqs,
-        Map<Module, Packages> modulePkgMap,
+        BundleRevision current, Packages currentPkgs,
+        BundleCapability mergeCap, List<BundleRequirementImpl> blameReqs,
+        Map<BundleRevision, Packages> revisionPkgMap,
         Candidates allCandidates,
-        Map<BundleCapabilityImpl, List<Module>> cycleMap)
+        Map<BundleCapability, List<BundleRevision>> cycleMap)
     {
         if (!mergeCap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
             return;
         }
-        // If the candidate module is the same as the current module,
+        // If the candidate revision is the same as the current revision,
         // then we don't need to verify and merge the uses constraints
         // since this will happen as we build up the package space.
-        else if (current == mergeCap.getModule())
+        else if (current.equals(mergeCap.getRevision()))
         {
             return;
         }
 
         // Check for cycles.
-        List<Module> list = cycleMap.get(mergeCap);
+        List<BundleRevision> list = cycleMap.get(mergeCap);
         if ((list != null) && list.contains(current))
         {
             return;
         }
-        list = (list == null) ? new ArrayList<Module>() : list;
+        list = (list == null) ? new ArrayList<BundleRevision>() : list;
         list.add(current);
         cycleMap.put(mergeCap, list);
 
-        for (BundleCapabilityImpl candSourceCap : getPackageSources(mergeCap, modulePkgMap))
+        for (BundleCapability candSourceCap : getPackageSources(mergeCap, revisionPkgMap))
         {
-            for (String usedPkgName : candSourceCap.getUses())
+            for (String usedPkgName : ((BundleCapabilityImpl) candSourceCap).getUses())
             {
-                Packages candSourcePkgs = modulePkgMap.get(candSourceCap.getModule());
+                Packages candSourcePkgs = revisionPkgMap.get(candSourceCap.getRevision());
                 Blame candExportedBlame = candSourcePkgs.m_exportedPkgs.get(usedPkgName);
                 List<Blame> candSourceBlames = null;
                 if (candExportedBlame != null)
@@ -762,13 +782,13 @@ public class ResolverImpl implements Res
                         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,
-                            modulePkgMap, allCandidates, cycleMap);
+                            revisionPkgMap, allCandidates, cycleMap);
                     }
                     else
                     {
                         usedCaps.add(new Blame(blame.m_cap, blameReqs));
                         mergeUses(current, currentPkgs, blame.m_cap, blameReqs,
-                            modulePkgMap, allCandidates, cycleMap);
+                            revisionPkgMap, allCandidates, cycleMap);
                     }
                 }
             }
@@ -776,22 +796,22 @@ public class ResolverImpl implements Res
     }
 
     private void checkPackageSpaceConsistency(
-        boolean isDynamicImport,
-        Module module,
+        boolean isDynamicImporting,
+        BundleRevision revision,
         Candidates allCandidates,
-        Map<Module, Packages> modulePkgMap,
-        Map<Module, Object> resultCache)
+        Map<BundleRevision, Packages> revisionPkgMap,
+        Map<BundleRevision, Object> resultCache)
     {
-        if (module.isResolved() && !isDynamicImport)
+        if ((revision.getWiring() != null) && !isDynamicImporting)
         {
             return;
         }
-        else if(resultCache.containsKey(module))
+        else if(resultCache.containsKey(revision))
         {
             return;
         }
 
-        Packages pkgs = modulePkgMap.get(module);
+        Packages pkgs = revisionPkgMap.get(revision);
 
         ResolveException rethrow = null;
         Candidates permutation = null;
@@ -809,7 +829,7 @@ public class ResolverImpl implements Res
                     {
                         sourceBlame = blame;
                     }
-                    else if (!sourceBlame.m_cap.getModule().equals(blame.m_cap.getModule()))
+                    else if (!sourceBlame.m_cap.getRevision().equals(blame.m_cap.getRevision()))
                     {
                         // Try to permutate the conflicting requirement.
                         permutate(allCandidates, blame.m_reqs.get(0), m_importPermutations);
@@ -817,22 +837,22 @@ public class ResolverImpl implements Res
                         permutate(allCandidates, sourceBlame.m_reqs.get(0), m_importPermutations);
                         // Report conflict.
                         ResolveException ex = new ResolveException(
-                            "Uses constraint violation. Unable to resolve module "
-                            + module.getSymbolicName()
-                            + " [" + module
+                            "Uses constraint violation. Unable to resolve bundle revision "
+                            + revision.getSymbolicName()
+                            + " [" + revision
                             + "] because it is exposed to package '"
                             + entry.getKey()
-                            + "' from modules "
-                            + sourceBlame.m_cap.getModule().getSymbolicName()
-                            + " [" + sourceBlame.m_cap.getModule()
+                            + "' from bundle revisions "
+                            + sourceBlame.m_cap.getRevision().getSymbolicName()
+                            + " [" + sourceBlame.m_cap.getRevision()
                             + "] and "
-                            + blame.m_cap.getModule().getSymbolicName()
-                            + " [" + blame.m_cap.getModule()
+                            + blame.m_cap.getRevision().getSymbolicName()
+                            + " [" + blame.m_cap.getRevision()
                             + "] via two dependency chains.\n\nChain 1:\n"
                             + toStringBlame(sourceBlame)
                             + "\n\nChain 2:\n"
                             + toStringBlame(blame),
-                            module,
+                            revision,
                             blame.m_reqs.get(0));
                         m_logger.log(
                             Logger.LOG_DEBUG,
@@ -855,7 +875,7 @@ public class ResolverImpl implements Res
             }
             for (Blame usedBlame : pkgs.m_usedPkgs.get(pkgName))
             {
-                if (!isCompatible(exportBlame.m_cap, usedBlame.m_cap, modulePkgMap))
+                if (!isCompatible(exportBlame.m_cap, usedBlame.m_cap, revisionPkgMap))
                 {
                     // Create a candidate permutation that eliminates all candidates
                     // that conflict with existing selected candidates.
@@ -865,14 +885,14 @@ public class ResolverImpl implements Res
                     rethrow = (rethrow != null)
                         ? rethrow
                         : new ResolveException(
-                            "Uses constraint violation. Unable to resolve module "
-                            + module.getSymbolicName()
-                            + " [" + module
+                            "Uses constraint violation. Unable to resolve bundle revision "
+                            + revision.getSymbolicName()
+                            + " [" + revision
                             + "] because it exports package '"
                             + pkgName
-                            + "' and is also exposed to it from module "
-                            + usedBlame.m_cap.getModule().getSymbolicName()
-                            + " [" + usedBlame.m_cap.getModule()
+                            + "' and is also exposed to it from bundle revision "
+                            + usedBlame.m_cap.getRevision().getSymbolicName()
+                            + " [" + usedBlame.m_cap.getRevision()
                             + "] via the following dependency chain:\n\n"
                             + toStringBlame(usedBlame),
                             null,
@@ -895,9 +915,9 @@ public class ResolverImpl implements Res
                         }
 
                         // See if we can permutate the candidates for blamed
-                        // requirement; there may be no candidates if the module
+                        // requirement; there may be no candidates if the revision
                         // associated with the requirement is already resolved.
-                        SortedSet<BundleCapabilityImpl> candidates =
+                        SortedSet<BundleCapability> candidates =
                             permutation.getCandidates(req);
                         if ((candidates != null) && (candidates.size() > 1))
                         {
@@ -939,7 +959,7 @@ public class ResolverImpl implements Res
                 }
                 for (Blame usedBlame : pkgs.m_usedPkgs.get(pkgName))
                 {
-                    if (!isCompatible(importBlame.m_cap, usedBlame.m_cap, modulePkgMap))
+                    if (!isCompatible(importBlame.m_cap, usedBlame.m_cap, revisionPkgMap))
                     {
                         // Create a candidate permutation that eliminates any candidates
                         // that conflict with existing selected candidates.
@@ -949,17 +969,17 @@ public class ResolverImpl implements Res
                         rethrow = (rethrow != null)
                             ? rethrow
                             : new ResolveException(
-                                "Uses constraint violation. Unable to resolve module "
-                                + module.getSymbolicName()
-                                + " [" + module
+                                "Uses constraint violation. Unable to resolve bundle revision "
+                                + revision.getSymbolicName()
+                                + " [" + revision
                                 + "] because it is exposed to package '"
                                 + pkgName
-                                + "' from modules "
-                                + importBlame.m_cap.getModule().getSymbolicName()
-                                + " [" + importBlame.m_cap.getModule()
+                                + "' from bundle revisions "
+                                + importBlame.m_cap.getRevision().getSymbolicName()
+                                + " [" + importBlame.m_cap.getRevision()
                                 + "] and "
-                                + usedBlame.m_cap.getModule().getSymbolicName()
-                                + " [" + usedBlame.m_cap.getModule()
+                                + usedBlame.m_cap.getRevision().getSymbolicName()
+                                + " [" + usedBlame.m_cap.getRevision()
                                 + "] via two dependency chains.\n\nChain 1:\n"
                                 + toStringBlame(importBlame)
                                 + "\n\nChain 2:\n"
@@ -984,9 +1004,9 @@ public class ResolverImpl implements Res
                             }
 
                             // See if we can permutate the candidates for blamed
-                            // requirement; there may be no candidates if the module
+                            // requirement; there may be no candidates if the revision
                             // associated with the requirement is already resolved.
-                            SortedSet<BundleCapabilityImpl> candidates =
+                            SortedSet<BundleCapability> candidates =
                                 permutation.getCandidates(req);
                             if ((candidates != null) && (candidates.size() > 1))
                             {
@@ -1038,10 +1058,10 @@ public class ResolverImpl implements Res
             }
         }
 
-        resultCache.put(module, Boolean.TRUE);
+        resultCache.put(revision, Boolean.TRUE);
 
-        // Now check the consistency of all modules on which the
-        // current module depends. Keep track of the current number
+        // Now check the consistency of all revisions on which the
+        // current revision depends. Keep track of the current number
         // of permutations so we know if the lower level check was
         // able to create a permutation or not in the case of failure.
         int permCount = m_usesPermutations.size() + m_importPermutations.size();
@@ -1049,19 +1069,19 @@ public class ResolverImpl implements Res
         {
             for (Blame importBlame : entry.getValue())
             {
-                if (!module.equals(importBlame.m_cap.getModule()))
+                if (!revision.equals(importBlame.m_cap.getRevision()))
                 {
                     try
                     {
                         checkPackageSpaceConsistency(
-                            false, importBlame.m_cap.getModule(),
-                            allCandidates, modulePkgMap, resultCache);
+                            false, importBlame.m_cap.getRevision(),
+                            allCandidates, revisionPkgMap, resultCache);
                     }
                     catch (ResolveException ex)
                     {
                         // If the lower level check didn't create any permutations,
                         // then we should create an import permutation for the
-                        // requirement with the dependency on the failing module
+                        // requirement with the dependency on the failing revision
                         // to backtrack on our current candidate selection.
                         if (permCount == (m_usesPermutations.size() + m_importPermutations.size()))
                         {
@@ -1078,7 +1098,7 @@ public class ResolverImpl implements Res
     private static void permutate(
         Candidates allCandidates, BundleRequirementImpl req, List<Candidates> permutations)
     {
-        SortedSet<BundleCapabilityImpl> candidates = allCandidates.getCandidates(req);
+        SortedSet<BundleCapability> candidates = allCandidates.getCandidates(req);
         if (candidates.size() > 1)
         {
             Candidates perm = allCandidates.copy();
@@ -1093,7 +1113,7 @@ public class ResolverImpl implements Res
     private static void permutateIfNeeded(
         Candidates allCandidates, BundleRequirementImpl req, List<Candidates> permutations)
     {
-        SortedSet<BundleCapabilityImpl> candidates = allCandidates.getCandidates(req);
+        SortedSet<BundleCapability> candidates = allCandidates.getCandidates(req);
         if (candidates.size() > 1)
         {
             // Check existing permutations to make sure we haven't
@@ -1105,7 +1125,7 @@ public class ResolverImpl implements Res
             boolean permutated = false;
             for (Candidates existingPerm : permutations)
             {
-                Set<BundleCapabilityImpl> existingPermCands = existingPerm.getCandidates(req);
+                Set<BundleCapability> existingPermCands = existingPerm.getCandidates(req);
                 if (!existingPermCands.iterator().next().equals(candidates.iterator().next()))
                 {
                     permutated = true;
@@ -1121,24 +1141,24 @@ public class ResolverImpl implements Res
     }
 
     private static void calculateExportedPackages(
-        Module module,
+        BundleRevision revision,
         Candidates allCandidates,
-        Map<Module, Packages> modulePkgMap)
+        Map<BundleRevision, Packages> revisionPkgMap)
     {
-        Packages packages = modulePkgMap.get(module);
+        Packages packages = revisionPkgMap.get(revision);
         if (packages != null)
         {
             return;
         }
-        packages = new Packages(module);
+        packages = new Packages(revision);
 
         // Get all exported packages.
-        List<BundleCapabilityImpl> caps = (module.isResolved())
-            ? module.getResolvedCapabilities()
-            : module.getDeclaredCapabilities();
-        Map<String, BundleCapabilityImpl> exports =
-            new HashMap<String, BundleCapabilityImpl>(caps.size());
-        for (BundleCapabilityImpl cap : caps)
+        List<BundleCapability> caps = (revision.getWiring() != null)
+            ? revision.getWiring().getCapabilities(null)
+            : revision.getDeclaredCapabilities(null);
+        Map<String, BundleCapability> exports =
+            new HashMap<String, BundleCapability>(caps.size());
+        for (BundleCapability cap : caps)
         {
             if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
             {
@@ -1148,12 +1168,12 @@ public class ResolverImpl implements Res
             }
         }
         // Remove substitutable exports that were imported.
-        // For resolved modules look at the wires, for resolving
-        // modules look in the candidate map to determine which
+        // For resolved revisions look at the wires, for resolving
+        // revisions look in the candidate map to determine which
         // exports are substitutable.
-        if (module.isResolved())
+        if (revision.getWiring() != null)
         {
-            for (Wire wire : module.getWires())
+            for (FelixBundleWire wire : ((BundleRevisionImpl) revision).getWires())
             {
                 if (wire.getRequirement().getNamespace().equals(
                     BundleCapabilityImpl.PACKAGE_NAMESPACE))
@@ -1166,11 +1186,12 @@ public class ResolverImpl implements Res
         }
         else
         {
-            for (BundleRequirementImpl req : module.getDeclaredRequirements())
+            for (BundleRequirement req : revision.getDeclaredRequirements(null))
             {
                 if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                 {
-                    Set<BundleCapabilityImpl> cands = allCandidates.getCandidates(req);
+                    Set<BundleCapability> cands =
+                        allCandidates.getCandidates((BundleRequirementImpl) req);
                     if ((cands != null) && !cands.isEmpty())
                     {
                         String pkgName = (String) cands.iterator().next()
@@ -1180,19 +1201,19 @@ public class ResolverImpl implements Res
                 }
             }
         }
-        // Add all non-substituted exports to the module's package space.
-        for (Entry<String, BundleCapabilityImpl> entry : exports.entrySet())
+        // Add all non-substituted exports to the revisions's package space.
+        for (Entry<String, BundleCapability> entry : exports.entrySet())
         {
             packages.m_exportedPkgs.put(
-                entry.getKey(), new Blame(entry.getValue(), null));
+                entry.getKey(), new Blame((BundleCapabilityImpl) entry.getValue(), null));
         }
 
-        modulePkgMap.put(module, packages);
+        revisionPkgMap.put(revision, packages);
     }
 
     private boolean isCompatible(
-        BundleCapabilityImpl currentCap, BundleCapabilityImpl candCap,
-        Map<Module, Packages> modulePkgMap)
+        BundleCapability currentCap, BundleCapability candCap,
+        Map<BundleRevision, Packages> revisionPkgMap)
     {
         if ((currentCap != null) && (candCap != null))
         {
@@ -1201,14 +1222,14 @@ public class ResolverImpl implements Res
                 return true;
             }
 
-            List<BundleCapabilityImpl> currentSources =
+            List<BundleCapability> currentSources =
                 getPackageSources(
                     currentCap,
-                    modulePkgMap);
-            List<BundleCapabilityImpl> candSources =
+                    revisionPkgMap);
+            List<BundleCapability> candSources =
                 getPackageSources(
                     candCap,
-                    modulePkgMap);
+                    revisionPkgMap);
 
             return currentSources.containsAll(candSources)
                 || candSources.containsAll(currentSources);
@@ -1216,19 +1237,19 @@ public class ResolverImpl implements Res
         return true;
     }
 
-    private Map<BundleCapabilityImpl, List<BundleCapabilityImpl>> m_packageSourcesCache
+    private Map<BundleCapability, List<BundleCapability>> m_packageSourcesCache
         = new HashMap();
 
-    private List<BundleCapabilityImpl> getPackageSources(
-        BundleCapabilityImpl cap, Map<Module, Packages> modulePkgMap)
+    private List<BundleCapability> getPackageSources(
+        BundleCapability cap, Map<BundleRevision, Packages> revisionPkgMap)
     {
         if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
-            List<BundleCapabilityImpl> sources = m_packageSourcesCache.get(cap);
+            List<BundleCapability> sources = m_packageSourcesCache.get(cap);
             if (sources == null)
             {
                 sources = getPackageSourcesInternal(
-                    cap, modulePkgMap, new ArrayList(), new HashSet());
+                    cap, revisionPkgMap, new ArrayList(), new HashSet());
                 m_packageSourcesCache.put(cap, sources);
             }
             return sources;
@@ -1237,9 +1258,9 @@ public class ResolverImpl implements Res
         return Collections.EMPTY_LIST;
     }
 
-    private static List<BundleCapabilityImpl> getPackageSourcesInternal(
-        BundleCapabilityImpl cap, Map<Module, Packages> modulePkgMap,
-        List<BundleCapabilityImpl> sources, Set<BundleCapabilityImpl> cycleMap)
+    private static List<BundleCapability> getPackageSourcesInternal(
+        BundleCapability cap, Map<BundleRevision, Packages> revisionPkgMap,
+        List<BundleCapability> sources, Set<BundleCapability> cycleMap)
     {
         if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
         {
@@ -1253,11 +1274,11 @@ public class ResolverImpl implements Res
             String pkgName = cap.getAttributes()
                 .get(BundleCapabilityImpl.PACKAGE_ATTR).toString();
 
-            // Since a module can export the same package more than once, get
+            // Since a revision can export the same package more than once, get
             // all package capabilities for the specified package name.
-            List<BundleCapabilityImpl> caps = (cap.getModule().isResolved())
-                ? cap.getModule().getResolvedCapabilities()
-                : cap.getModule().getDeclaredCapabilities();
+            List<BundleCapability> caps = (cap.getRevision().getWiring() != null)
+                ? cap.getRevision().getWiring().getCapabilities(null)
+                : cap.getRevision().getDeclaredCapabilities(null);
             for (int capIdx = 0; capIdx < caps.size(); capIdx++)
             {
                 if (caps.get(capIdx).getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE)
@@ -1268,13 +1289,13 @@ public class ResolverImpl implements Res
             }
 
             // Then get any addition sources for the package from required bundles.
-            Packages pkgs = modulePkgMap.get(cap.getModule());
+            Packages pkgs = revisionPkgMap.get(cap.getRevision());
             List<Blame> required = pkgs.m_requiredPkgs.get(pkgName);
             if (required != null)
             {
                 for (Blame blame : required)
                 {
-                    getPackageSourcesInternal(blame.m_cap, modulePkgMap, sources, cycleMap);
+                    getPackageSourcesInternal(blame.m_cap, revisionPkgMap, sources, cycleMap);
                 }
             }
         }
@@ -1282,16 +1303,16 @@ public class ResolverImpl implements Res
         return sources;
     }
 
-    private static Module getActualModule(Module m)
+    private static BundleRevision getActualBundleRevision(BundleRevision br)
     {
-        if (m instanceof HostModule)
+        if (br instanceof HostBundleRevision)
         {
-            return ((HostModule) m).getHost();
+            return ((HostBundleRevision) br).getHost();
         }
-        return m;
+        return br;
     }
 
-    private static BundleCapabilityImpl getActualCapability(BundleCapabilityImpl c)
+    private static BundleCapability getActualCapability(BundleCapability c)
     {
         if (c instanceof HostedCapability)
         {
@@ -1300,7 +1321,7 @@ public class ResolverImpl implements Res
         return c;
     }
 
-    private static BundleRequirementImpl getActualRequirement(BundleRequirementImpl r)
+    private static BundleRequirement getActualRequirement(BundleRequirement r)
     {
         if (r instanceof HostedRequirement)
         {
@@ -1309,77 +1330,73 @@ public class ResolverImpl implements Res
         return r;
     }
 
-    private static Map<Module, List<Wire>> populateWireMap(
-        Module module, Map<Module, Packages> modulePkgMap,
-        Map<Module, List<Wire>> wireMap,
+    private static Map<BundleRevision, List<ResolverWire>> populateWireMap(
+        BundleRevision revision, Map<BundleRevision, Packages> revisionPkgMap,
+        Map<BundleRevision, List<ResolverWire>> wireMap,
         Candidates allCandidates)
     {
-        Module unwrappedModule = getActualModule(module);
-        if (!unwrappedModule.isResolved() && !wireMap.containsKey(unwrappedModule))
+        BundleRevision unwrappedRevision = getActualBundleRevision(revision);
+        if ((unwrappedRevision.getWiring() == null)
+            && !wireMap.containsKey(unwrappedRevision))
         {
-            wireMap.put(unwrappedModule, (List<Wire>) Collections.EMPTY_LIST);
+            wireMap.put(unwrappedRevision, (List<ResolverWire>) Collections.EMPTY_LIST);
 
-            List<Wire> packageWires = new ArrayList<Wire>();
-            List<Wire> moduleWires = new ArrayList<Wire>();
+            List<ResolverWire> packageWires = new ArrayList<ResolverWire>();
+            List<ResolverWire> requireWires = new ArrayList<ResolverWire>();
 
-            for (BundleRequirementImpl req : module.getDeclaredRequirements())
+            for (BundleRequirement req : revision.getDeclaredRequirements(null))
             {
-                SortedSet<BundleCapabilityImpl> cands = allCandidates.getCandidates(req);
+                SortedSet<BundleCapability> cands = allCandidates.getCandidates(req);
                 if ((cands != null) && (cands.size() > 0))
                 {
-                    BundleCapabilityImpl cand = cands.iterator().next();
-                    if (!cand.getModule().isResolved())
-                    {
-                        populateWireMap(cand.getModule(),
-                            modulePkgMap, wireMap, allCandidates);
-                    }
-                    // Ignore modules that import themselves.
-                    if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE)
-                        && !module.equals(cand.getModule()))
+                    BundleCapability cand = cands.iterator().next();
+                    if (cand.getRevision().getWiring() == null)
                     {
-                        packageWires.add(
-                            new WireImpl(
-                                unwrappedModule,
-                                getActualRequirement(req),
-                                getActualModule(cand.getModule()),
-                                getActualCapability(cand)));
+                        populateWireMap(cand.getRevision(),
+                            revisionPkgMap, wireMap, allCandidates);
                     }
-                    else if (req.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
+                    // Ignore revisions that import themselves.
+                    if (!revision.equals(cand.getRevision()))
                     {
-                        Packages candPkgs = modulePkgMap.get(cand.getModule());
-                        moduleWires.add(
-                            new WireModuleImpl(
-                                unwrappedModule,
-                                getActualRequirement(req),
-                                getActualModule(cand.getModule()),
-                                getActualCapability(cand),
-                                candPkgs.getExportedAndReexportedPackages()));
+                        ResolverWire wire = new ResolverWireImpl(
+                            unwrappedRevision,
+                            (BundleRequirementImpl) getActualRequirement(req),
+                            getActualBundleRevision(cand.getRevision()),
+                            (BundleCapabilityImpl) getActualCapability(cand));
+                        if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
+                        {
+                            packageWires.add(wire);
+                        }
+                        else if (req.getNamespace().equals(BundleCapabilityImpl.BUNDLE_NAMESPACE))
+                        {
+                            requireWires.add(wire);
+                        }
                     }
                 }
             }
 
-            // Combine wires with module wires last.
-            packageWires.addAll(moduleWires);
-            wireMap.put(unwrappedModule, packageWires);
+            // Combine package wires with require wires last.
+            packageWires.addAll(requireWires);
+            wireMap.put(unwrappedRevision, packageWires);
 
             // Add host wire for any fragments.
-            if (module instanceof HostModule)
+            if (revision instanceof HostBundleRevision)
             {
-                List<Module> fragments = ((HostModule) module).getFragments();
-                for (Module fragment : fragments)
+                List<BundleRevision> fragments = ((HostBundleRevision) revision).getFragments();
+                for (BundleRevision fragment : fragments)
                 {
-                    List<Wire> hostWires = wireMap.get(fragment);
+                    List<ResolverWire> hostWires = wireMap.get(fragment);
                     if (hostWires == null)
                     {
-                        hostWires = new ArrayList<Wire>();
+                        hostWires = new ArrayList<ResolverWire>();
                         wireMap.put(fragment, hostWires);
                     }
                     hostWires.add(
-                        new WireImpl(
-                            getActualModule(fragment),
+                        new ResolverWireImpl(
+                            getActualBundleRevision(fragment),
                             getHostRequirement(fragment),
-                            unwrappedModule,
-                            getHostCapability(unwrappedModule)));
+                            unwrappedRevision,
+                            getHostCapability(unwrappedRevision)));
                 }
             }
         }
@@ -1387,65 +1404,67 @@ public class ResolverImpl implements Res
         return wireMap;
     }
 
-    private static Map<Module, List<Wire>> populateDynamicWireMap(
-        Module module, String pkgName, Map<Module, Packages> modulePkgMap,
-        Map<Module, List<Wire>> wireMap, Candidates allCandidates)
+    private static Map<BundleRevision, List<ResolverWire>> populateDynamicWireMap(
+        BundleRevision revision, String pkgName, Map<BundleRevision, Packages> revisionPkgMap,
+        Map<BundleRevision, List<ResolverWire>> wireMap, Candidates allCandidates)
     {
-        wireMap.put(module, (List<Wire>) Collections.EMPTY_LIST);
+        wireMap.put(revision, (List<ResolverWire>) Collections.EMPTY_LIST);
 
-        List<Wire> packageWires = new ArrayList<Wire>();
+        List<ResolverWire> packageWires = new ArrayList<ResolverWire>();
 
-        Packages pkgs = modulePkgMap.get(module);
+        Packages pkgs = revisionPkgMap.get(revision);
         for (Entry<String, List<Blame>> entry : pkgs.m_importedPkgs.entrySet())
         {
             for (Blame blame : entry.getValue())
             {
-                // Ignore modules that import themselves.
-                if (!module.equals(blame.m_cap.getModule())
-                    && blame.m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName))
+                // Ignore revisions that import themselves.
+                if (!revision.equals(blame.m_cap.getRevision())
+                    && blame.m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR)
+                        .equals(pkgName))
                 {
-                    if (!blame.m_cap.getModule().isResolved())
+                    if (blame.m_cap.getRevision().getWiring() == null)
                     {
-                        populateWireMap(blame.m_cap.getModule(), modulePkgMap, wireMap,
+                        populateWireMap(blame.m_cap.getRevision(), revisionPkgMap, wireMap,
                             allCandidates);
                     }
 
                     Map<String, Object> attrs = new HashMap(1);
                     attrs.put(BundleCapabilityImpl.PACKAGE_ATTR, pkgName);
                     packageWires.add(
-                        new WireImpl(
-                            module,
+                        new ResolverWireImpl(
+                            revision,
                             // We need an unique requirement here or else subsequent
                             // dynamic imports for the same dynamic requirement will
                             // conflict with previous ones.
                             new BundleRequirementImpl(
-                                module,
+                                revision,
                                 BundleCapabilityImpl.PACKAGE_NAMESPACE,
                                 Collections.EMPTY_MAP,
                                 attrs),
-                            getActualModule(blame.m_cap.getModule()),
-                            getActualCapability(blame.m_cap)));
+                            getActualBundleRevision(blame.m_cap.getRevision()),
+                            (BundleCapabilityImpl) getActualCapability(blame.m_cap)));
                 }
             }
         }
 
-        wireMap.put(module, packageWires);
+        wireMap.put(revision, packageWires);
 
         return wireMap;
     }
 
-    private static void dumpModulePkgMap(Map<Module, Packages> modulePkgMap)
+    private static void dumpRevisionPkgMap(Map<BundleRevision, Packages> revisionPkgMap)
     {
-        System.out.println("+++MODULE PKG MAP+++");
-        for (Entry<Module, Packages> entry : modulePkgMap.entrySet())
+        System.out.println("+++BUNDLE REVISION PKG MAP+++");
+        for (Entry<BundleRevision, Packages> entry : revisionPkgMap.entrySet())
         {
-            dumpModulePkgs(entry.getKey(), entry.getValue());
+            dumpRevisionPkgs(entry.getKey(), entry.getValue());
         }
     }
 
-    private static void dumpModulePkgs(Module module, Packages packages)
+    private static void dumpRevisionPkgs(BundleRevision revision, Packages packages)
     {
-        System.out.println(module + " (" + (module.isResolved() ? "RESOLVED)" : "UNRESOLVED)"));
+        System.out.println(revision
+            + " (" + ((revision.getWiring() != null) ? "RESOLVED)" : "UNRESOLVED)"));
         System.out.println("  EXPORTED");
         for (Entry<String, Blame> entry : packages.m_exportedPkgs.entrySet())
         {
@@ -1477,9 +1496,9 @@ public class ResolverImpl implements Res
             {
                 BundleRequirementImpl req = blame.m_reqs.get(i);
                 sb.append("  ");
-                sb.append(req.getModule().getSymbolicName());
+                sb.append(req.getRevision().getSymbolicName());
                 sb.append(" [");
-                sb.append(req.getModule().toString());
+                sb.append(req.getRevision().toString());
                 sb.append("]\n");
                 if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                 {
@@ -1501,25 +1520,25 @@ public class ResolverImpl implements Res
                 }
                 if ((i + 1) < blame.m_reqs.size())
                 {
-                    BundleCapabilityImpl cap = Util.getSatisfyingCapability(
-                        blame.m_reqs.get(i + 1).getModule(),
+                    BundleCapability cap = Util.getSatisfyingCapability(
+                        blame.m_reqs.get(i + 1).getRevision(),
                         blame.m_reqs.get(i));
                     if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                     {
                         sb.append(BundleCapabilityImpl.PACKAGE_ATTR);
                         sb.append("=");
                         sb.append(cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).toString());
-                        BundleCapabilityImpl usedCap;
+                        BundleCapability usedCap;
                         if ((i + 2) < blame.m_reqs.size())
                         {
                             usedCap = Util.getSatisfyingCapability(
-                                blame.m_reqs.get(i + 2).getModule(),
+                                blame.m_reqs.get(i + 2).getRevision(),
                                 blame.m_reqs.get(i + 1));
                         }
                         else
                         {
                             usedCap = Util.getSatisfyingCapability(
-                                blame.m_cap.getModule(),
+                                blame.m_cap.getRevision(),
                                 blame.m_reqs.get(i + 1));
                         }
                         sb.append("; uses:=");
@@ -1533,8 +1552,8 @@ public class ResolverImpl implements Res
                 }
                 else
                 {
-                    BundleCapabilityImpl export = Util.getSatisfyingCapability(
-                        blame.m_cap.getModule(),
+                    BundleCapability export = Util.getSatisfyingCapability(
+                        blame.m_cap.getRevision(),
                         blame.m_reqs.get(i));
                     sb.append(BundleCapabilityImpl.PACKAGE_ATTR);
                     sb.append("=");
@@ -1550,45 +1569,45 @@ public class ResolverImpl implements Res
                         sb.append(blame.m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).toString());
                     }
                     sb.append("\n  ");
-                    sb.append(blame.m_cap.getModule().getSymbolicName());
+                    sb.append(blame.m_cap.getRevision().getSymbolicName());
                     sb.append(" [");
-                    sb.append(blame.m_cap.getModule().toString());
+                    sb.append(blame.m_cap.getRevision().toString());
                     sb.append("]");
                 }
             }
         }
         else
         {
-            sb.append(blame.m_cap.getModule().toString());
+            sb.append(blame.m_cap.getRevision().toString());
         }
         return sb.toString();
     }
 
     private static class Packages
     {
-        private final Module m_module;
+        private final BundleRevision m_revision;
         public final Map<String, Blame> m_exportedPkgs = new HashMap();
         public final Map<String, List<Blame>> m_importedPkgs = new HashMap();
         public final Map<String, List<Blame>> m_requiredPkgs = new HashMap();
         public final Map<String, List<Blame>> m_usedPkgs = new HashMap();
 
-        public Packages(Module module)
+        public Packages(BundleRevision revision)
         {
-            m_module = module;
+            m_revision = revision;
         }
 
         public List<String> getExportedAndReexportedPackages()
         {
             List<String> pkgs = new ArrayList();
-            // Grab the module's actual exported packages.
+            // Grab the revision's actual exported packages.
             // Note that we ignore the calculated exported packages here,
             // 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.
-            List<BundleCapabilityImpl> caps = (m_module.isResolved())
-                ? m_module.getResolvedCapabilities()
-                : m_module.getDeclaredCapabilities();
-            for (BundleCapabilityImpl cap : caps)
+            List<BundleCapability> caps = (m_revision.getWiring() != null)
+                ? m_revision.getWiring().getCapabilities(null)
+                : m_revision.getDeclaredCapabilities(null);
+            for (BundleCapability cap : caps)
             {
                 if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
                 {
@@ -1618,10 +1637,10 @@ public class ResolverImpl implements Res
 
     private static class Blame
     {
-        public final BundleCapabilityImpl m_cap;
+        public final BundleCapability m_cap;
         public final List<BundleRequirementImpl> m_reqs;
 
-        public Blame(BundleCapabilityImpl cap, List<BundleRequirementImpl> reqs)
+        public Blame(BundleCapability cap, List<BundleRequirementImpl> reqs)
         {
             m_cap = cap;
             m_reqs = reqs;
@@ -1630,7 +1649,7 @@ public class ResolverImpl implements Res
         @Override
         public String toString()
         {
-            return m_cap.getModule()
+            return m_cap.getRevision()
                 + "." + m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR)
                 + (((m_reqs == null) || m_reqs.isEmpty())
                     ? " NO BLAME"

Added: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWire.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWire.java?rev=1102805&view=auto
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWire.java (added)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWire.java Fri May 13 16:27:26 2011
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.framework.resolver;
+
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+
+public interface ResolverWire
+{
+    /**
+     * Returns the importing bundle revision.
+     * @return The importing bundle revision.
+    **/
+    public BundleRevision getRequirer();
+    /**
+     * Returns the associated requirement from the importing bundle revision
+     * that resulted in the creation of this wire.
+     * @return
+    **/
+    public BundleRequirement getRequirement();
+    /**
+     * Returns the exporting bundle revision.
+     * @return The exporting bundle revision.
+    **/
+    public BundleRevision getProvider();
+    /**
+     * Returns the associated capability from the exporting bundle revision
+     * that satisfies the requirement of the importing bundle revision.
+     * @return
+    **/
+    public BundleCapability getCapability();
+}
\ No newline at end of file

Added: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java?rev=1102805&view=auto
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java (added)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java Fri May 13 16:27:26 2011
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.framework.resolver;
+
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+
+class ResolverWireImpl implements ResolverWire
+{
+    private final BundleRevision m_requirer;
+    private final BundleRequirement m_req;
+    private final BundleRevision m_provider;
+    private final BundleCapability m_cap;
+
+    public ResolverWireImpl(BundleRevision requirer, BundleRequirement req,
+        BundleRevision provider, BundleCapability cap)
+    {
+        m_requirer = requirer;
+        m_req = req;
+        m_provider = provider;
+        m_cap = cap;
+    }
+
+    public BundleRevision getRequirer()
+    {
+        return m_requirer;
+    }
+
+    public BundleRequirement getRequirement()
+    {
+        return m_req;
+    }
+
+    public BundleRevision getProvider()
+    {
+        return m_provider;
+    }
+
+    public BundleCapability getCapability()
+    {
+        return m_cap;
+    }
+
+    public String toString()
+    {
+        return "[" + m_requirer + "] "
+            + m_req
+            + " -> "
+            + "[" + m_provider + "]";
+    }
+}
\ No newline at end of file

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java?rev=1102805&r1=1102804&r2=1102805&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java Fri May 13 16:27:26 2011
@@ -26,16 +26,17 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import org.apache.felix.framework.BundleRevisionImpl;
 import org.apache.felix.framework.Logger;
 import org.apache.felix.framework.capabilityset.CapabilitySet;
-import org.apache.felix.framework.resolver.Module;
-import org.apache.felix.framework.resolver.Wire;
 import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.apache.felix.framework.wiring.BundleRequirementImpl;
+import org.apache.felix.framework.wiring.FelixBundleWire;
 
 import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRevision;
 
 public class Util
 {
@@ -85,11 +86,11 @@ public class Util
     }
 
     /**
-     * Converts a module identifier to a bundle identifier. Module IDs
+     * Converts a revision identifier to a bundle identifier. Revision IDs
      * are typically <tt>&lt;bundle-id&gt;.&lt;revision&gt;</tt>; this
      * method returns only the portion corresponding to the bundle ID.
     **/
-    public static long getBundleIdFromModuleId(String id)
+    public static long getBundleIdFromRevisionId(String id)
     {
         try
         {
@@ -279,17 +280,18 @@ public class Util
         return allow;
     }
 
-    public static BundleCapabilityImpl getSatisfyingCapability(Module m, BundleRequirementImpl req)
+    public static BundleCapability getSatisfyingCapability(
+        BundleRevision br, BundleRequirementImpl req)
     {
-        List<BundleCapabilityImpl> caps = (m.isResolved())
-            ? m.getResolvedCapabilities()
-            : m.getDeclaredCapabilities();
+        List<BundleCapability> caps = (br.getWiring() != null)
+            ? br.getWiring().getCapabilities(null)
+            : br.getDeclaredCapabilities(null);
         if (caps != null)
         {
-            for (BundleCapabilityImpl cap : caps)
+            for (BundleCapability cap : caps)
             {
                 if (cap.getNamespace().equals(req.getNamespace())
-                    && CapabilitySet.matches(cap, req.getFilter()))
+                    && CapabilitySet.matches((BundleCapabilityImpl) cap, req.getFilter()))
                 {
                     return cap;
                 }
@@ -301,19 +303,20 @@ public class Util
     /**
      * Returns all the capabilities from a module that has a specified namespace.
      *
-     * @param m    module providing capabilities
+     * @param br    module providing capabilities
      * @param namespace capability namespace
      * @return array of matching capabilities or empty if none found
      */
-    public static List<BundleCapabilityImpl> getCapabilityByNamespace(Module m, String namespace)
+    public static List<BundleCapability> getCapabilityByNamespace(
+        BundleRevision br, String namespace)
     {
-        final List<BundleCapabilityImpl> matching = new ArrayList();
-        final List<BundleCapabilityImpl> caps = (m.isResolved())
-            ? m.getResolvedCapabilities()
-            : m.getDeclaredCapabilities();
+        final List<BundleCapability> matching = new ArrayList();
+        final List<BundleCapability> caps = (br.getWiring() != null)
+            ? br.getWiring().getCapabilities(null)
+            : br.getDeclaredCapabilities(null);
         if (caps != null)
         {
-            for (BundleCapabilityImpl cap : caps)
+            for (BundleCapability cap : caps)
             {
                 if (cap.getNamespace().equals(namespace))
                 {
@@ -324,12 +327,12 @@ public class Util
         return matching;
     }
 
-    public static Wire getWire(Module m, String name)
+    public static FelixBundleWire getWire(BundleRevision br, String name)
     {
-        List<Wire> wires = m.getWires();
+        List<FelixBundleWire> wires = ((BundleRevisionImpl) br).getWires();
         if (wires != null)
         {
-            for (Wire w : wires)
+            for (FelixBundleWire w : wires)
             {
                 if (w.getCapability().getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE) &&
                     w.getCapability().getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(name))
@@ -587,9 +590,8 @@ public class Util
      * @return <code>true</code> if the module declares a fragment host, <code>false</code>
      *      otherwise.
      */
-    public static boolean isFragment(Module module)
+    public static boolean isFragment(BundleRevision revision)
     {
-        Map headerMap = module.getHeaders();
-        return headerMap.containsKey(Constants.FRAGMENT_HOST);
+        return ((revision.getTypes() & BundleRevision.TYPE_FRAGMENT) > 0);
     }
 }
\ No newline at end of file



Mime
View raw message