org.eclipse.equinox.p2.updatechecker_1.1.200.v20110808-1657

16:44:38.226 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.p2.updatechecker_1.1.200.v20110808-1657.jar
package org.eclipse.equinox.internal.p2.updatechecker;

import java.util.Collection;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.provisional.p2.updatechecker.IUpdateListener;
import org.eclipse.equinox.internal.provisional.p2.updatechecker.UpdateEvent;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQuery;

class UpdateChecker$UpdateCheckThread
  extends Thread
{
  boolean done = false;
  long poll;
  long delay;
  IUpdateListener listener;
  String profileId;
  IQuery<IInstallableUnit> query;
  final UpdateChecker this$0;
  
  UpdateChecker$UpdateCheckThread(String arg1, IQuery<IInstallableUnit> profileId, long query, long arg5, IUpdateListener arg7)
  {
    this.poll = poll;
    this.delay = delay;
    this.profileId = profileId;
    this.query = query;
    this.listener = listener;
  }
  
  public void run()
  {
    try
    {
      if ((delay != -1L) && (delay > 0L)) {
        Thread.sleep(delay);
      }
      while (!done)
      {
        this$0.trace("Checking for updates for " + profileId + " at " + this$0.getTimeStamp());
        Collection<IInstallableUnit> iusWithUpdates = this$0.checkForUpdates(profileId, query);
        if (iusWithUpdates.size() > 0)
        {
          this$0.trace("Notifying listener of available updates");
          UpdateEvent event = new UpdateEvent(profileId, iusWithUpdates);
          if (!done) {
            listener.updatesAvailable(event);
          }
        }
        else
        {
          this$0.trace("No updates were available");
        }
        if ((delay == -1L) || (delay <= 0L)) {
          done = true;
        } else {
          Thread.sleep(poll);
        }
      }
    }
    catch (InterruptedException localInterruptedException) {}catch (Exception e)
    {
      LogHelper.log(new Status(4, "org.eclipse.equinox.p2.updatechecker", "Exception in update check thread", e));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.updatechecker.UpdateChecker.UpdateCheckThread
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.updatechecker;

import java.net.URI;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.internal.provisional.p2.updatechecker.IUpdateChecker;
import org.eclipse.equinox.internal.provisional.p2.updatechecker.IUpdateListener;
import org.eclipse.equinox.internal.provisional.p2.updatechecker.UpdateEvent;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.planner.IPlanner;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;

public class UpdateChecker
  implements IUpdateChecker
{
  public static boolean DEBUG = false;
  public static boolean TRACE = false;
  private HashMap<IUpdateListener, UpdateCheckThread> checkers = new HashMap();
  private final IProvisioningAgent agent;
  IProfileRegistry profileRegistry;
  IPlanner planner;
  
  private class UpdateCheckThread
    extends Thread
  {
    boolean done = false;
    long poll;
    long delay;
    IUpdateListener listener;
    String profileId;
    IQuery<IInstallableUnit> query;
    
    UpdateCheckThread(IQuery<IInstallableUnit> profileId, long query, long arg5, IUpdateListener arg7)
    {
      this.poll = poll;
      this.delay = delay;
      this.profileId = profileId;
      this.query = query;
      this.listener = listener;
    }
    
    public void run()
    {
      try
      {
        if ((delay != -1L) && (delay > 0L)) {
          Thread.sleep(delay);
        }
        while (!done)
        {
          trace("Checking for updates for " + profileId + " at " + getTimeStamp());
          Collection<IInstallableUnit> iusWithUpdates = checkForUpdates(profileId, query);
          if (iusWithUpdates.size() > 0)
          {
            trace("Notifying listener of available updates");
            UpdateEvent event = new UpdateEvent(profileId, iusWithUpdates);
            if (!done) {
              listener.updatesAvailable(event);
            }
          }
          else
          {
            trace("No updates were available");
          }
          if ((delay == -1L) || (delay <= 0L)) {
            done = true;
          } else {
            Thread.sleep(poll);
          }
        }
      }
      catch (InterruptedException localInterruptedException) {}catch (Exception e)
      {
        LogHelper.log(new Status(4, "org.eclipse.equinox.p2.updatechecker", "Exception in update check thread", e));
      }
    }
  }
  
  public UpdateChecker(IProvisioningAgent agent)
  {
    this.agent = agent;
  }
  
  public void addUpdateCheck(String profileId, IQuery<IInstallableUnit> query, long delay, long poll, IUpdateListener listener)
  {
    if (checkers.containsKey(listener)) {
      return;
    }
    trace("Adding update checker for " + profileId + " at " + getTimeStamp());
    UpdateCheckThread thread = new UpdateCheckThread(profileId, query, delay, poll, listener);
    checkers.put(listener, thread);
    thread.start();
  }
  
  public void removeUpdateCheck(IUpdateListener listener)
  {
    checkers.remove(listener);
  }
  
  Collection<IInstallableUnit> checkForUpdates(String profileId, IQuery<IInstallableUnit> query)
  {
    IProfile profile = getProfileRegistry().getProfile(profileId);
    ArrayList<IInstallableUnit> iusWithUpdates = new ArrayList();
    if (profile == null) {
      return CollectionUtils.emptyList();
    }
    ProvisioningContext context = new ProvisioningContext(agent);
    context.setMetadataRepositories(getAvailableRepositories());
    if (query == null) {
      query = QueryUtil.createIUAnyQuery();
    }
    Iterator<IInstallableUnit> iter = profile.query(query, null).iterator();
    while (iter.hasNext())
    {
      IInstallableUnit iu = (IInstallableUnit)iter.next();
      IQueryResult<IInstallableUnit> replacements = getPlanner().updatesFor(iu, context, null);
      if (!replacements.isEmpty()) {
        iusWithUpdates.add(iu);
      }
    }
    return iusWithUpdates;
  }
  
  private URI[] getAvailableRepositories()
  {
    IMetadataRepositoryManager repoMgr = (IMetadataRepositoryManager)agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
    URI[] repositories = repoMgr.getKnownRepositories(0);
    ArrayList<URI> available = new ArrayList();
    for (int i = 0; i < repositories.length; i++) {
      try
      {
        repoMgr.loadRepository(repositories[i], null);
        available.add(repositories[i]);
      }
      catch (ProvisionException e)
      {
        LogHelper.log(e.getStatus());
      }
    }
    return (URI[])available.toArray(new URI[available.size()]);
  }
  
  void trace(String message)
  {
    if (Tracing.DEBUG_UPDATE_CHECK) {
      Tracing.debug(message);
    }
  }
  
  String getTimeStamp()
  {
    Date d = new Date();
    SimpleDateFormat df = new SimpleDateFormat("[MM/dd/yy;HH:mm:ss:SSS]");
    return df.format(d);
  }
  
  IPlanner getPlanner()
  {
    if (planner == null)
    {
      planner = ((IPlanner)agent.getService(IPlanner.SERVICE_NAME));
      if (planner == null) {
        throw new IllegalStateException("Provisioning system has not been initialized");
      }
    }
    return planner;
  }
  
  IProfileRegistry getProfileRegistry()
  {
    if (profileRegistry == null)
    {
      profileRegistry = ((IProfileRegistry)agent.getService(IProfileRegistry.SERVICE_NAME));
      if (profileRegistry == null) {
        throw new IllegalStateException("Provisioning system has not been initialized");
      }
    }
    return profileRegistry;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.updatechecker.UpdateChecker
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.updatechecker;

import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;

public class UpdateCheckerComponent
  implements IAgentServiceFactory
{
  public static final String BUNDLE_ID = "org.eclipse.equinox.p2.updatechecker";
  
  public Object createService(IProvisioningAgent agent)
  {
    return new UpdateChecker(agent);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.updatechecker.UpdateCheckerComponent
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.provisional.p2.updatechecker;

import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQuery;

public abstract interface IUpdateChecker
{
  static
  {
    try {}catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }
  
  public static final String SERVICE_NAME = Class.forName("org.eclipse.equinox.internal.provisional.p2.updatechecker.IUpdateChecker").getName();
  public static final long ONE_TIME_CHECK = -1L;
  
  public abstract void addUpdateCheck(String paramString, IQuery<IInstallableUnit> paramIQuery, long paramLong1, long paramLong2, IUpdateListener paramIUpdateListener);
  
  public abstract void removeUpdateCheck(IUpdateListener paramIUpdateListener);
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.provisional.p2.updatechecker.IUpdateChecker
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.provisional.p2.updatechecker;

public abstract interface IUpdateListener
{
  public abstract void updatesAvailable(UpdateEvent paramUpdateEvent);
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.provisional.p2.updatechecker.IUpdateListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.provisional.p2.updatechecker;

import java.util.Collection;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;

public class UpdateEvent
{
  String profileId;
  Collection<IInstallableUnit> iusWithUpdates;
  
  public UpdateEvent(String profileId, Collection<IInstallableUnit> iusWithUpdates)
  {
    this.profileId = profileId;
    this.iusWithUpdates = iusWithUpdates;
  }
  
  public Collection<IInstallableUnit> getIUs()
  {
    return iusWithUpdates;
  }
  
  public String getProfileId()
  {
    return profileId;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.provisional.p2.updatechecker.UpdateEvent
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd