felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1667215 - in /felix/trunk/resolver/src/main/java/org/apache/felix/resolver: Candidates.java ResolverImpl.java
Date Tue, 17 Mar 2015 09:38:19 GMT
Author: gnodet
Date: Tue Mar 17 09:38:19 2015
New Revision: 1667215

URL: http://svn.apache.org/r1667215
Log:
[FELIX-4656] Bring a deterministic behaviour to the resolver
This would eventually allow introducing heuristics

Modified:
    felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Candidates.java
    felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java

Modified: felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Candidates.java
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Candidates.java?rev=1667215&r1=1667214&r2=1667215&view=diff
==============================================================================
--- felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Candidates.java (original)
+++ felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Candidates.java Tue Mar 17
09:38:19 2015
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -107,9 +108,9 @@ class Candidates
         m_dependentMap = new OpenHashMapSet<Capability, Requirement>();
         m_candidateMap = new OpenHashMapList<Requirement, Capability>();
         m_allWrappedHosts = new HashMap<Resource, WrappedResource>();
-        m_populateResultCache = new HashMap<Resource, Object>();
+        m_populateResultCache = new LinkedHashMap<Resource, Object>();
         m_validOnDemandResources = validOnDemandResources;
-        m_subtitutableMap = new HashMap<Capability, Requirement>();
+        m_subtitutableMap = new LinkedHashMap<Capability, Requirement>();
         m_path = new OpenHashMapSet<Requirement, Capability>(3);
     }
 
@@ -379,11 +380,11 @@ class Candidates
         {
             return;
         }
-        Map<String, Collection<Capability>> exportNames = new HashMap<String,
Collection<Capability>>();
+        Map<String, List<Capability>> exportNames = new LinkedHashMap<String,
List<Capability>>();
         for (Capability packageExport : packageExports)
         {
             String packageName = (String) packageExport.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
-            Collection<Capability> caps = exportNames.get(packageName);
+            List<Capability> caps = exportNames.get(packageName);
             if (caps == null)
             {
                 caps = new ArrayList<Capability>(1);
@@ -398,7 +399,7 @@ class Candidates
             if (substitutes != null && !substitutes.isEmpty())
             {
                 String packageName = (String) substitutes.iterator().next().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
-                Collection<Capability> exportedPackages = exportNames.get(packageName);
+                List<Capability> exportedPackages = exportNames.get(packageName);
                 if (exportedPackages != null)
                 {
                     // The package is exported;
@@ -427,7 +428,7 @@ class Candidates
 
     void checkSubstitutes(List<Candidates> importPermutations) throws ResolutionException
     {
-        Map<Capability, Integer> substituteStatuses = new HashMap<Capability, Integer>(m_subtitutableMap.size());
+        Map<Capability, Integer> substituteStatuses = new LinkedHashMap<Capability,
Integer>(m_subtitutableMap.size());
         for (Capability substitutable : m_subtitutableMap.keySet())
         {
             // initialize with unprocessed

Modified: felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java?rev=1667215&r1=1667214&r2=1667215&view=diff
==============================================================================
--- felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java (original)
+++ felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java Tue Mar
17 09:38:19 2015
@@ -24,6 +24,8 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -170,7 +172,7 @@ public class ResolverImpl implements Res
                 // fragments, since they will only be pulled in if their
                 // host is already present.
                 Set<Resource> allResources =
-                    new HashSet<Resource>(mandatoryResources);
+                    new LinkedHashSet<Resource>(mandatoryResources);
                 for (Resource resource : optionalResources)
                 {
                     if (allCandidates.isPopulated(resource))
@@ -1301,7 +1303,8 @@ public class ResolverImpl implements Res
         // Imported packages are added after required packages because they shadow or override
         // the packages from required bundles.
         Map<String, List<Blame>> allImportRequirePkgs =
-            new HashMap<String, List<Blame>>(pkgs.m_requiredPkgs);
+            new LinkedHashMap<String, List<Blame>>(pkgs.m_requiredPkgs.size()
+ pkgs.m_importedPkgs.size());
+        allImportRequirePkgs.putAll(pkgs.m_requiredPkgs);
         allImportRequirePkgs.putAll(pkgs.m_importedPkgs);
 
         for (Entry<String, List<Blame>> requirementBlames : allImportRequirePkgs.entrySet())
@@ -2099,10 +2102,10 @@ public class ResolverImpl implements Res
     private static class Packages
     {
         private final Resource m_resource;
-        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<UsedBlames>> m_usedPkgs = new HashMap();
+        public final Map<String, Blame> m_exportedPkgs = new LinkedHashMap<String,
Blame>(32);
+        public final Map<String, List<Blame>> m_importedPkgs = new LinkedHashMap<String,
List<Blame>>(32);
+        public final Map<String, List<Blame>> m_requiredPkgs = new LinkedHashMap<String,
List<Blame>>(32);
+        public final Map<String, Map<Capability, UsedBlames>> m_usedPkgs = new
LinkedHashMap<String, Map<Capability, UsedBlames>>(32);
         public boolean m_isCalculated = false;
 
         public Packages(Resource resource)



Mime
View raw message