예제 #1
0
 // Once we have resolved bundles, we need to make sure that exports
 // from these are ahead of those from unresolved bundles
 void reorder() {
   Iterator it = internal.values().iterator();
   while (it.hasNext()) {
     ArrayList toBeReordered = new ArrayList();
     VersionSupplier[] existing = (VersionSupplier[]) it.next();
     if (existing == null || existing.length <= 1) continue;
     // Find any VersionSuppliers that need to be reordered
     VersionSupplier vs1 = (VersionSupplier) existing[0];
     for (int i = 1; i < existing.length; i++) {
       VersionSupplier vs2 = (VersionSupplier) existing[i];
       BundleDescription b1 = vs1.getBundle();
       BundleDescription b2 = vs2.getBundle();
       if (b2.isResolved() && !b1.isResolved()) {
         toBeReordered.add(vs2);
       } else if (b2.isResolved() == b1.isResolved()) {
         int versionDiff = vs2.getVersion().compareTo(vs1.getVersion());
         if (versionDiff > 0 || (b2.getBundleId() < b1.getBundleId() && versionDiff == 0)) {
           toBeReordered.add(vs2);
         }
       }
       vs1 = vs2;
     }
     // Reorder them
     for (int i = 0; i < toBeReordered.size(); i++) {
       VersionSupplier vs = (VersionSupplier) toBeReordered.get(i);
       remove(vs);
       put(vs);
     }
   }
 }
 public void checkBundlesResolved_a() {
   assertTrue("unexpected bundle resolution state", bundle_1.isResolved());
   assertTrue("unexpected bundle resolution state", !bundle_2.isResolved());
   assertTrue("unexpected bundle resolution state", bundle_3.isResolved());
   assertTrue("unexpected bundle resolution state", bundle_4.isResolved());
   assertTrue("unexpected bundle resolution state", bundle_5.isResolved());
   assertTrue("unexpected bundle resolution state", bundle_6.isResolved());
 } // end method