コード例 #1
0
  public void testSite() throws MalformedURLException, CoreException {
    String ident1 = "org.eclipse.test.feature_1.0.0.jar";

    ISite site = SiteManager.getSite(SOURCE_FILE_SITE, null);

    URL id = UpdateManagerUtils.getURL(site.getURL(), ident1, null);
    remoteFeature = new DefaultFeature(site);
    remoteFeature.setURL(id);
    assertEquals(site, remoteFeature.getSite());
  }
コード例 #2
0
 /** the feature to test */
 private DefaultFeature getFeature() throws MalformedURLException, CoreException {
   if (remoteFeature == null) {
     ISite site = SiteManager.getSite(SOURCE_FILE_SITE, null);
     URL id =
         UpdateManagerUtils.getURL(
             site.getURL(), "org.eclipse.update.core.feature1_1.0.0.jar", null);
     remoteFeature = new DefaultFeature(site);
     remoteFeature.setURL(id);
   }
   return remoteFeature;
 }
コード例 #3
0
  public void testIdentifier() throws CoreException, MalformedURLException {

    String id1 = "features/org.eclipse.test.feature_1.0.0.jar";
    String id2 = "features/org.eclipse_test_feature.jar";
    VersionedIdentifier ident1 = new VersionedIdentifier("org.test1.ident1", "1.0.0");
    VersionedIdentifier ident2 = new VersionedIdentifier("org.test1.ident2", "1.0.0");

    ISite site = SiteManager.getSite(SOURCE_FILE_SITE, null);

    URL url1 = UpdateManagerUtils.getURL(site.getURL(), id1, null);
    remoteFeature = new DefaultFeature(site);
    remoteFeature.setURL(url1);
    remoteFeature.setIdentifier(ident1);
    assertEquals(ident1.toString(), remoteFeature.getVersionedIdentifier().toString());

    URL url2 = UpdateManagerUtils.getURL(site.getURL(), id2, null);
    remoteFeature = new DefaultFeature(site);
    remoteFeature.setURL(url2);
    remoteFeature.setIdentifier(ident2);
    assertEquals(ident2.toString(), remoteFeature.getVersionedIdentifier().toString());
  }
コード例 #4
0
    public void run(
        ISite site,
        String[] categoriesToSkip,
        IUpdateSearchFilter filter,
        IUpdateSearchResultCollector collector,
        IProgressMonitor monitor) {

      ISiteFeatureReference[] refs = site.getFeatureReferences();
      HashSet ignores = new HashSet();
      Map liteFeatures = new HashMap();

      if (categoriesToSkip != null) {
        for (int i = 0; i < categoriesToSkip.length; i++) {
          ignores.add(categoriesToSkip[i]);
        }
      }
      List siteFeatureReferences = new ArrayList(Arrays.asList(refs));

      if (liteFeaturesAreOK && (site instanceof ExtendedSite)) {

        ExtendedSite extendedSite = (ExtendedSite) site;
        LiteFeature[] liteFeaturesArray = extendedSite.getLiteFeatures();
        if ((liteFeaturesArray != null) && (liteFeaturesArray.length != 0)) {
          for (int i = 0; i < liteFeaturesArray.length; i++) {
            liteFeatures.put(liteFeaturesArray[i].getVersionedIdentifier(), liteFeaturesArray[i]);
          }
          (new FeatureDownloader(
                  siteFeatureReferences, collector, filter, ignores, monitor, true, liteFeatures))
              .run();
          return;
        } else {
          liteFeaturesAreOK = false;
        }
      }

      monitor.beginTask("", refs.length); // $NON-NLS-1$
      ThreadGroup featureDownloaders = new ThreadGroup("FeatureDownloader"); // $NON-NLS-1$
      int numberOfThreads = (refs.length > 5) ? 5 : refs.length;

      Thread[] featureDownloader = new Thread[numberOfThreads];
      for (int i = 0; i < numberOfThreads; i++) {
        featureDownloader[i] =
            new Thread(
                featureDownloaders,
                new FeatureDownloader(siteFeatureReferences, collector, filter, ignores, monitor));
        featureDownloader[i].start();
      }

      int i = 0;
      while (i < numberOfThreads) {
        if (monitor.isCanceled()) {
          synchronized (siteFeatureReferences) {
            siteFeatureReferences.clear();
          }
        }
        try {
          featureDownloader[i].join(250);
          if (!featureDownloader[i].isAlive()) {
            i++;
          }
        } catch (InterruptedException ie) {
        }
      }
    }