felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1099489 [3/5] - in /felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework: ./ capabilityset/ resolver/ util/ util/manifestparser/ wiring/
Date Wed, 04 May 2011 15:36:51 GMT
Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java (original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java Wed May  4 15:36:50 2011
@@ -33,32 +33,33 @@ import java.util.TreeMap;
 import org.apache.felix.framework.util.SecureAction;
 import org.apache.felix.framework.util.StringComparator;
 import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.osgi.framework.wiring.BundleCapability;
 
 public class CapabilitySet
 {
-    private final Map<String, Map<Object, Set<BundleCapabilityImpl>>> m_indices;
-    private final Set<BundleCapabilityImpl> m_capSet = new HashSet<BundleCapabilityImpl>();
+    private final Map<String, Map<Object, Set<BundleCapability>>> m_indices;
+    private final Set<BundleCapability> m_capSet = new HashSet<BundleCapability>();
     private final static SecureAction m_secureAction = new SecureAction();
 
     public CapabilitySet(List<String> indexProps, boolean caseSensitive)
     {
         m_indices = (caseSensitive)
-            ? new TreeMap<String, Map<Object, Set<BundleCapabilityImpl>>>()
-            : new TreeMap<String, Map<Object, Set<BundleCapabilityImpl>>>(
+            ? new TreeMap<String, Map<Object, Set<BundleCapability>>>()
+            : new TreeMap<String, Map<Object, Set<BundleCapability>>>(
                 new StringComparator(false));
         for (int i = 0; (indexProps != null) && (i < indexProps.size()); i++)
         {
             m_indices.put(
-                indexProps.get(i), new HashMap<Object, Set<BundleCapabilityImpl>>());
+                indexProps.get(i), new HashMap<Object, Set<BundleCapability>>());
         }
     }
 
-    public void addCapability(BundleCapabilityImpl cap)
+    public void addCapability(BundleCapability cap)
     {
         m_capSet.add(cap);
 
         // Index capability.
-        for (Entry<String, Map<Object, Set<BundleCapabilityImpl>>> entry : m_indices.entrySet())
+        for (Entry<String, Map<Object, Set<BundleCapability>>> entry : m_indices.entrySet())
         {
             Object value = cap.getAttributes().get(entry.getKey());
             if (value != null)
@@ -68,7 +69,7 @@ public class CapabilitySet
                     value = convertArrayToList(value);
                 }
 
-                Map<Object, Set<BundleCapabilityImpl>> index = entry.getValue();
+                Map<Object, Set<BundleCapability>> index = entry.getValue();
 
                 if (value instanceof Collection)
                 {
@@ -87,22 +88,22 @@ public class CapabilitySet
     }
 
     private void indexCapability(
-        Map<Object, Set<BundleCapabilityImpl>> index, BundleCapabilityImpl cap, Object capValue)
+        Map<Object, Set<BundleCapability>> index, BundleCapability cap, Object capValue)
     {
-        Set<BundleCapabilityImpl> caps = index.get(capValue);
+        Set<BundleCapability> caps = index.get(capValue);
         if (caps == null)
         {
-            caps = new HashSet<BundleCapabilityImpl>();
+            caps = new HashSet<BundleCapability>();
             index.put(capValue, caps);
         }
         caps.add(cap);
     }
 
-    public void removeCapability(BundleCapabilityImpl cap)
+    public void removeCapability(BundleCapability cap)
     {
         if (m_capSet.remove(cap))
         {
-            for (Entry<String, Map<Object, Set<BundleCapabilityImpl>>> entry : m_indices.entrySet())
+            for (Entry<String, Map<Object, Set<BundleCapability>>> entry : m_indices.entrySet())
             {
                 Object value = cap.getAttributes().get(entry.getKey());
                 if (value != null)
@@ -112,7 +113,7 @@ public class CapabilitySet
                         value = convertArrayToList(value);
                     }
 
-                    Map<Object, Set<BundleCapabilityImpl>> index = entry.getValue();
+                    Map<Object, Set<BundleCapability>> index = entry.getValue();
 
                     if (value instanceof Collection)
                     {
@@ -132,9 +133,9 @@ public class CapabilitySet
     }
 
     private void deindexCapability(
-        Map<Object, Set<BundleCapabilityImpl>> index, BundleCapabilityImpl cap, Object value)
+        Map<Object, Set<BundleCapability>> index, BundleCapability cap, Object value)
     {
-        Set<BundleCapabilityImpl> caps = index.get(value);
+        Set<BundleCapability> caps = index.get(value);
         if (caps != null)
         {
             caps.remove(cap);
@@ -145,17 +146,17 @@ public class CapabilitySet
         }
     }
 
-    public Set<BundleCapabilityImpl> match(SimpleFilter sf, boolean obeyMandatory)
+    public Set<BundleCapability> match(SimpleFilter sf, boolean obeyMandatory)
     {
-        Set<BundleCapabilityImpl> matches = match(m_capSet, sf);
+        Set<BundleCapability> matches = match(m_capSet, sf);
         return (obeyMandatory)
             ? matchMandatory(matches, sf)
             : matches;
     }
 
-    private Set<BundleCapabilityImpl> match(Set<BundleCapabilityImpl> caps, SimpleFilter sf)
+    private Set<BundleCapability> match(Set<BundleCapability> caps, SimpleFilter sf)
     {
-        Set<BundleCapabilityImpl> matches = new HashSet<BundleCapabilityImpl>();
+        Set<BundleCapability> matches = new HashSet<BundleCapability>();
 
         if (sf.getOperation() == SimpleFilter.MATCH_ALL)
         {
@@ -197,10 +198,10 @@ public class CapabilitySet
         }
         else
         {
-            Map<Object, Set<BundleCapabilityImpl>> index = m_indices.get(sf.getName());
+            Map<Object, Set<BundleCapability>> index = m_indices.get(sf.getName());
             if ((sf.getOperation() == SimpleFilter.EQ) && (index != null))
             {
-                Set<BundleCapabilityImpl> existingCaps = index.get(sf.getValue());
+                Set<BundleCapability> existingCaps = index.get(sf.getValue());
                 if (existingCaps != null)
                 {
                     matches.addAll(existingCaps);
@@ -209,9 +210,9 @@ public class CapabilitySet
             }
             else
             {
-                for (Iterator<BundleCapabilityImpl> it = caps.iterator(); it.hasNext(); )
+                for (Iterator<BundleCapability> it = caps.iterator(); it.hasNext(); )
                 {
-                    BundleCapabilityImpl cap = it.next();
+                    BundleCapability cap = it.next();
                     Object lhs = cap.getAttributes().get(sf.getName());
                     if (lhs != null)
                     {
@@ -227,12 +228,12 @@ public class CapabilitySet
         return matches;
     }
 
-    public static boolean matches(BundleCapabilityImpl cap, SimpleFilter sf)
+    public static boolean matches(BundleCapability cap, SimpleFilter sf)
     {
         return matchesInternal(cap, sf) && matchMandatory(cap, sf);
     }
 
-    private static boolean matchesInternal(BundleCapabilityImpl cap, SimpleFilter sf)
+    private static boolean matchesInternal(BundleCapability cap, SimpleFilter sf)
     {
         boolean matched = true;
 
@@ -282,12 +283,12 @@ public class CapabilitySet
         return matched;
     }
 
-    private static Set<BundleCapabilityImpl> matchMandatory(
-        Set<BundleCapabilityImpl> caps, SimpleFilter sf)
+    private static Set<BundleCapability> matchMandatory(
+        Set<BundleCapability> caps, SimpleFilter sf)
     {
-        for (Iterator<BundleCapabilityImpl> it = caps.iterator(); it.hasNext(); )
+        for (Iterator<BundleCapability> it = caps.iterator(); it.hasNext(); )
         {
-            BundleCapabilityImpl cap = it.next();
+            BundleCapability cap = it.next();
             if (!matchMandatory(cap, sf))
             {
                 it.remove();
@@ -296,12 +297,12 @@ public class CapabilitySet
         return caps;
     }
 
-    private static boolean matchMandatory(BundleCapabilityImpl cap, SimpleFilter sf)
+    private static boolean matchMandatory(BundleCapability cap, SimpleFilter sf)
     {
         Map<String, Object> attrs = cap.getAttributes();
         for (Entry<String, Object> entry : attrs.entrySet())
         {
-            if (cap.isAttributeMandatory(entry.getKey())
+            if (((BundleCapabilityImpl) cap).isAttributeMandatory(entry.getKey())
                 && !matchMandatoryAttrbute(entry.getKey(), sf))
             {
                 return false;

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java (original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java Wed May  4 15:36:50 2011
@@ -22,26 +22,29 @@ import java.util.Comparator;
 import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
+import org.osgi.framework.wiring.BundleCapability;
 
-public class CandidateComparator implements Comparator<BundleCapabilityImpl>
+public class CandidateComparator implements Comparator<BundleCapability>
 {
-    public int compare(BundleCapabilityImpl cap1, BundleCapabilityImpl cap2)
+    public int compare(BundleCapability cap1, BundleCapability cap2)
     {
         // First check resolved state, since resolved capabilities have priority
         // over unresolved ones. Compare in reverse order since we want to sort
         // in descending order.
         int c = 0;
-        if (cap1.getModule().isResolved() && !cap2.getModule().isResolved())
+        if ((cap1.getRevision().getWiring() != null)
+            && (cap2.getRevision().getWiring() == null))
         {
             c = -1;
         }
-        else if (!cap1.getModule().isResolved() && cap2.getModule().isResolved())
+        else if ((cap1.getRevision().getWiring() == null)
+            && (cap2.getRevision().getWiring() != null))
         {
             c = 1;
         }
 
-        // Compare module capabilities.
-        if ((c == 0) && cap1.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
+        // Compare revision capabilities.
+        if ((c == 0) && cap1.getNamespace().equals(BundleCapabilityImpl.BUNDLE_NAMESPACE))
         {
             c = ((Comparable) cap1.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
                 .compareTo(cap2.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE));
@@ -77,16 +80,16 @@ public class CandidateComparator impleme
             }
         }
 
-        // Finally, compare module identity.
+        // Finally, compare bundle identity.
         if (c == 0)
         {
-            if (cap1.getModule().getBundle().getBundleId() <
-                cap2.getModule().getBundle().getBundleId())
+            if (cap1.getRevision().getBundle().getBundleId() <
+                cap2.getRevision().getBundle().getBundleId())
             {
                 c = -1;
             }
-            else if (cap1.getModule().getBundle().getBundleId() >
-                cap2.getModule().getBundle().getBundleId())
+            else if (cap1.getRevision().getBundle().getBundleId() >
+                cap2.getRevision().getBundle().getBundleId())
             {
                 c = 1;
             }

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Candidates.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Candidates.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Candidates.java (original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Candidates.java Wed May  4 15:36:50 2011
@@ -30,34 +30,38 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeMap;
 import java.util.TreeSet;
+import org.apache.felix.framework.BundleRevisionImpl;
 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;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
 
 class Candidates
 {
-    private final Module m_root;
+    private final BundleRevision m_root;
 
-    // Set of all candidate modules.
-    private final Set<Module> m_candidateModules;
+    // Set of all candidate bundle revisions.
+    private final Set<BundleRevision> m_candidateRevisions;
     // Maps a capability to requirements that match it.
-    private final Map<BundleCapabilityImpl, Set<BundleRequirementImpl>> m_dependentMap;
+    private final Map<BundleCapability, Set<BundleRequirement>> m_dependentMap;
     // Maps a requirement to the capability it matches.
-    private final Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> m_candidateMap;
+    private final Map<BundleRequirement, SortedSet<BundleCapability>> 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<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;
+    private final Map<BundleCapability,
+        Map<String, Map<Version, List<BundleRequirement>>>> m_hostFragments;
+    // Maps a bundle revision to its associated wrapped revision; this only happens
+    // when a revision being resolved has fragments to attach to it.
+    private final Map<BundleRevision, HostBundleRevision> m_allWrappedHosts;
     // Map used when populating candidates to hold intermediate and final results.
-    private final Map<Module, Object> m_populateResultCache;
+    private final Map<BundleRevision, Object> m_populateResultCache;
 
     // Flag to signal if fragments are present in the candidate map.
     private boolean m_fragmentsPresent = false;
@@ -71,16 +75,16 @@ class Candidates
      * @param wrappedHosts the wrapped hosts map.
     **/
     private Candidates(
-        Module root,
-        Set<Module> candidateModules,
-        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,
+        BundleRevision root,
+        Set<BundleRevision> candidateRevisions,
+        Map<BundleCapability, Set<BundleRequirement>> dependentMap,
+        Map<BundleRequirement, SortedSet<BundleCapability>> candidateMap,
+        Map<BundleCapability, Map<String, Map<Version, List<BundleRequirement>>>> hostFragments,
+        Map<BundleRevision, HostBundleRevision> wrappedHosts, Map<BundleRevision, Object> populateResultCache,
         boolean fragmentsPresent)
     {
         m_root = root;
-        m_candidateModules = candidateModules;
+        m_candidateRevisions = candidateRevisions;
         m_dependentMap = dependentMap;
         m_candidateMap = candidateMap;
         m_hostFragments = hostFragments;
@@ -94,16 +98,16 @@ class Candidates
      * @param state the resolver state used for populating the candidates.
      * @param root the root module for the resolve.
     **/
-    public Candidates(ResolverState state, Module root)
+    public Candidates(ResolverState state, BundleRevision root)
     {
         m_root = root;
-        m_candidateModules = new HashSet<Module>();
-        m_dependentMap = new HashMap<BundleCapabilityImpl, Set<BundleRequirementImpl>>();
-        m_candidateMap = new HashMap<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>>();
+        m_candidateRevisions = new HashSet<BundleRevision>();
+        m_dependentMap = new HashMap<BundleCapability, Set<BundleRequirement>>();
+        m_candidateMap = new HashMap<BundleRequirement, SortedSet<BundleCapability>>();
         m_hostFragments =
-            new HashMap<BundleCapabilityImpl, Map<String, Map<Version, List<BundleRequirementImpl>>>>();
-        m_allWrappedHosts = new HashMap<Module, HostModule>();
-        m_populateResultCache = new HashMap<Module, Object>();
+            new HashMap<BundleCapability, Map<String, Map<Version, List<BundleRequirement>>>>();
+        m_allWrappedHosts = new HashMap<BundleRevision, HostBundleRevision>();
+        m_populateResultCache = new HashMap<BundleRevision, Object>();
 
         populate(state, m_root);
     }
@@ -118,17 +122,17 @@ class Candidates
      * @param req the requirement being resolved.
      * @param candidates the potential candidates matching the requirement.
     **/
-    public Candidates(ResolverState state, Module root,
-        BundleRequirementImpl req, SortedSet<BundleCapabilityImpl> candidates)
+    public Candidates(ResolverState state, BundleRevision root,
+        BundleRequirement req, SortedSet<BundleCapability> candidates)
     {
         m_root = root;
-        m_candidateModules = new HashSet<Module>();
-        m_dependentMap = new HashMap<BundleCapabilityImpl, Set<BundleRequirementImpl>>();
-        m_candidateMap = new HashMap<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>>();
+        m_candidateRevisions = new HashSet<BundleRevision>();
+        m_dependentMap = new HashMap<BundleCapability, Set<BundleRequirement>>();
+        m_candidateMap = new HashMap<BundleRequirement, SortedSet<BundleCapability>>();
         m_hostFragments =
-            new HashMap<BundleCapabilityImpl, Map<String, Map<Version, List<BundleRequirementImpl>>>>();
-        m_allWrappedHosts = new HashMap<Module, HostModule>();
-        m_populateResultCache = new HashMap<Module, Object>();
+            new HashMap<BundleCapability, Map<String, Map<Version, List<BundleRequirement>>>>();
+        m_allWrappedHosts = new HashMap<BundleRevision, HostBundleRevision>();
+        m_populateResultCache = new HashMap<BundleRevision, Object>();
 
         add(req, candidates);
 
@@ -138,17 +142,17 @@ class Candidates
     /**
      * Populates additional candidates for the specified module.
      * @param state the resolver state used for populating the candidates.
-     * @param module the module whose candidates should be populated.
+     * @param revision the module whose candidates should be populated.
      */
 // TODO: FELIX3 - Modify to not be recursive.
-    public final void populate(ResolverState state, Module module)
+    public final void populate(ResolverState state, BundleRevision revision)
     {
-        // Determine if we've already calculated this module's candidates.
+        // Determine if we've already calculated this revision's candidates.
         // The result cache will have one of three values:
         //   1. A resolve exception if we've already attempted to populate the
-        //      module's candidates but were unsuccessful.
+        //      revision's candidates but were unsuccessful.
         //   2. Boolean.TRUE indicating we've already attempted to populate the
-        //      module's candidates and were successful.
+        //      revision's candidates and were successful.
         //   3. An array containing the cycle count, current map of candidates
         //      for already processed requirements, and a list of remaining
         //      requirements whose candidates still need to be calculated.
@@ -158,19 +162,19 @@ class Candidates
         // until we've popped completely out of the cycle.
 
         // Keeps track of the number of times we've reentered this method
-        // for the current module.
+        // for the current revision.
         Integer cycleCount = null;
 
         // Keeps track of the candidates we've already calculated for the
-        // current module's requirements.
-        Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> localCandidateMap = null;
+        // current revision's requirements.
+        Map<BundleRequirement, SortedSet<BundleCapability>> localCandidateMap = null;
 
-        // Keeps track of the current module's requirements for which we
+        // Keeps track of the current revision's requirements for which we
         // haven't yet found candidates.
-        List<BundleRequirementImpl> remainingReqs = null;
+        List<BundleRequirement> remainingReqs = null;
 
-        // Get the cache value for the current module.
-        Object cacheValue = m_populateResultCache.get(module);
+        // Get the cache value for the current revision.
+        Object cacheValue = m_populateResultCache.get(revision);
 
         // This is case 1.
         if (cacheValue instanceof ResolveException)
@@ -195,66 +199,67 @@ class Candidates
             remainingReqs = (List) ((Object[]) cacheValue)[2];
         }
 
-        // If there is no cache value for the current module, then this is
+        // If there is no cache value for the current revision, then this is
         // the first time we are attempting to populate its candidates, so
         // do some one-time checks and initialization.
         if ((remainingReqs == null) && (localCandidateMap == null))
         {
             // Verify that any required execution environment is satisfied.
-            state.checkExecutionEnvironment(module);
+            state.checkExecutionEnvironment(revision);
 
             // Verify that any native libraries match the current platform.
-            state.checkNativeLibraries(module);
+            state.checkNativeLibraries(revision);
 
             // Record cycle count.
             cycleCount = new Integer(0);
 
             // Create a local map for populating candidates first, just in case
-            // the module is not resolvable.
+            // the revision is not resolvable.
             localCandidateMap = new HashMap();
 
-            // Create a modifiable list of the module's requirements.
-            remainingReqs = new ArrayList(module.getDeclaredRequirements());
+            // Create a modifiable list of the revision's requirements.
+            remainingReqs = new ArrayList(revision.getDeclaredRequirements(null));
 
             // Add these value to the result cache so we know we are
             // in the middle of populating candidates for the current
-            // module.
-            m_populateResultCache.put(module,
+            // revision.
+            m_populateResultCache.put(revision,
                 cacheValue = new Object[] { cycleCount, localCandidateMap, remainingReqs });
         }
 
         // If we have requirements remaining, then find candidates for them.
         while (remainingReqs.size() > 0)
         {
-            BundleRequirementImpl req = remainingReqs.remove(0);
+            BundleRequirement req = remainingReqs.remove(0);
 
             // Get satisfying candidates and populate their candidates if necessary.
             ResolveException rethrow = null;
-            SortedSet<BundleCapabilityImpl> candidates = state.getCandidates(req, true);
-            for (Iterator<BundleCapabilityImpl> itCandCap = candidates.iterator();
+            SortedSet<BundleCapability> candidates =
+                state.getCandidates((BundleRequirementImpl) req, true);
+            for (Iterator<BundleCapability> itCandCap = candidates.iterator();
                 itCandCap.hasNext(); )
             {
-                BundleCapabilityImpl candCap = itCandCap.next();
+                BundleCapability candCap = itCandCap.next();
 
-                // If the candidate module is a fragment, then always attempt
+                // If the candidate revision is a fragment, then always attempt
                 // to populate candidates for its dependency, since it must be
                 // attached to a host to be used. Otherwise, if the candidate
-                // module is not already resolved and is not the current module
+                // revision is not already resolved and is not the current version
                 // we are trying to populate, then populate the candidates for
                 // its dependencies as well.
                 // NOTE: Technically, we don't have to check to see if the
-                // candidate module is equal to the current module, but this
+                // candidate revision is equal to the current revision, but this
                 // saves us from recursing and also simplifies exceptions messages
                 // since we effectively chain exception messages for each level
                 // of recursion; thus, any avoided recursion results in fewer
                 // exceptions to chain when an error does occur.
-                if (Util.isFragment(candCap.getModule())
-                    || (!candCap.getModule().isResolved()
-                        && !candCap.getModule().equals(module)))
+                if (Util.isFragment(candCap.getRevision())
+                    || ((candCap.getRevision().getWiring() == null)
+                        && !candCap.getRevision().equals(revision)))
                 {
                     try
                     {
-                        populate(state, candCap.getModule());
+                        populate(state, candCap.getRevision());
                     }
                     catch (ResolveException ex)
                     {
@@ -272,16 +277,16 @@ class Candidates
             // If there are no candidates for the current requirement
             // and it is not optional, then create, cache, and throw
             // a resolve exception.
-            if (candidates.isEmpty() && !req.isOptional())
+            if (candidates.isEmpty() && !((BundleRequirementImpl) req).isOptional())
             {
-                String msg = "Unable to resolve " + module
+                String msg = "Unable to resolve " + revision
                     + ": missing requirement " + req;
                 if (rethrow != null)
                 {
                     msg = msg + " [caused by: " + rethrow.getMessage() + "]";
                 }
-                rethrow = new ResolveException(msg, module, req);
-                m_populateResultCache.put(module, rethrow);
+                rethrow = new ResolveException(msg, revision, req);
+                m_populateResultCache.put(revision, rethrow);
                 throw rethrow;
             }
             // If we actually have candidates for the requirement, then
@@ -300,8 +305,8 @@ class Candidates
         }
         else if (cycleCount.intValue() == 0)
         {
-            // Record that the module was successfully populated.
-            m_populateResultCache.put(module, Boolean.TRUE);
+            // Record that the revision was successfully populated.
+            m_populateResultCache.put(revision, Boolean.TRUE);
 
             // Merge local candidate map into global candidate map.
             if (localCandidateMap.size() > 0)
@@ -311,42 +316,42 @@ class Candidates
         }
     }
 
-    public final void populateOptional(ResolverState state, Module module)
+    public final void populateOptional(ResolverState state, BundleRevision revision)
     {
         // We will always attempt to populate optional fragments, since this
         // is necessary for greedy resolving of fragment. Howevere, we'll only
-        // attempt to populate optional non-fragment modules if they aren't
+        // attempt to populate optional non-fragment revisions if they aren't
         // already resolved.
-        boolean isFragment = Util.isFragment(module);
-        if (!isFragment && module.isResolved())
+        boolean isFragment = Util.isFragment(revision);
+        if (!isFragment && (revision.getWiring() != null))
         {
             return;
         }
 
         try
         {
-            // If the optional module is a fragment, then we only want to populate
+            // If the optional revision is a fragment, then we only want to populate
             // the fragment if it has a candidate host in the set of already populated
-            // modules. We do this to avoid unnecessary work in prepare(). If the
+            // revisions. We do this to avoid unnecessary work in prepare(). If the
             // fragment has a host, we'll prepopulate the result cache here to avoid
             // having to do the host lookup again in populate().
             if (isFragment)
             {
-                // Get the current result cache value, to make sure the module
+                // Get the current result cache value, to make sure the revision
                 // hasn't already been populated.
-                Object cacheValue = m_populateResultCache.get(module);
+                Object cacheValue = m_populateResultCache.get(revision);
                 if (cacheValue == null)
                 {
-                    // Create a modifiable list of the module's requirements.
-                    List<BundleRequirementImpl> remainingReqs =
-                        new ArrayList(module.getDeclaredRequirements());
+                    // Create a modifiable list of the revision's requirements.
+                    List<BundleRequirement> remainingReqs =
+                        new ArrayList(revision.getDeclaredRequirements(null));
 
                     // Find the host requirement.
-                    BundleRequirementImpl hostReq = null;
-                    for (Iterator<BundleRequirementImpl> it = remainingReqs.iterator();
+                    BundleRequirement hostReq = null;
+                    for (Iterator<BundleRequirement> it = remainingReqs.iterator();
                         it.hasNext(); )
                     {
-                        BundleRequirementImpl r = it.next();
+                        BundleRequirement r = it.next();
                         if (r.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
                         {
                             hostReq = r;
@@ -355,11 +360,12 @@ class Candidates
                     }
 
                     // Get candidates hosts and keep any that have been populated.
-                    SortedSet<BundleCapabilityImpl> hosts = state.getCandidates(hostReq, false);
-                    for (Iterator<BundleCapabilityImpl> it = hosts.iterator(); it.hasNext(); )
+                    SortedSet<BundleCapability> hosts =
+                        state.getCandidates((BundleRequirementImpl) hostReq, false);
+                    for (Iterator<BundleCapability> it = hosts.iterator(); it.hasNext(); )
                     {
-                        BundleCapabilityImpl host = it.next();
-                        if (!isPopulated(host.getModule()))
+                        BundleCapability host = it.next();
+                        if (!isPopulated(host.getRevision()))
                         {
                             it.remove();
                         }
@@ -377,65 +383,65 @@ class Candidates
                     // the work we've done so far.
                     
                     // Verify that any required execution environment is satisfied.
-                    state.checkExecutionEnvironment(module);
+                    state.checkExecutionEnvironment(revision);
 
                     // Verify that any native libraries match the current platform.
-                    state.checkNativeLibraries(module);
+                    state.checkNativeLibraries(revision);
 
                     // Record cycle count, but start at -1 since it will
                     // be incremented again in populate().
                     Integer cycleCount = new Integer(-1);
 
                     // Create a local map for populating candidates first, just in case
-                    // the module is not resolvable.
-                    Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> localCandidateMap =
-                        new HashMap<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>>();
+                    // the revision is not resolvable.
+                    Map<BundleRequirement, SortedSet<BundleCapability>> localCandidateMap =
+                        new HashMap<BundleRequirement, SortedSet<BundleCapability>>();
 
                     // Add the discovered host candidates to the local candidate map.
                     localCandidateMap.put(hostReq, hosts);
 
                     // Add these value to the result cache so we know we are
                     // in the middle of populating candidates for the current
-                    // module.
-                    m_populateResultCache.put(module,
+                    // revision.
+                    m_populateResultCache.put(revision,
                         new Object[] { cycleCount, localCandidateMap, remainingReqs });
                 }
             }
 
-            // Try to populate candidates for the optional module.
-            populate(state, module);
+            // Try to populate candidates for the optional revision.
+            populate(state, revision);
         }
         catch (ResolveException ex)
         {
-            // Ignore since the module is optional.
+            // Ignore since the revision is optional.
         }
     }
 
-    private boolean isPopulated(Module module)
+    private boolean isPopulated(BundleRevision revision)
     {
-        Object value = m_populateResultCache.get(module);
+        Object value = m_populateResultCache.get(revision);
         return ((value != null) && (value instanceof Boolean));
     }
 
-    private void populateDynamic(ResolverState state, Module module)
+    private void populateDynamic(ResolverState state, BundleRevision revision)
     {
         // There should be one entry in the candidate map, which are the
         // the candidates for the matching dynamic requirement. Get the
         // matching candidates and populate their candidates if necessary.
         ResolveException rethrow = null;
-        Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry =
+        Entry<BundleRequirement, SortedSet<BundleCapability>> entry =
             m_candidateMap.entrySet().iterator().next();
-        BundleRequirementImpl dynReq = entry.getKey();
-        SortedSet<BundleCapabilityImpl> candidates = entry.getValue();
-        for (Iterator<BundleCapabilityImpl> itCandCap = candidates.iterator();
+        BundleRequirement dynReq = entry.getKey();
+        SortedSet<BundleCapability> candidates = entry.getValue();
+        for (Iterator<BundleCapability> itCandCap = candidates.iterator();
             itCandCap.hasNext(); )
         {
-            BundleCapabilityImpl candCap = itCandCap.next();
-            if (!candCap.getModule().isResolved())
+            BundleCapability candCap = itCandCap.next();
+            if (candCap.getRevision().getWiring() == null)
             {
                 try
                 {
-                    populate(state, candCap.getModule());
+                    populate(state, candCap.getRevision());
                 }
                 catch (ResolveException ex)
                 {
@@ -452,7 +458,7 @@ class Candidates
         {
             if (rethrow == null)
             {
-                rethrow = new ResolveException("Dynamic import failed.", module, dynReq);
+                rethrow = new ResolveException("Dynamic import failed.", revision, dynReq);
             }
             throw rethrow;
         }
@@ -467,7 +473,7 @@ class Candidates
      * @param req the requirement to add.
      * @param candidates the candidates matching the requirement.
     **/
-    private void add(BundleRequirementImpl req, SortedSet<BundleCapabilityImpl> candidates)
+    private void add(BundleRequirement req, SortedSet<BundleCapability> candidates)
     {
         if (req.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
         {
@@ -477,14 +483,14 @@ class Candidates
         // Record the candidates.
         m_candidateMap.put(req, candidates);
 
-        // Make a list of all candidate modules for determining singetons.
+        // Make a list of all candidate revisions for determining singetons.
         // Add the requirement as a dependent on the candidates. Keep track
         // of fragments for hosts.
-        for (BundleCapabilityImpl cap : candidates)
+        for (BundleCapability cap : candidates)
         {
-            // Remember the module for all capabilities so we can
+            // Remember the revision for all capabilities so we can
             // determine which ones are singletons.
-            m_candidateModules.add(cap.getModule());
+            m_candidateRevisions.add(cap.getRevision());
         }
     }
 
@@ -494,9 +500,9 @@ class Candidates
      * be further modified by the caller.
      * @param candidates the bulk requirements and candidates to add.
     **/
-    private void add(Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> candidates)
+    private void add(Map<BundleRequirement, SortedSet<BundleCapability>> candidates)
     {
-        for (Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry : candidates.entrySet())
+        for (Entry<BundleRequirement, SortedSet<BundleCapability>> entry : candidates.entrySet())
         {
             add(entry.getKey(), entry.getValue());
         }
@@ -509,9 +515,9 @@ class Candidates
      * @param m the module whose wrapper is desired.
      * @return the wrapper module or the module itself if it was not wrapped.
     **/
-    public Module getWrappedHost(Module m)
+    public BundleRevision getWrappedHost(BundleRevision m)
     {
-        Module wrapped = m_allWrappedHosts.get(m);
+        BundleRevision wrapped = m_allWrappedHosts.get(m);
         return (wrapped == null) ? m : wrapped;
     }
 
@@ -520,7 +526,7 @@ class Candidates
      * @param req the requirement whose candidates are desired.
      * @return the matching candidates or null.
     **/
-    public SortedSet<BundleCapabilityImpl> getCandidates(BundleRequirementImpl req)
+    public SortedSet<BundleCapability> getCandidates(BundleRequirement req)
     {
         return m_candidateMap.get(req);
     }
@@ -541,7 +547,7 @@ class Candidates
      * @throws ResolveException if the removal of any unselected fragments result
      *         in the root module being unable to resolve.
     **/
-    public void prepare(List<Module> existingSingletons)
+    public void prepare(List<BundleRevision> existingSingletons)
     {
         boolean init = false;
 
@@ -551,12 +557,12 @@ class Candidates
             init = true;
         }
 
-        final Map<String, Module> singletons = new HashMap<String, Module>();
+        final Map<String, BundleRevision> singletons = new HashMap<String, BundleRevision>();
 
-        for (Iterator<Module> it = m_candidateModules.iterator(); it.hasNext(); )
+        for (Iterator<BundleRevision> it = m_candidateRevisions.iterator(); it.hasNext(); )
         {
-            Module m = it.next();
-            if (isSingleton(m))
+            BundleRevision br = it.next();
+            if (isSingleton(br))
             {
                 if (!init)
                 {
@@ -565,28 +571,28 @@ class Candidates
                 }
 
                 // See if there is an existing singleton for the
-                // module's symbolic name.
-                Module singleton = singletons.get(m.getSymbolicName());
-                // If there is no existing singleton or this module is
-                // a resolved singleton or this module has a higher version
+                // revision's symbolic name.
+                BundleRevision singleton = singletons.get(br.getSymbolicName());
+                // If there is no existing singleton or this revision is
+                // a resolved singleton or this revision has a higher version
                 // and the existing singleton is not resolved, then select
-                // this module as the singleton.
+                // this revision as the singleton.
                 if ((singleton == null)
-                    || m.isResolved()
-                    || ((m.getVersion().compareTo(singleton.getVersion()) > 0)
-                        && !singleton.isResolved()))
+                    || (br.getWiring() != null)
+                    || ((br.getVersion().compareTo(singleton.getVersion()) > 0)
+                        && (singleton.getWiring() == null)))
                 {
-                    singletons.put(m.getSymbolicName(), m);
-                    // Remove the singleton module from the candidates
+                    singletons.put(br.getSymbolicName(), br);
+                    // Remove the singleton revision from the candidates
                     // if it wasn't selected.
                     if (singleton != null)
                     {
-                        removeModule(singleton);
+                        removeRevision(singleton);
                     }
                 }
                 else
                 {
-                    removeModule(m);
+                    removeRevision(br);
                 }
             }
         }
@@ -594,11 +600,11 @@ class Candidates
         // If the root is a singleton, then prefer it over any other singleton.
         if (isSingleton(m_root))
         {
-            Module singleton = singletons.get(m_root.getSymbolicName());
+            BundleRevision singleton = singletons.get(m_root.getSymbolicName());
             singletons.put(m_root.getSymbolicName(), m_root);
             if ((singleton != null) && !singleton.equals(m_root))
             {
-                if (singleton.isResolved())
+                if (singleton.getWiring() != null)
                 {
                     throw new ResolveException(
                         "Cannot resolve singleton "
@@ -608,7 +614,7 @@ class Candidates
                         + " singleton is already resolved.",
                         m_root, null);
                 }
-                removeModule(singleton);
+                removeRevision(singleton);
             }
         }
 
@@ -616,12 +622,12 @@ class Candidates
         // singletons passed into this method.
         for (int i = 0; (existingSingletons != null) && (i < existingSingletons.size()); i++)
         {
-            Module existing = existingSingletons.get(i);
-            Module singleton = singletons.get(existing.getSymbolicName());
+            BundleRevision existing = existingSingletons.get(i);
+            BundleRevision singleton = singletons.get(existing.getSymbolicName());
             if ((singleton != null) && (singleton != existing))
             {
                 singletons.remove(singleton.getSymbolicName());
-                removeModule(singleton);
+                removeRevision(singleton);
             }
         }
 
@@ -629,9 +635,9 @@ class Candidates
         // 1. Select the fragments to attach to a given host.
         // 2. Wrap hosts and attach fragments.
         // 3. Remove any unselected fragments. This is necessary because
-        //    other modules may depend on the capabilities of unselected
+        //    other revisions may depend on the capabilities of unselected
         //    fragments, so we need to remove the unselected fragments and
-        //    any modules that depends on them, which could ultimately cause
+        //    any revisions that depends on them, which could ultimately cause
         //    the entire resolve to fail.
         // 4. Replace all fragments with any host it was merged into
         //    (effectively multiplying it).
@@ -640,30 +646,31 @@ class Candidates
         //      with host's attached fragment capabilities.
 
         // Steps 1 and 2
-        List<HostModule> hostModules = new ArrayList<HostModule>();
-        List<Module> unselectedFragments = new ArrayList<Module>();
-        for (Entry<BundleCapabilityImpl, Map<String, Map<Version, List<BundleRequirementImpl>>>>
+        List<HostBundleRevision> hostRevisions = new ArrayList<HostBundleRevision>();
+        List<BundleRevision> unselectedFragments = new ArrayList<BundleRevision>();
+        for (Entry<BundleCapability, Map<String, Map<Version, List<BundleRequirement>>>>
             hostEntry : m_hostFragments.entrySet())
         {
             // Step 1
-            BundleCapabilityImpl hostCap = hostEntry.getKey();
-            Map<String, Map<Version, List<BundleRequirementImpl>>> fragments
+            BundleCapability hostCap = hostEntry.getKey();
+            Map<String, Map<Version, List<BundleRequirement>>> fragments
                 = hostEntry.getValue();
-            List<Module> selectedFragments = new ArrayList<Module>();
-            for (Entry<String, Map<Version, List<BundleRequirementImpl>>> fragEntry
+            List<BundleRevision> selectedFragments = new ArrayList<BundleRevision>();
+            for (Entry<String, Map<Version, List<BundleRequirement>>> fragEntry
                 : fragments.entrySet())
             {
                 boolean isFirst = true;
-                for (Entry<Version, List<BundleRequirementImpl>> versionEntry
+                for (Entry<Version, List<BundleRequirement>> versionEntry
                     : fragEntry.getValue().entrySet())
                 {
-                    for (BundleRequirementImpl hostReq : versionEntry.getValue())
+                    for (BundleRequirement hostReq : versionEntry.getValue())
                     {
                         // Select the highest version of the fragment that
                         // is not removal pending.
-                        if (isFirst && !hostReq.getModule().isRemovalPending())
+                        if (isFirst
+                            && !((BundleRevisionImpl) hostReq.getRevision()).isRemovalPending())
                         {
-                            selectedFragments.add(hostReq.getModule());
+                            selectedFragments.add(hostReq.getRevision());
                             isFirst = false;
                         }
                         // For any fragment that wasn't selected, remove the
@@ -674,11 +681,11 @@ class Candidates
                         else
                         {
                             m_dependentMap.get(hostCap).remove(hostReq);
-                            SortedSet<BundleCapabilityImpl> hosts = m_candidateMap.get(hostReq);
+                            SortedSet<BundleCapability> hosts = m_candidateMap.get(hostReq);
                             hosts.remove(hostCap);
                             if (hosts.isEmpty())
                             {
-                                unselectedFragments.add(hostReq.getModule());
+                                unselectedFragments.add(hostReq.getRevision());
                             }
                         }
                     }
@@ -686,31 +693,32 @@ class Candidates
             }
 
             // Step 2
-            HostModule wrappedHost = new HostModule(hostCap.getModule(), selectedFragments);
-            hostModules.add(wrappedHost);
-            m_allWrappedHosts.put(hostCap.getModule(), wrappedHost);
+            HostBundleRevision wrappedHost =
+                new HostBundleRevision(hostCap.getRevision(), selectedFragments);
+            hostRevisions.add(wrappedHost);
+            m_allWrappedHosts.put(hostCap.getRevision(), wrappedHost);
         }
 
         // Step 3
-        for (Module m : unselectedFragments)
+        for (BundleRevision br : unselectedFragments)
         {
-            removeModule(m);
+            removeRevision(br);
         }
 
         // Step 4
-        for (HostModule hostModule : hostModules)
+        for (HostBundleRevision hostRevision : hostRevisions)
         {
             // Replaces capabilities from fragments with the capabilities
             // from the merged host.
-            for (BundleCapabilityImpl c : hostModule.getDeclaredCapabilities())
+            for (BundleCapability c : hostRevision.getDeclaredCapabilities(null))
             {
-                Set<BundleRequirementImpl> dependents =
+                Set<BundleRequirement> dependents =
                     m_dependentMap.get(((HostedCapability) c).getDeclaredCapability());
                 if (dependents != null)
                 {
-                    for (BundleRequirementImpl r : dependents)
+                    for (BundleRequirement r : dependents)
                     {
-                        Set<BundleCapabilityImpl> cands = m_candidateMap.get(r);
+                        Set<BundleCapability> cands = m_candidateMap.get(r);
                         cands.remove(((HostedCapability) c).getDeclaredCapability());
                         cands.add(c);
                     }
@@ -720,13 +728,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 (BundleRequirementImpl r : hostModule.getDeclaredRequirements())
+            for (BundleRequirement r : hostRevision.getDeclaredRequirements(null))
             {
-                SortedSet<BundleCapabilityImpl> cands =
+                SortedSet<BundleCapability> cands =
                     m_candidateMap.get(((HostedRequirement) r).getDeclaredRequirement());
                 if (cands != null)
                 {
-                    m_candidateMap.put(r, new TreeSet<BundleCapabilityImpl>(cands));
+                    m_candidateMap.put(r, new TreeSet<BundleCapability>(cands));
                 }
             }
         }
@@ -734,18 +742,18 @@ class Candidates
 
     private void populateDependents()
     {
-        for (Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry
+        for (Entry<BundleRequirement, SortedSet<BundleCapability>> entry
             : m_candidateMap.entrySet())
         {
-            BundleRequirementImpl req = entry.getKey();
-            SortedSet<BundleCapabilityImpl> caps = entry.getValue();
-            for (BundleCapabilityImpl cap : caps)
+            BundleRequirement req = entry.getKey();
+            SortedSet<BundleCapability> caps = entry.getValue();
+            for (BundleCapability cap : caps)
             {
                 // Record the requirement as dependent on the capability.
-                Set<BundleRequirementImpl> dependents = m_dependentMap.get(cap);
+                Set<BundleRequirement> dependents = m_dependentMap.get(cap);
                 if (dependents == null)
                 {
-                    dependents = new HashSet<BundleRequirementImpl>();
+                    dependents = new HashSet<BundleRequirement>();
                     m_dependentMap.put(cap, dependents);
                 }
                 dependents.add(req);
@@ -753,26 +761,26 @@ class Candidates
                 // Keep track of hosts and associated fragments.
                 if (req.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE))
                 {
-                    Map<String, Map<Version, List<BundleRequirementImpl>>>
+                    Map<String, Map<Version, List<BundleRequirement>>>
                         fragments = m_hostFragments.get(cap);
                     if (fragments == null)
                     {
-                        fragments = new HashMap<String, Map<Version, List<BundleRequirementImpl>>>();
+                        fragments = new HashMap<String, Map<Version, List<BundleRequirement>>>();
                         m_hostFragments.put(cap, fragments);
                     }
-                    Map<Version, List<BundleRequirementImpl>> fragmentVersions =
-                        fragments.get(req.getModule().getSymbolicName());
+                    Map<Version, List<BundleRequirement>> fragmentVersions =
+                        fragments.get(req.getRevision().getSymbolicName());
                     if (fragmentVersions == null)
                     {
                         fragmentVersions =
-                            new TreeMap<Version, List<BundleRequirementImpl>>(Collections.reverseOrder());
-                        fragments.put(req.getModule().getSymbolicName(), fragmentVersions);
+                            new TreeMap<Version, List<BundleRequirement>>(Collections.reverseOrder());
+                        fragments.put(req.getRevision().getSymbolicName(), fragmentVersions);
                     }
-                    List<BundleRequirementImpl> actual = fragmentVersions.get(req.getModule().getVersion());
+                    List<BundleRequirement> actual = fragmentVersions.get(req.getRevision().getVersion());
                     if (actual == null)
                     {
-                        actual = new ArrayList<BundleRequirementImpl>();
-                        fragmentVersions.put(req.getModule().getVersion(), actual);
+                        actual = new ArrayList<BundleRequirement>();
+                        fragmentVersions.put(req.getRevision().getVersion(), actual);
                     }
                     actual.add(req);
                 }
@@ -785,26 +793,26 @@ class Candidates
      * as a fragment or a singleton. This process may cause other modules to
      * become unresolved if they depended on the module's capabilities and there
      * is no other candidate.
-     * @param module the module to remove.
+     * @param revision the module to remove.
      * @throws ResolveException if removing the module caused the resolve to fail.
     **/
-    private void removeModule(Module module) throws ResolveException
+    private void removeRevision(BundleRevision revision) throws ResolveException
     {
-        if (m_root.equals(module))
+        if (m_root.equals(revision))
         {
 // TODO: SINGLETON RESOLVER - Improve this message.
             String msg = "Unable to resolve " + m_root;
             ResolveException ex = new ResolveException(msg, m_root, null);
             throw ex;
         }
-        Set<Module> unresolvedModules = new HashSet<Module>();
-        remove(module, unresolvedModules);
-        while (!unresolvedModules.isEmpty())
+        Set<BundleRevision> unresolvedRevisions = new HashSet<BundleRevision>();
+        remove(revision, unresolvedRevisions);
+        while (!unresolvedRevisions.isEmpty())
         {
-            Iterator<Module> it = unresolvedModules.iterator();
-            module = it.next();
+            Iterator<BundleRevision> it = unresolvedRevisions.iterator();
+            revision = it.next();
             it.remove();
-            remove(module, unresolvedModules);
+            remove(revision, unresolvedRevisions);
         }
     }
 
@@ -812,22 +820,23 @@ class Candidates
      * Removes the specified module from the internal data structures, which
      * involves removing its requirements and its capabilities. This may cause
      * other modules to become unresolved as a result.
-     * @param m the module to remove.
-     * @param unresolvedModules a list to containing any additional modules that
+     * @param br the module to remove.
+     * @param unresolvedRevisions a list to containing any additional modules that
      *        that became unresolved as a result of removing this module and will
      *        also need to be removed.
      * @throws ResolveException if removing the module caused the resolve to fail.
     **/
-    private void remove(Module m, Set<Module> unresolvedModules) throws ResolveException
+    private void remove(BundleRevision br, Set<BundleRevision> unresolvedRevisions)
+        throws ResolveException
     {
-        for (BundleRequirementImpl r : m.getDeclaredRequirements())
+        for (BundleRequirement r : br.getDeclaredRequirements(null))
         {
             remove(r);
         }
 
-        for (BundleCapabilityImpl c : m.getDeclaredCapabilities())
+        for (BundleCapability c : br.getDeclaredCapabilities(null))
         {
-            remove(c, unresolvedModules);
+            remove(c, unresolvedRevisions);
         }
     }
 
@@ -835,16 +844,16 @@ class Candidates
      * Removes a requirement from the internal data structures.
      * @param req the requirement to remove.
     **/
-    private void remove(BundleRequirementImpl req)
+    private void remove(BundleRequirement req)
     {
         boolean isFragment = req.getNamespace().equals(BundleCapabilityImpl.HOST_NAMESPACE);
 
-        SortedSet<BundleCapabilityImpl> candidates = m_candidateMap.remove(req);
+        SortedSet<BundleCapability> candidates = m_candidateMap.remove(req);
         if (candidates != null)
         {
-            for (BundleCapabilityImpl cap : candidates)
+            for (BundleCapability cap : candidates)
             {
-                Set<BundleRequirementImpl> dependents = m_dependentMap.get(cap);
+                Set<BundleRequirement> dependents = m_dependentMap.get(cap);
                 if (dependents != null)
                 {
                     dependents.remove(req);
@@ -852,25 +861,25 @@ class Candidates
 
                 if (isFragment)
                 {
-                    Map<String, Map<Version, List<BundleRequirementImpl>>>
+                    Map<String, Map<Version, List<BundleRequirement>>>
                         fragments = m_hostFragments.get(cap);
                     if (fragments != null)
                     {
-                        Map<Version, List<BundleRequirementImpl>> fragmentVersions =
-                            fragments.get(req.getModule().getSymbolicName());
+                        Map<Version, List<BundleRequirement>> fragmentVersions =
+                            fragments.get(req.getRevision().getSymbolicName());
                         if (fragmentVersions != null)
                         {
-                            List<BundleRequirementImpl> actual =
-                                fragmentVersions.get(req.getModule().getVersion());
+                            List<BundleRequirement> actual =
+                                fragmentVersions.get(req.getRevision().getVersion());
                             if (actual != null)
                             {
                                 actual.remove(req);
                                 if (actual.isEmpty())
                                 {
-                                    fragmentVersions.remove(req.getModule().getVersion());
+                                    fragmentVersions.remove(req.getRevision().getVersion());
                                     if (fragmentVersions.isEmpty())
                                     {
-                                        fragments.remove(req.getModule().getSymbolicName());
+                                        fragments.remove(req.getRevision().getSymbolicName());
                                         if (fragments.isEmpty())
                                         {
                                             m_hostFragments.remove(cap);
@@ -889,34 +898,34 @@ class Candidates
      * Removes a capability from the internal data structures. This may cause
      * other modules to become unresolved as a result.
      * @param c the capability to remove.
-     * @param unresolvedModules a list to containing any additional modules that
+     * @param unresolvedRevisions a list to containing any additional modules that
      *        that became unresolved as a result of removing this module and will
      *        also need to be removed.
      * @throws ResolveException if removing the module caused the resolve to fail.
     **/
-    private void remove(BundleCapabilityImpl c, Set<Module> unresolvedModules)
+    private void remove(BundleCapability c, Set<BundleRevision> unresolvedRevisions)
         throws ResolveException
     {
-        Set<BundleRequirementImpl> dependents = m_dependentMap.remove(c);
+        Set<BundleRequirement> dependents = m_dependentMap.remove(c);
         if (dependents != null)
         {
-            for (BundleRequirementImpl r : dependents)
+            for (BundleRequirement r : dependents)
             {
-                SortedSet<BundleCapabilityImpl> candidates = m_candidateMap.get(r);
+                SortedSet<BundleCapability> candidates = m_candidateMap.get(r);
                 candidates.remove(c);
                 if (candidates.isEmpty())
                 {
                     m_candidateMap.remove(r);
-                    if (!r.isOptional())
+                    if (!((BundleRequirementImpl) r).isOptional())
                     {
-                        if (m_root.equals(r.getModule()))
+                        if (m_root.equals(r.getRevision()))
                         {
                             String msg = "Unable to resolve " + m_root
                                 + ": missing requirement " + r;
                             ResolveException ex = new ResolveException(msg, m_root, r);
                             throw ex;
                         }
-                        unresolvedModules.add(r.getModule());
+                        unresolvedRevisions.add(r.getRevision());
                     }
                 }
             }
@@ -930,62 +939,62 @@ class Candidates
     **/
     public Candidates copy()
     {
-        Map<BundleCapabilityImpl, Set<BundleRequirementImpl>> dependentMap =
-            new HashMap<BundleCapabilityImpl, Set<BundleRequirementImpl>>();
-        for (Entry<BundleCapabilityImpl, Set<BundleRequirementImpl>> entry : m_dependentMap.entrySet())
+        Map<BundleCapability, Set<BundleRequirement>> dependentMap =
+            new HashMap<BundleCapability, Set<BundleRequirement>>();
+        for (Entry<BundleCapability, Set<BundleRequirement>> entry : m_dependentMap.entrySet())
         {
-            Set<BundleRequirementImpl> dependents = new HashSet<BundleRequirementImpl>(entry.getValue());
+            Set<BundleRequirement> dependents = new HashSet<BundleRequirement>(entry.getValue());
             dependentMap.put(entry.getKey(), dependents);
         }
 
-        Map<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> candidateMap =
-            new HashMap<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>>();
-        for (Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry
+        Map<BundleRequirement, SortedSet<BundleCapability>> candidateMap =
+            new HashMap<BundleRequirement, SortedSet<BundleCapability>>();
+        for (Entry<BundleRequirement, SortedSet<BundleCapability>> entry
             : m_candidateMap.entrySet())
         {
-            SortedSet<BundleCapabilityImpl> candidates =
-                new TreeSet<BundleCapabilityImpl>(entry.getValue());
+            SortedSet<BundleCapability> candidates =
+                new TreeSet<BundleCapability>(entry.getValue());
             candidateMap.put(entry.getKey(), candidates);
         }
 
         return new Candidates(
-            m_root, m_candidateModules, dependentMap, candidateMap,
+            m_root, m_candidateRevisions, dependentMap, candidateMap,
             m_hostFragments, m_allWrappedHosts, m_populateResultCache,
             m_fragmentsPresent);
     }
 
     public void dump()
     {
-        // Create set of all modules from requirements.
-        Set<Module> modules = new HashSet();
-        for (Entry<BundleRequirementImpl, SortedSet<BundleCapabilityImpl>> entry
+        // Create set of all revisions from requirements.
+        Set<BundleRevision> revisions = new HashSet<BundleRevision>();
+        for (Entry<BundleRequirement, SortedSet<BundleCapability>> entry
             : m_candidateMap.entrySet())
         {
-            modules.add(entry.getKey().getModule());
+            revisions.add(entry.getKey().getRevision());
         }
-        // Now dump the modules.
+        // Now dump the revisions.
         System.out.println("=== BEGIN CANDIDATE MAP ===");
-        for (Module module : modules)
+        for (BundleRevision br : revisions)
         {
-            System.out.println("  " + module
-                 + " (" + (module.isResolved() ? "RESOLVED)" : "UNRESOLVED)"));
-            List<BundleRequirementImpl> reqs = (module.isResolved())
-                ? module.getResolvedRequirements()
-                : module.getDeclaredRequirements();
-            for (BundleRequirementImpl req : reqs)
+            System.out.println("  " + br
+                 + " (" + ((br.getWiring() != null) ? "RESOLVED)" : "UNRESOLVED)"));
+            List<BundleRequirement> reqs = (br.getWiring() != null)
+                ? br.getWiring().getRequirements(null)
+                : br.getDeclaredRequirements(null);
+            for (BundleRequirement req : reqs)
             {
-                Set<BundleCapabilityImpl> candidates = m_candidateMap.get(req);
+                Set<BundleCapability> candidates = m_candidateMap.get(req);
                 if ((candidates != null) && (candidates.size() > 0))
                 {
                     System.out.println("    " + req + ": " + candidates);
                 }
             }
-            reqs = (module.isResolved())
-                ? module.getResolvedDynamicRequirements()
-                : module.getDeclaredDynamicRequirements();
-            for (BundleRequirementImpl req : reqs)
+            reqs = (br.getWiring() != null)
+                ? ((BundleRevisionImpl) br).getResolvedDynamicRequirements()
+                : ((BundleRevisionImpl) br).getDeclaredDynamicRequirements();
+            for (BundleRequirement req : reqs)
             {
-                Set<BundleCapabilityImpl> candidates = m_candidateMap.get(req);
+                Set<BundleCapability> candidates = m_candidateMap.get(req);
                 if ((candidates != null) && (candidates.size() > 0))
                 {
                     System.out.println("    " + req + ": " + candidates);
@@ -999,14 +1008,14 @@ class Candidates
      * Returns true if the specified module is a singleton
      * (i.e., directive singleton:=true).
      *
-     * @param module the module to check for singleton status.
+     * @param revision the module to check for singleton status.
      * @return true if the module is a singleton, false otherwise.
     **/
-    private static boolean isSingleton(Module module)
+    private static boolean isSingleton(BundleRevision revision)
     {
-        final List<BundleCapabilityImpl> modCaps =
+        final List<BundleCapability> modCaps =
             Util.getCapabilityByNamespace(
-                module, BundleCapabilityImpl.MODULE_NAMESPACE);
+                revision, BundleCapabilityImpl.BUNDLE_NAMESPACE);
         if (modCaps == null || modCaps.isEmpty())
         {
             return false;

Added: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostBundleRevision.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostBundleRevision.java?rev=1099489&view=auto
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostBundleRevision.java (added)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostBundleRevision.java Wed May  4 15:36:50 2011
@@ -0,0 +1,148 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleWiring;
+
+class HostBundleRevision implements BundleRevision
+{
+    private final BundleRevision m_host;
+    private final List<BundleRevision> m_fragments;
+    private List<BundleCapability> m_cachedCapabilities = null;
+    private List<BundleRequirement> m_cachedRequirements = null;
+
+    public HostBundleRevision(BundleRevision host, List<BundleRevision> fragments)
+    {
+        m_host = host;
+        m_fragments = fragments;
+    }
+
+    public BundleRevision getHost()
+    {
+        return m_host;
+    }
+
+    public List<BundleRevision> getFragments()
+    {
+        return m_fragments;
+    }
+
+    public String getSymbolicName()
+    {
+        return m_host.getSymbolicName();
+    }
+
+    public Version getVersion()
+    {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public List<BundleCapability> getDeclaredCapabilities(String namespace)
+    {
+        if (m_cachedCapabilities == null)
+        {
+            List<BundleCapability> caps = new ArrayList<BundleCapability>();
+
+            // Wrap host capabilities.
+            for (BundleCapability cap : m_host.getDeclaredCapabilities(null))
+            {
+                caps.add(new HostedCapability(this, (BundleCapabilityImpl) cap));
+            }
+
+            // Wrap fragment capabilities.
+            if (m_fragments != null)
+            {
+                for (BundleRevision fragment : m_fragments)
+                {
+                    for (BundleCapability cap : fragment.getDeclaredCapabilities(null))
+                    {
+                        if (cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE))
+                        {
+                            caps.add(new HostedCapability(this, (BundleCapabilityImpl) cap));
+                        }
+                    }
+                }
+            }
+            m_cachedCapabilities = Collections.unmodifiableList(caps);
+        }
+        return m_cachedCapabilities;
+    }
+
+    public List<BundleRequirement> getDeclaredRequirements(String namespace)
+    {
+        if (m_cachedRequirements == null)
+        {
+            List<BundleRequirement> reqs = new ArrayList<BundleRequirement>();
+
+            // Wrap host requirements.
+            for (BundleRequirement req : m_host.getDeclaredRequirements(null))
+            {
+                reqs.add(new HostedRequirement(this, (BundleRequirementImpl) req));
+            }
+
+            // Wrap fragment requirements.
+            if (m_fragments != null)
+            {
+                for (BundleRevision fragment : m_fragments)
+                {
+                    for (BundleRequirement req : fragment.getDeclaredRequirements(null))
+                    {
+                        if (req.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE)
+                            || req.getNamespace().equals(BundleCapabilityImpl.BUNDLE_NAMESPACE))
+                        {
+                            reqs.add(new HostedRequirement(this, (BundleRequirementImpl) req));
+                        }
+                    }
+                }
+            }
+            m_cachedRequirements = Collections.unmodifiableList(reqs);
+        }
+        return m_cachedRequirements;
+    }
+
+    public int getTypes()
+    {
+        return m_host.getTypes();
+    }
+
+    public BundleWiring getWiring()
+    {
+        return null;
+    }
+
+    public Bundle getBundle()
+    {
+        return m_host.getBundle();
+    }
+
+    public String toString()
+    {
+        return m_host.toString();
+    }
+}
\ No newline at end of file

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java (original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java Wed May  4 15:36:50 2011
@@ -21,16 +21,18 @@ package org.apache.felix.framework.resol
 import java.util.List;
 import java.util.Map;
 import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRevision;
 
 public class HostedCapability extends BundleCapabilityImpl
 {
-    private final Module m_host;
+    private final BundleRevision m_host;
     private final BundleCapabilityImpl m_cap;
 
-    public HostedCapability(Module module, BundleCapabilityImpl cap)
+    public HostedCapability(BundleRevision host, BundleCapabilityImpl cap)
     {
-        super(module, cap.getNamespace(), cap.getDirectives(), cap.getAttributes());
-        m_host = module;
+        super(host, cap.getNamespace(), cap.getDirectives(), cap.getAttributes());
+        m_host = host;
         m_cap = cap;
     }
 
@@ -72,7 +74,7 @@ public class HostedCapability extends Bu
     }
 
     @Override
-    public Module getModule()
+    public BundleRevision getRevision()
     {
         return m_host;
     }

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java (original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java Wed May  4 15:36:50 2011
@@ -21,16 +21,17 @@ package org.apache.felix.framework.resol
 import java.util.Map;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
 import org.apache.felix.framework.wiring.BundleRequirementImpl;
+import org.osgi.framework.wiring.BundleRevision;
 
 public class HostedRequirement extends BundleRequirementImpl
 {
-    private final Module m_host;
+    private final BundleRevision m_host;
     private final BundleRequirementImpl m_req;
 
-    public HostedRequirement(Module module, BundleRequirementImpl req)
+    public HostedRequirement(BundleRevision host, BundleRequirementImpl req)
     {
-        super(module, req.getNamespace(), req.getDirectives(), req.getAttributes());
-        m_host = module;
+        super(host, req.getNamespace(), req.getDirectives(), req.getAttributes());
+        m_host = host;
         m_req = req;
     }
 
@@ -72,7 +73,7 @@ public class HostedRequirement extends B
     }
 
     @Override
-    public Module getModule()
+    public BundleRevision getRevision()
     {
         return m_host;
     }

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/ResolveException.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/ResolveException.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/ResolveException.java (original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/ResolveException.java Wed May  4 15:36:50 2011
@@ -18,30 +18,31 @@
  */
 package org.apache.felix.framework.resolver;
 
-import org.apache.felix.framework.wiring.BundleRequirementImpl;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
 
 public class ResolveException extends RuntimeException
 {
-    private final Module m_module;
-    private final BundleRequirementImpl m_req;
+    private final BundleRevision m_revision;
+    private final BundleRequirement 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, BundleRequirementImpl req)
+    public ResolveException(String msg, BundleRevision revision, BundleRequirement req)
     {
         super(msg);
-        m_module = module;
+        m_revision = revision;
         m_req = req;
     }
 
-    public Module getModule()
+    public BundleRevision getRevision()
     {
-        return m_module;
+        return m_revision;
     }
 
-    public BundleRequirementImpl getRequirement()
+    public BundleRequirement getRequirement()
     {
         return m_req;
     }

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Resolver.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Resolver.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Resolver.java (original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Resolver.java Wed May  4 15:36:50 2011
@@ -22,20 +22,23 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedSet;
-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.BundleRevision;
 
 public interface Resolver
 {
-    Map<Module, List<Wire>> resolve(ResolverState state, Module module, Set<Module> fragments);
-    Map<Module, List<Wire>> resolve(
-        ResolverState state, Module module, String pkgName, Set<Module> fragments);
+    Map<BundleRevision, List<ResolverWire>> resolve(
+        ResolverState state, BundleRevision revision, Set<BundleRevision> optional);
+    Map<BundleRevision, List<ResolverWire>> resolve(
+        ResolverState state, BundleRevision revision, String pkgName,
+        Set<BundleRevision> fragments);
 
     public static interface ResolverState
     {
-        SortedSet<BundleCapabilityImpl> getCandidates(
+        SortedSet<BundleCapability> getCandidates(
             BundleRequirementImpl req, boolean obeyMandatory);
-        void checkExecutionEnvironment(Module module) throws ResolveException;
-        void checkNativeLibraries(Module module) throws ResolveException;
+        void checkExecutionEnvironment(BundleRevision revision) throws ResolveException;
+        void checkNativeLibraries(BundleRevision revision) throws ResolveException;
     }
 }
\ No newline at end of file



Mime
View raw message