org.eclipse.equinox.p2.directorywatcher_1.0.300.v20110808-1657

16:44:07.261 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.p2.directorywatcher_1.0.300.v20110808-1657.jar
package org.eclipse.equinox.internal.provisional.p2.directorywatcher;

import java.io.File;
import java.net.URI;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.service.packageadmin.PackageAdmin;

public class Activator
  implements BundleActivator
{
  public static final String ID = "org.eclipse.equinox.p2.directorywatcher";
  private static BundleContext context;
  
  public static BundleContext getContext()
  {
    return context;
  }
  
  public void start(BundleContext aContext)
    throws Exception
  {
    context = aContext;
  }
  
  public void stop(BundleContext aContext)
    throws Exception
  {
    context = null;
  }
  
  public static IArtifactRepositoryManager getArtifactRepositoryManager()
  {
    return (IArtifactRepositoryManager)((IProvisioningAgent)ServiceHelper.getService(context, IProvisioningAgent.SERVICE_NAME)).getService(IArtifactRepositoryManager.SERVICE_NAME);
  }
  
  public static IMetadataRepositoryManager getMetadataRepositoryManager()
  {
    return (IMetadataRepositoryManager)((IProvisioningAgent)ServiceHelper.getService(context, IProvisioningAgent.SERVICE_NAME)).getService(IMetadataRepositoryManager.SERVICE_NAME);
  }
  
  public static URI getDefaultRepositoryLocation(Object object, String repositoryName)
  {
    PackageAdmin packageAdmin = (PackageAdmin)ServiceHelper.getService(context, PackageAdmin.class.getName());
    Bundle bundle = packageAdmin.getBundle(object.getClass());
    BundleContext context = bundle.getBundleContext();
    File base = context.getDataFile("");
    File result = new File(base, "listener_" + repositoryName.hashCode());
    result.mkdirs();
    return result.toURI();
  }
}

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

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.p2.repository.IRunnableWithProgress;

class CachingArtifactRepository$1
  implements IRunnableWithProgress
{
  final CachingArtifactRepository this$0;
  
  CachingArtifactRepository$1(CachingArtifactRepository paramCachingArtifactRepository) {}
  
  public void run(IProgressMonitor monitor)
  {
    this$0.savePropertyChanges();
    this$0.saveAdditions();
    this$0.saveRemovals();
  }
}

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

import java.util.Collection;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;

class CachingArtifactRepository$2
  implements IQueryable<IArtifactDescriptor>
{
  final CachingArtifactRepository this$0;
  
  CachingArtifactRepository$2(CachingArtifactRepository paramCachingArtifactRepository, Collection paramCollection) {}
  
  public IQueryResult<IArtifactDescriptor> query(IQuery<IArtifactDescriptor> query, IProgressMonitor monitor)
  {
    return query.perform(new CompoundIterator(val$descs.iterator()));
  }
}

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

import java.util.Iterator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;

class CachingArtifactRepository$3
  implements IQueryable<IArtifactKey>
{
  final CachingArtifactRepository this$0;
  
  CachingArtifactRepository$3(CachingArtifactRepository paramCachingArtifactRepository, Iterator paramIterator) {}
  
  public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> q, IProgressMonitor mon)
  {
    return q.perform(val$keyIterator);
  }
}

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

import java.io.File;
import java.io.OutputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRunnableWithProgress;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository;

public class CachingArtifactRepository
  implements IArtifactRepository, IFileArtifactRepository
{
  private static final String NULL = "";
  private IArtifactRepository innerRepo;
  private Set<IArtifactDescriptor> descriptorsToAdd = new HashSet();
  private Map<IArtifactKey, List<IArtifactDescriptor>> artifactMap = new HashMap();
  private Set<IArtifactDescriptor> descriptorsToRemove = new HashSet();
  private Map<String, String> propertyChanges = new HashMap();
  
  protected CachingArtifactRepository(IArtifactRepository innerRepo)
  {
    this.innerRepo = innerRepo;
  }
  
  public void save()
  {
    innerRepo.executeBatch(new IRunnableWithProgress()
    {
      public void run(IProgressMonitor monitor)
      {
        savePropertyChanges();
        saveAdditions();
        saveRemovals();
      }
    }, null);
  }
  
  void saveRemovals()
  {
    for (Iterator localIterator = descriptorsToRemove.iterator(); localIterator.hasNext();)
    {
      IArtifactDescriptor desc = (IArtifactDescriptor)localIterator.next();
      innerRepo.removeDescriptor(desc);
    }
    descriptorsToRemove.clear();
  }
  
  void saveAdditions()
  {
    if (descriptorsToAdd.isEmpty()) {
      return;
    }
    innerRepo.addDescriptors((IArtifactDescriptor[])descriptorsToAdd.toArray(new IArtifactDescriptor[descriptorsToAdd.size()]));
    descriptorsToAdd.clear();
    artifactMap.clear();
  }
  
  void savePropertyChanges()
  {
    for (Iterator localIterator = propertyChanges.keySet().iterator(); localIterator.hasNext();)
    {
      String key = (String)localIterator.next();
      String value = (String)propertyChanges.get(key);
      innerRepo.setProperty(key, value == "" ? null : value);
    }
    propertyChanges.clear();
  }
  
  private void mapDescriptor(IArtifactDescriptor descriptor)
  {
    IArtifactKey key = descriptor.getArtifactKey();
    List<IArtifactDescriptor> descriptors = (List)artifactMap.get(key);
    if (descriptors == null)
    {
      descriptors = new ArrayList();
      artifactMap.put(key, descriptors);
    }
    descriptors.add(descriptor);
  }
  
  private void unmapDescriptor(IArtifactDescriptor descriptor)
  {
    IArtifactKey key = descriptor.getArtifactKey();
    List<IArtifactDescriptor> descriptors = (List)artifactMap.get(key);
    if (descriptors == null)
    {
      descriptorsToRemove.add(descriptor);
      return;
    }
    descriptors.remove(descriptor);
    if (descriptors.isEmpty()) {
      artifactMap.remove(key);
    }
  }
  
  /* Error */
  public synchronized void addDescriptors(IArtifactDescriptor[] descriptors, IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_2
    //   1: aload_1
    //   2: arraylength
    //   3: invokestatic 339	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   6: astore_3
    //   7: iconst_0
    //   8: istore 4
    //   10: goto +44 -> 54
    //   13: aload_1
    //   14: iload 4
    //   16: aaload
    //   17: checkcast 160	org/eclipse/equinox/p2/repository/artifact/spi/ArtifactDescriptor
    //   20: aload_0
    //   21: invokevirtual 358	org/eclipse/equinox/p2/repository/artifact/spi/ArtifactDescriptor:setRepository	(Lorg/eclipse/equinox/p2/repository/artifact/IArtifactRepository;)V
    //   24: aload_0
    //   25: getfield 325	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:descriptorsToAdd	Ljava/util/Set;
    //   28: aload_1
    //   29: iload 4
    //   31: aaload
    //   32: invokeinterface 377 2 0
    //   37: pop
    //   38: aload_0
    //   39: aload_1
    //   40: iload 4
    //   42: aaload
    //   43: invokespecial 343	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:mapDescriptor	(Lorg/eclipse/equinox/p2/repository/artifact/IArtifactDescriptor;)V
    //   46: aload_3
    //   47: iconst_1
    //   48: invokevirtual 338	org/eclipse/core/runtime/SubMonitor:worked	(I)V
    //   51: iinc 4 1
    //   54: iload 4
    //   56: aload_1
    //   57: arraylength
    //   58: if_icmplt -45 -> 13
    //   61: goto +18 -> 79
    //   64: astore 5
    //   66: aload_2
    //   67: ifnull +9 -> 76
    //   70: aload_2
    //   71: invokeinterface 382 1 0
    //   76: aload 5
    //   78: athrow
    //   79: aload_2
    //   80: ifnull +9 -> 89
    //   83: aload_2
    //   84: invokeinterface 382 1 0
    //   89: return
    // Line number table:
    //   Java source line #98	-> byte code offset #0
    //   Java source line #99	-> byte code offset #7
    //   Java source line #100	-> byte code offset #13
    //   Java source line #101	-> byte code offset #24
    //   Java source line #102	-> byte code offset #38
    //   Java source line #103	-> byte code offset #46
    //   Java source line #99	-> byte code offset #51
    //   Java source line #105	-> byte code offset #64
    //   Java source line #106	-> byte code offset #66
    //   Java source line #107	-> byte code offset #70
    //   Java source line #108	-> byte code offset #76
    //   Java source line #106	-> byte code offset #79
    //   Java source line #107	-> byte code offset #83
    //   Java source line #109	-> byte code offset #89
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	90	0	this	CachingArtifactRepository
    //   0	90	1	descriptors	IArtifactDescriptor[]
    //   0	90	2	monitor	IProgressMonitor
    //   6	41	3	subMonitor	org.eclipse.core.runtime.SubMonitor
    //   8	47	4	i	int
    //   64	13	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	64	64	finally
  }
  
  @Deprecated
  public final synchronized void addDescriptors(IArtifactDescriptor[] descriptors)
  {
    addDescriptors(descriptors, new NullProgressMonitor());
  }
  
  /* Error */
  public synchronized void addDescriptor(IArtifactDescriptor toAdd, IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_2
    //   1: iconst_1
    //   2: invokestatic 339	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   5: astore_3
    //   6: aload_1
    //   7: checkcast 160	org/eclipse/equinox/p2/repository/artifact/spi/ArtifactDescriptor
    //   10: aload_0
    //   11: invokevirtual 358	org/eclipse/equinox/p2/repository/artifact/spi/ArtifactDescriptor:setRepository	(Lorg/eclipse/equinox/p2/repository/artifact/IArtifactRepository;)V
    //   14: aload_0
    //   15: getfield 325	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:descriptorsToAdd	Ljava/util/Set;
    //   18: aload_1
    //   19: invokeinterface 377 2 0
    //   24: pop
    //   25: aload_0
    //   26: aload_1
    //   27: invokespecial 343	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:mapDescriptor	(Lorg/eclipse/equinox/p2/repository/artifact/IArtifactDescriptor;)V
    //   30: aload_3
    //   31: iconst_1
    //   32: invokevirtual 338	org/eclipse/core/runtime/SubMonitor:worked	(I)V
    //   35: goto +18 -> 53
    //   38: astore 4
    //   40: aload_2
    //   41: ifnull +9 -> 50
    //   44: aload_2
    //   45: invokeinterface 382 1 0
    //   50: aload 4
    //   52: athrow
    //   53: aload_2
    //   54: ifnull +9 -> 63
    //   57: aload_2
    //   58: invokeinterface 382 1 0
    //   63: return
    // Line number table:
    //   Java source line #118	-> byte code offset #0
    //   Java source line #120	-> byte code offset #6
    //   Java source line #121	-> byte code offset #14
    //   Java source line #122	-> byte code offset #25
    //   Java source line #123	-> byte code offset #30
    //   Java source line #124	-> byte code offset #38
    //   Java source line #125	-> byte code offset #40
    //   Java source line #126	-> byte code offset #44
    //   Java source line #127	-> byte code offset #50
    //   Java source line #125	-> byte code offset #53
    //   Java source line #126	-> byte code offset #57
    //   Java source line #128	-> byte code offset #63
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	64	0	this	CachingArtifactRepository
    //   0	64	1	toAdd	IArtifactDescriptor
    //   0	64	2	monitor	IProgressMonitor
    //   5	26	3	subMonitor	org.eclipse.core.runtime.SubMonitor
    //   38	13	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	38	38	finally
  }
  
  @Deprecated
  public final synchronized void addDescriptor(IArtifactDescriptor toAdd)
  {
    addDescriptor(toAdd, new NullProgressMonitor());
  }
  
  public synchronized IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key)
  {
    List<IArtifactDescriptor> result = (List)artifactMap.get(key);
    if (result == null) {
      return innerRepo.getArtifactDescriptors(key);
    }
    result = new ArrayList(result);
    result.addAll(Arrays.asList(innerRepo.getArtifactDescriptors(key)));
    return (IArtifactDescriptor[])result.toArray(new IArtifactDescriptor[result.size()]);
  }
  
  public synchronized boolean contains(IArtifactDescriptor descriptor)
  {
    return (descriptorsToAdd.contains(descriptor)) || (innerRepo.contains(descriptor));
  }
  
  public synchronized boolean contains(IArtifactKey key)
  {
    return (artifactMap.containsKey(key)) || (innerRepo.contains(key));
  }
  
  public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor)
  {
    return innerRepo.getArtifact(descriptor, destination, monitor);
  }
  
  public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor)
  {
    return innerRepo.getRawArtifact(descriptor, destination, monitor);
  }
  
  public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor)
  {
    return Status.OK_STATUS;
  }
  
  public OutputStream getOutputStream(IArtifactDescriptor descriptor)
  {
    return null;
  }
  
  /* Error */
  public final synchronized void removeAll(IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_1
    //   1: iconst_1
    //   2: invokestatic 339	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   5: astore_2
    //   6: aload_0
    //   7: getfield 325	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:descriptorsToAdd	Ljava/util/Set;
    //   10: aload_0
    //   11: getfield 325	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:descriptorsToAdd	Ljava/util/Set;
    //   14: invokeinterface 374 1 0
    //   19: anewarray 157	org/eclipse/equinox/p2/repository/artifact/IArtifactDescriptor
    //   22: invokeinterface 381 2 0
    //   27: checkcast 133	[Lorg/eclipse/equinox/p2/repository/artifact/IArtifactDescriptor;
    //   30: astore_3
    //   31: iconst_0
    //   32: istore 4
    //   34: goto +15 -> 49
    //   37: aload_0
    //   38: aload_3
    //   39: iload 4
    //   41: aaload
    //   42: invokespecial 345	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:doRemoveArtifact	(Lorg/eclipse/equinox/p2/repository/artifact/IArtifactDescriptor;)Z
    //   45: pop
    //   46: iinc 4 1
    //   49: iload 4
    //   51: aload_3
    //   52: arraylength
    //   53: if_icmplt -16 -> 37
    //   56: aload_2
    //   57: iconst_1
    //   58: invokevirtual 338	org/eclipse/core/runtime/SubMonitor:worked	(I)V
    //   61: goto +18 -> 79
    //   64: astore 5
    //   66: aload_1
    //   67: ifnull +9 -> 76
    //   70: aload_1
    //   71: invokeinterface 382 1 0
    //   76: aload 5
    //   78: athrow
    //   79: aload_1
    //   80: ifnull +9 -> 89
    //   83: aload_1
    //   84: invokeinterface 382 1 0
    //   89: return
    // Line number table:
    //   Java source line #170	-> byte code offset #0
    //   Java source line #171	-> byte code offset #6
    //   Java source line #172	-> byte code offset #31
    //   Java source line #173	-> byte code offset #37
    //   Java source line #172	-> byte code offset #46
    //   Java source line #174	-> byte code offset #56
    //   Java source line #175	-> byte code offset #64
    //   Java source line #176	-> byte code offset #66
    //   Java source line #177	-> byte code offset #70
    //   Java source line #178	-> byte code offset #76
    //   Java source line #176	-> byte code offset #79
    //   Java source line #177	-> byte code offset #83
    //   Java source line #179	-> byte code offset #89
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	90	0	this	CachingArtifactRepository
    //   0	90	1	monitor	IProgressMonitor
    //   5	52	2	subMonitor	org.eclipse.core.runtime.SubMonitor
    //   30	22	3	toRemove	IArtifactDescriptor[]
    //   32	18	4	i	int
    //   64	13	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	64	64	finally
  }
  
  @Deprecated
  public synchronized void removeAll()
  {
    removeAll(new NullProgressMonitor());
  }
  
  /* Error */
  public synchronized void removeDescriptor(IArtifactDescriptor descriptor, IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_2
    //   1: iconst_1
    //   2: invokestatic 339	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   5: astore_3
    //   6: aload_0
    //   7: aload_1
    //   8: invokespecial 345	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:doRemoveArtifact	(Lorg/eclipse/equinox/p2/repository/artifact/IArtifactDescriptor;)Z
    //   11: pop
    //   12: aload_3
    //   13: iconst_1
    //   14: invokevirtual 338	org/eclipse/core/runtime/SubMonitor:worked	(I)V
    //   17: goto +18 -> 35
    //   20: astore 4
    //   22: aload_2
    //   23: ifnull +9 -> 32
    //   26: aload_2
    //   27: invokeinterface 382 1 0
    //   32: aload 4
    //   34: athrow
    //   35: aload_2
    //   36: ifnull +9 -> 45
    //   39: aload_2
    //   40: invokeinterface 382 1 0
    //   45: return
    // Line number table:
    //   Java source line #188	-> byte code offset #0
    //   Java source line #189	-> byte code offset #6
    //   Java source line #190	-> byte code offset #12
    //   Java source line #191	-> byte code offset #20
    //   Java source line #192	-> byte code offset #22
    //   Java source line #193	-> byte code offset #26
    //   Java source line #194	-> byte code offset #32
    //   Java source line #192	-> byte code offset #35
    //   Java source line #193	-> byte code offset #39
    //   Java source line #195	-> byte code offset #45
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	46	0	this	CachingArtifactRepository
    //   0	46	1	descriptor	IArtifactDescriptor
    //   0	46	2	monitor	IProgressMonitor
    //   5	8	3	subMonitor	org.eclipse.core.runtime.SubMonitor
    //   20	13	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	20	20	finally
  }
  
  @Deprecated
  public final synchronized void removeDescriptor(IArtifactDescriptor descriptor)
  {
    removeDescriptor(descriptor, new NullProgressMonitor());
  }
  
  /* Error */
  public synchronized void removeDescriptor(IArtifactKey key, IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: invokevirtual 352	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:getArtifactDescriptors	(Lorg/eclipse/equinox/p2/metadata/IArtifactKey;)[Lorg/eclipse/equinox/p2/repository/artifact/IArtifactDescriptor;
    //   5: astore_3
    //   6: aload_2
    //   7: aload_3
    //   8: arraylength
    //   9: invokestatic 339	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   12: astore 4
    //   14: iconst_0
    //   15: istore 5
    //   17: goto +21 -> 38
    //   20: aload_0
    //   21: aload_3
    //   22: iload 5
    //   24: aaload
    //   25: invokespecial 345	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:doRemoveArtifact	(Lorg/eclipse/equinox/p2/repository/artifact/IArtifactDescriptor;)Z
    //   28: pop
    //   29: aload 4
    //   31: iconst_1
    //   32: invokevirtual 338	org/eclipse/core/runtime/SubMonitor:worked	(I)V
    //   35: iinc 5 1
    //   38: iload 5
    //   40: aload_3
    //   41: arraylength
    //   42: if_icmplt -22 -> 20
    //   45: goto +18 -> 63
    //   48: astore 6
    //   50: aload_2
    //   51: ifnull +9 -> 60
    //   54: aload_2
    //   55: invokeinterface 382 1 0
    //   60: aload 6
    //   62: athrow
    //   63: aload_2
    //   64: ifnull +9 -> 73
    //   67: aload_2
    //   68: invokeinterface 382 1 0
    //   73: return
    // Line number table:
    //   Java source line #204	-> byte code offset #0
    //   Java source line #205	-> byte code offset #6
    //   Java source line #206	-> byte code offset #14
    //   Java source line #207	-> byte code offset #20
    //   Java source line #208	-> byte code offset #29
    //   Java source line #206	-> byte code offset #35
    //   Java source line #210	-> byte code offset #48
    //   Java source line #211	-> byte code offset #50
    //   Java source line #212	-> byte code offset #54
    //   Java source line #213	-> byte code offset #60
    //   Java source line #211	-> byte code offset #63
    //   Java source line #212	-> byte code offset #67
    //   Java source line #214	-> byte code offset #73
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	74	0	this	CachingArtifactRepository
    //   0	74	1	key	IArtifactKey
    //   0	74	2	monitor	IProgressMonitor
    //   5	36	3	toRemove	IArtifactDescriptor[]
    //   12	18	4	subMonitor	org.eclipse.core.runtime.SubMonitor
    //   15	24	5	i	int
    //   48	13	6	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	48	48	finally
  }
  
  @Deprecated
  public final synchronized void removeDescriptor(IArtifactKey key)
  {
    removeDescriptor(key, new NullProgressMonitor());
  }
  
  /* Error */
  public synchronized void removeDescriptors(IArtifactDescriptor[] descriptors, IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_2
    //   1: aload_1
    //   2: arraylength
    //   3: invokestatic 339	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   6: astore_3
    //   7: aload_1
    //   8: dup
    //   9: astore 7
    //   11: arraylength
    //   12: istore 6
    //   14: iconst_0
    //   15: istore 5
    //   17: goto +25 -> 42
    //   20: aload 7
    //   22: iload 5
    //   24: aaload
    //   25: astore 4
    //   27: aload_0
    //   28: aload 4
    //   30: invokespecial 345	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:doRemoveArtifact	(Lorg/eclipse/equinox/p2/repository/artifact/IArtifactDescriptor;)Z
    //   33: pop
    //   34: aload_3
    //   35: iconst_1
    //   36: invokevirtual 338	org/eclipse/core/runtime/SubMonitor:worked	(I)V
    //   39: iinc 5 1
    //   42: iload 5
    //   44: iload 6
    //   46: if_icmplt -26 -> 20
    //   49: goto +18 -> 67
    //   52: astore 8
    //   54: aload_2
    //   55: ifnull +9 -> 64
    //   58: aload_2
    //   59: invokeinterface 382 1 0
    //   64: aload 8
    //   66: athrow
    //   67: aload_2
    //   68: ifnull +9 -> 77
    //   71: aload_2
    //   72: invokeinterface 382 1 0
    //   77: return
    // Line number table:
    //   Java source line #223	-> byte code offset #0
    //   Java source line #224	-> byte code offset #7
    //   Java source line #225	-> byte code offset #27
    //   Java source line #226	-> byte code offset #34
    //   Java source line #224	-> byte code offset #39
    //   Java source line #228	-> byte code offset #52
    //   Java source line #229	-> byte code offset #54
    //   Java source line #230	-> byte code offset #58
    //   Java source line #231	-> byte code offset #64
    //   Java source line #229	-> byte code offset #67
    //   Java source line #230	-> byte code offset #71
    //   Java source line #232	-> byte code offset #77
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	78	0	this	CachingArtifactRepository
    //   0	78	1	descriptors	IArtifactDescriptor[]
    //   0	78	2	monitor	IProgressMonitor
    //   6	29	3	subMonitor	org.eclipse.core.runtime.SubMonitor
    //   25	4	4	descriptor	IArtifactDescriptor
    //   15	32	5	i	int
    //   12	35	6	j	int
    //   9	12	7	arrayOfIArtifactDescriptor	IArtifactDescriptor[]
    //   52	13	8	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	52	52	finally
  }
  
  @Deprecated
  public final synchronized void removeDescriptors(IArtifactDescriptor[] descriptors)
  {
    removeDescriptors(descriptors, new NullProgressMonitor());
  }
  
  /* Error */
  public synchronized void removeDescriptors(IArtifactKey[] keys, IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_2
    //   1: aload_1
    //   2: arraylength
    //   3: invokestatic 339	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   6: astore_3
    //   7: aload_1
    //   8: dup
    //   9: astore 7
    //   11: arraylength
    //   12: istore 6
    //   14: iconst_0
    //   15: istore 5
    //   17: goto +24 -> 41
    //   20: aload 7
    //   22: iload 5
    //   24: aaload
    //   25: astore 4
    //   27: aload_0
    //   28: aload 4
    //   30: invokevirtual 342	org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository:removeDescriptor	(Lorg/eclipse/equinox/p2/metadata/IArtifactKey;)V
    //   33: aload_3
    //   34: iconst_1
    //   35: invokevirtual 338	org/eclipse/core/runtime/SubMonitor:worked	(I)V
    //   38: iinc 5 1
    //   41: iload 5
    //   43: iload 6
    //   45: if_icmplt -25 -> 20
    //   48: goto +18 -> 66
    //   51: astore 8
    //   53: aload_2
    //   54: ifnull +9 -> 63
    //   57: aload_2
    //   58: invokeinterface 382 1 0
    //   63: aload 8
    //   65: athrow
    //   66: aload_2
    //   67: ifnull +9 -> 76
    //   70: aload_2
    //   71: invokeinterface 382 1 0
    //   76: return
    // Line number table:
    //   Java source line #241	-> byte code offset #0
    //   Java source line #242	-> byte code offset #7
    //   Java source line #243	-> byte code offset #27
    //   Java source line #244	-> byte code offset #33
    //   Java source line #242	-> byte code offset #38
    //   Java source line #246	-> byte code offset #51
    //   Java source line #247	-> byte code offset #53
    //   Java source line #248	-> byte code offset #57
    //   Java source line #249	-> byte code offset #63
    //   Java source line #247	-> byte code offset #66
    //   Java source line #248	-> byte code offset #70
    //   Java source line #250	-> byte code offset #76
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	77	0	this	CachingArtifactRepository
    //   0	77	1	keys	IArtifactKey[]
    //   0	77	2	monitor	IProgressMonitor
    //   6	28	3	subMonitor	org.eclipse.core.runtime.SubMonitor
    //   25	4	4	key	IArtifactKey
    //   15	31	5	i	int
    //   12	34	6	j	int
    //   9	12	7	arrayOfIArtifactKey	IArtifactKey[]
    //   51	13	8	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	51	51	finally
  }
  
  @Deprecated
  public final synchronized void removeDescriptors(IArtifactKey[] keys)
  {
    removeDescriptors(keys, new NullProgressMonitor());
  }
  
  private boolean doRemoveArtifact(IArtifactDescriptor descriptor)
  {
    boolean result = descriptorsToAdd.remove(descriptor);
    if (result) {
      unmapDescriptor(descriptor);
    }
    descriptorsToRemove.add(descriptor);
    return result;
  }
  
  public String getDescription()
  {
    return innerRepo.getDescription();
  }
  
  public URI getLocation()
  {
    return innerRepo.getLocation();
  }
  
  public String getName()
  {
    return innerRepo.getName();
  }
  
  public Map<String, String> getProperties()
  {
    return innerRepo.getProperties();
  }
  
  public String getProperty(String key)
  {
    return innerRepo.getProperty(key);
  }
  
  public String getProvider()
  {
    return innerRepo.getProvider();
  }
  
  public IProvisioningAgent getProvisioningAgent()
  {
    return innerRepo.getProvisioningAgent();
  }
  
  public String getType()
  {
    return innerRepo.getType();
  }
  
  public String getVersion()
  {
    return innerRepo.getVersion();
  }
  
  public boolean isModifiable()
  {
    return innerRepo.isModifiable();
  }
  
  public String setProperty(String key, String value, IProgressMonitor monitor)
  {
    try
    {
      String result = (String)getProperties().get(key);
      propertyChanges.put(key, value == null ? "" : value);
      return result;
    }
    finally
    {
      if (monitor != null) {
        monitor.done();
      }
    }
  }
  
  public final String setProperty(String key, String value)
  {
    return setProperty(key, value, new NullProgressMonitor());
  }
  
  public Object getAdapter(Class adapter)
  {
    return innerRepo.getAdapter(adapter);
  }
  
  public File getArtifactFile(IArtifactKey key)
  {
    if ((innerRepo instanceof IFileArtifactRepository)) {
      return ((IFileArtifactRepository)innerRepo).getArtifactFile(key);
    }
    return null;
  }
  
  public File getArtifactFile(IArtifactDescriptor descriptor)
  {
    if ((innerRepo instanceof IFileArtifactRepository)) {
      return ((IFileArtifactRepository)innerRepo).getArtifactFile(descriptor);
    }
    return null;
  }
  
  public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key)
  {
    return innerRepo.createArtifactDescriptor(key);
  }
  
  public IArtifactKey createArtifactKey(String classifier, String id, Version version)
  {
    return innerRepo.createArtifactKey(classifier, id, version);
  }
  
  public IQueryable<IArtifactDescriptor> descriptorQueryable()
  {
    final Collection<List<IArtifactDescriptor>> descs = artifactMap.values();
    IQueryable<IArtifactDescriptor> cached = new IQueryable()
    {
      public IQueryResult<IArtifactDescriptor> query(IQuery<IArtifactDescriptor> query, IProgressMonitor monitor)
      {
        return query.perform(new CompoundIterator(descs.iterator()));
      }
    };
    return QueryUtil.compoundQueryable(cached, innerRepo.descriptorQueryable());
  }
  
  public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor)
  {
    final Iterator<IArtifactKey> keyIterator = artifactMap.keySet().iterator();
    IQueryable<IArtifactKey> cached = new IQueryable()
    {
      public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> q, IProgressMonitor mon)
      {
        return q.perform(keyIterator);
      }
    };
    IQueryable<IArtifactKey> compound = QueryUtil.compoundQueryable(cached, innerRepo);
    return compound.query(query, monitor);
  }
  
  public IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor)
  {
    try
    {
      runnable.run(monitor);
    }
    catch (OperationCanceledException oce)
    {
      return new Status(8, "org.eclipse.equinox.p2.directorywatcher", oce.getMessage(), oce);
    }
    catch (Exception e)
    {
      return new Status(4, "org.eclipse.equinox.p2.directorywatcher", e.getMessage(), e);
    }
    return Status.OK_STATUS;
  }
}

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

import java.io.File;

public abstract class DirectoryChangeListener
{
  public void startPoll() {}
  
  public void stopPoll() {}
  
  public boolean isInterested(File file)
  {
    return false;
  }
  
  public boolean added(File file)
  {
    return false;
  }
  
  public boolean removed(File file)
  {
    return false;
  }
  
  public boolean changed(File file)
  {
    return false;
  }
  
  public Long getSeenFile(File file)
  {
    return null;
  }
}

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

public class DirectoryWatcher$WatcherThread
  extends Thread
{
  private final long pollFrequency;
  private boolean done = false;
  final DirectoryWatcher this$0;
  
  public DirectoryWatcher$WatcherThread(DirectoryWatcher paramDirectoryWatcher, long pollFrequency)
  {
    super("Directory Watcher");
    this.pollFrequency = pollFrequency;
  }
  
  public void run()
  {
    do
    {
      try
      {
        this$0.poll();
        synchronized (this)
        {
          wait(pollFrequency);
        }
      }
      catch (InterruptedException localInterruptedException) {}catch (Throwable e)
      {
        DirectoryWatcher.log(Messages.error_main_loop, e);
        done = true;
      }
    } while (!
    
      done);
  }
  
  public synchronized void done()
  {
    done = true;
    notify();
  }
}

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

import java.io.File;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;

public class DirectoryWatcher
{
  private static final String DEL_EXT = ".del";
  public static final String POLL = "eclipse.p2.directory.watcher.poll";
  public static final String DIR = "eclipse.p2.directory.watcher.dir";
  private static final long DEFAULT_POLL_FREQUENCY = 2000L;
  final File[] directories;
  
  public class WatcherThread
    extends Thread
  {
    private final long pollFrequency;
    private boolean done = false;
    
    public WatcherThread(long pollFrequency)
    {
      super();
      this.pollFrequency = pollFrequency;
    }
    
    public void run()
    {
      do
      {
        try
        {
          poll();
          synchronized (this)
          {
            wait(pollFrequency);
          }
        }
        catch (InterruptedException localInterruptedException) {}catch (Throwable e)
        {
          DirectoryWatcher.log(Messages.error_main_loop, e);
          done = true;
        }
      } while (!
      
        done);
    }
    
    public synchronized void done()
    {
      done = true;
      notify();
    }
  }
  
  public static void log(String string, Throwable e)
  {
    System.err.println(string + ": " + e);
  }
  
  long poll = 2000L;
  private Set<DirectoryChangeListener> listeners = new HashSet();
  private HashSet<File> scannedFiles = new HashSet();
  private HashSet<File> removals;
  private Set<File> pendingDeletions;
  private WatcherThread watcher;
  
  public DirectoryWatcher(Map<String, String> properties, BundleContext context)
  {
    String dir = (String)properties.get("eclipse.p2.directory.watcher.dir");
    if (dir == null) {
      dir = "./load";
    }
    File targetDirectory = new File(dir);
    targetDirectory.mkdirs();
    directories = new File[] { targetDirectory };
  }
  
  public DirectoryWatcher(File directory)
  {
    if (directory == null) {
      throw new IllegalArgumentException(Messages.null_folder);
    }
    directories = new File[] { directory };
  }
  
  public DirectoryWatcher(File[] directories)
  {
    if (directories == null) {
      throw new IllegalArgumentException(Messages.null_folder);
    }
    this.directories = directories;
  }
  
  public synchronized void addListener(DirectoryChangeListener listener)
  {
    listeners.add(listener);
  }
  
  public synchronized void removeListener(DirectoryChangeListener listener)
  {
    listeners.remove(listener);
  }
  
  public void start()
  {
    start(2000L);
  }
  
  public synchronized void poll()
  {
    startPoll();
    scanDirectories();
    stopPoll();
  }
  
  public synchronized void start(long pollFrequency)
  {
    if (watcher != null) {
      throw new IllegalStateException(Messages.thread_started);
    }
    watcher = new WatcherThread(pollFrequency);
    watcher.start();
  }
  
  public synchronized void stop()
  {
    if (watcher == null) {
      throw new IllegalStateException(Messages.thread_not_started);
    }
    watcher.done();
    watcher = null;
  }
  
  public File[] getDirectories()
  {
    return directories;
  }
  
  private void startPoll()
  {
    removals = scannedFiles;
    scannedFiles = new HashSet();
    pendingDeletions = new HashSet();
    for (Iterator localIterator = listeners.iterator(); localIterator.hasNext();)
    {
      DirectoryChangeListener listener = (DirectoryChangeListener)localIterator.next();
      listener.startPoll();
    }
  }
  
  private void scanDirectories()
  {
    for (int index = 0; index < directories.length; index++)
    {
      File directory = directories[index];
   
1 2

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