org.eclipse.osgi_3.7.2.v20120110-1415

work.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.SynchronousBundleListener;

final class BundleTracker$Tracked
  extends AbstractTracked<Bundle, T, BundleEvent>
  implements SynchronousBundleListener
{
  final BundleTracker this$0;
  
  BundleTracker$Tracked(BundleTracker paramBundleTracker) {}
  
  public void bundleChanged(BundleEvent event)
  {
    if (closed) {
      return;
    }
    Bundle bundle = event.getBundle();
    int state = bundle.getState();
    if ((state & this$0.mask) != 0) {
      track(bundle, event);
    } else {
      untrack(bundle, event);
    }
  }
  
  T customizerAdding(Bundle item, BundleEvent related)
  {
    return (T)this$0.customizer.addingBundle(item, related);
  }
  
  void customizerModified(Bundle item, BundleEvent related, T object)
  {
    this$0.customizer.modifiedBundle(item, related, object);
  }
  
  void customizerRemoved(Bundle item, BundleEvent related, T object)
  {
    this$0.customizer.removedBundle(item, related, object);
  }
}

/* Location:
 * Qualified Name:     org.osgi.util.tracker.BundleTracker.Tracked
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.util.tracker;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.SynchronousBundleListener;

public class BundleTracker<T>
  implements BundleTrackerCustomizer<T>
{
  static final boolean DEBUG = false;
  protected final BundleContext context;
  final BundleTrackerCustomizer<T> customizer;
  private volatile BundleTracker<T>.Tracked tracked;
  final int mask;
  
  private BundleTracker<T>.Tracked tracked()
  {
    return tracked;
  }
  
  public BundleTracker(BundleContext context, int stateMask, BundleTrackerCustomizer<T> customizer)
  {
    this.context = context;
    mask = stateMask;
    this.customizer = (customizer == null ? this : customizer);
  }
  
  public void open()
  {
    synchronized (this)
    {
      if (tracked != null) {
        return;
      }
      BundleTracker<T>.Tracked t = new Tracked();
      synchronized (t)
      {
        context.addBundleListener(t);
        Bundle[] bundles = context.getBundles();
        if (bundles != null)
        {
          int length = bundles.length;
          for (int i = 0; i < length; i++)
          {
            int state = bundles[i].getState();
            if ((state & mask) == 0) {
              bundles[i] = null;
            }
          }
          t.setInitial(bundles);
        }
      }
      tracked = t;
    }
    BundleTracker<T>.Tracked t;
    t.trackInitial();
  }
  
  public void close()
  {
    synchronized (this)
    {
      BundleTracker<T>.Tracked outgoing = tracked;
      if (outgoing == null) {
        return;
      }
      outgoing.close();
      Bundle[] bundles = getBundles();
      tracked = null;
      try
      {
        context.removeBundleListener(outgoing);
      }
      catch (IllegalStateException localIllegalStateException) {}
    }
    BundleTracker<T>.Tracked outgoing;
    Bundle[] bundles;
    if (bundles != null) {
      for (int i = 0; i < bundles.length; i++) {
        outgoing.untrack(bundles[i], null);
      }
    }
  }
  
  public T addingBundle(Bundle bundle, BundleEvent event)
  {
    T result = bundle;
    return result;
  }
  
  public void modifiedBundle(Bundle bundle, BundleEvent event, T object) {}
  
  public void removedBundle(Bundle bundle, BundleEvent event, T object) {}
  
  public Bundle[] getBundles()
  {
    BundleTracker<T>.Tracked t = tracked();
    if (t == null) {
      return null;
    }
    synchronized (t)
    {
      int length = t.size();
      if (length == 0) {
        return null;
      }
      return (Bundle[])t.copyKeys(new Bundle[length]);
    }
  }
  
  /* Error */
  public T getObject(Bundle bundle)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 128	org/osgi/util/tracker/BundleTracker:tracked	()Lorg/osgi/util/tracker/BundleTracker$Tracked;
    //   4: astore_2
    //   5: aload_2
    //   6: ifnonnull +5 -> 11
    //   9: aconst_null
    //   10: areturn
    //   11: aload_2
    //   12: dup
    //   13: astore_3
    //   14: monitorenter
    //   15: aload_2
    //   16: aload_1
    //   17: invokevirtual 136	org/osgi/util/tracker/BundleTracker$Tracked:getCustomizedObject	(Ljava/lang/Object;)Ljava/lang/Object;
    //   20: aload_3
    //   21: monitorexit
    //   22: areturn
    //   23: aload_3
    //   24: monitorexit
    //   25: athrow
    // Line number table:
    //   Java source line #308	-> byte code offset #0
    //   Java source line #309	-> byte code offset #5
    //   Java source line #310	-> byte code offset #9
    //   Java source line #312	-> byte code offset #11
    //   Java source line #313	-> byte code offset #15
    //   Java source line #312	-> byte code offset #23
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	26	0	this	BundleTracker<T>
    //   0	26	1	bundle	Bundle
    //   4	12	2	t	BundleTracker<T>.Tracked
    //   13	11	3	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   15	22	23	finally
    //   23	25	23	finally
  }
  
  public void remove(Bundle bundle)
  {
    BundleTracker<T>.Tracked t = tracked();
    if (t == null) {
      return;
    }
    t.untrack(bundle, null);
  }
  
  /* Error */
  public int size()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 128	org/osgi/util/tracker/BundleTracker:tracked	()Lorg/osgi/util/tracker/BundleTracker$Tracked;
    //   4: astore_1
    //   5: aload_1
    //   6: ifnonnull +5 -> 11
    //   9: iconst_0
    //   10: ireturn
    //   11: aload_1
    //   12: dup
    //   13: astore_2
    //   14: monitorenter
    //   15: aload_1
    //   16: invokevirtual 130	org/osgi/util/tracker/BundleTracker$Tracked:size	()I
    //   19: aload_2
    //   20: monitorexit
    //   21: ireturn
    //   22: aload_2
    //   23: monitorexit
    //   24: athrow
    // Line number table:
    //   Java source line #342	-> byte code offset #0
    //   Java source line #343	-> byte code offset #5
    //   Java source line #344	-> byte code offset #9
    //   Java source line #346	-> byte code offset #11
    //   Java source line #347	-> byte code offset #15
    //   Java source line #346	-> byte code offset #22
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	25	0	this	BundleTracker<T>
    //   4	12	1	t	BundleTracker<T>.Tracked
    //   13	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   15	21	22	finally
    //   22	24	22	finally
  }
  
  /* Error */
  public int getTrackingCount()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 128	org/osgi/util/tracker/BundleTracker:tracked	()Lorg/osgi/util/tracker/BundleTracker$Tracked;
    //   4: astore_1
    //   5: aload_1
    //   6: ifnonnull +5 -> 11
    //   9: iconst_m1
    //   10: ireturn
    //   11: aload_1
    //   12: dup
    //   13: astore_2
    //   14: monitorenter
    //   15: aload_1
    //   16: invokevirtual 129	org/osgi/util/tracker/BundleTracker$Tracked:getTrackingCount	()I
    //   19: aload_2
    //   20: monitorexit
    //   21: ireturn
    //   22: aload_2
    //   23: monitorexit
    //   24: athrow
    // Line number table:
    //   Java source line #370	-> byte code offset #0
    //   Java source line #371	-> byte code offset #5
    //   Java source line #372	-> byte code offset #9
    //   Java source line #374	-> byte code offset #11
    //   Java source line #375	-> byte code offset #15
    //   Java source line #374	-> byte code offset #22
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	25	0	this	BundleTracker<T>
    //   4	12	1	t	BundleTracker<T>.Tracked
    //   13	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   15	21	22	finally
    //   22	24	22	finally
  }
  
  /* Error */
  public java.util.Map<Bundle, T> getTracked()
  {
    // Byte code:
    //   0: new 60	java/util/HashMap
    //   3: dup
    //   4: invokespecial 126	java/util/HashMap:<init>	()V
    //   7: astore_1
    //   8: aload_0
    //   9: invokespecial 128	org/osgi/util/tracker/BundleTracker:tracked	()Lorg/osgi/util/tracker/BundleTracker$Tracked;
    //   12: astore_2
    //   13: aload_2
    //   14: ifnonnull +5 -> 19
    //   17: aload_1
    //   18: areturn
    //   19: aload_2
    //   20: dup
    //   21: astore_3
    //   22: monitorenter
    //   23: aload_2
    //   24: aload_1
    //   25: invokevirtual 139	org/osgi/util/tracker/BundleTracker$Tracked:copyEntries	(Ljava/util/Map;)Ljava/util/Map;
    //   28: aload_3
    //   29: monitorexit
    //   30: areturn
    //   31: aload_3
    //   32: monitorexit
    //   33: athrow
    // Line number table:
    //   Java source line #390	-> byte code offset #0
    //   Java source line #391	-> byte code offset #8
    //   Java source line #392	-> byte code offset #13
    //   Java source line #393	-> byte code offset #17
    //   Java source line #395	-> byte code offset #19
    //   Java source line #396	-> byte code offset #23
    //   Java source line #395	-> byte code offset #31
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	34	0	this	BundleTracker<T>
    //   7	18	1	map	java.util.Map<Bundle, T>
    //   12	12	2	t	BundleTracker<T>.Tracked
    //   21	11	3	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   23	30	31	finally
    //   31	33	31	finally
  }
  
  /* Error */
  public boolean isEmpty()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 128	org/osgi/util/tracker/BundleTracker:tracked	()Lorg/osgi/util/tracker/BundleTracker$Tracked;
    //   4: astore_1
    //   5: aload_1
    //   6: ifnonnull +5 -> 11
    //   9: iconst_1
    //   10: ireturn
    //   11: aload_1
    //   12: dup
    //   13: astore_2
    //   14: monitorenter
    //   15: aload_1
    //   16: invokevirtual 133	org/osgi/util/tracker/BundleTracker$Tracked:isEmpty	()Z
    //   19: aload_2
    //   20: monitorexit
    //   21: ireturn
    //   22: aload_2
    //   23: monitorexit
    //   24: athrow
    // Line number table:
    //   Java source line #408	-> byte code offset #0
    //   Java source line #409	-> byte code offset #5
    //   Java source line #410	-> byte code offset #9
    //   Java source line #412	-> byte code offset #11
    //   Java source line #413	-> byte code offset #15
    //   Java source line #412	-> byte code offset #22
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	25	0	this	BundleTracker<T>
    //   4	12	1	t	BundleTracker<T>.Tracked
    //   13	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   15	21	22	finally
    //   22	24	22	finally
  }
  
  private final class Tracked
    extends AbstractTracked<Bundle, T, BundleEvent>
    implements SynchronousBundleListener
  {
    Tracked() {}
    
    public void bundleChanged(BundleEvent event)
    {
      if (closed) {
        return;
      }
      Bundle bundle = event.getBundle();
      int state = bundle.getState();
      if ((state & mask) != 0) {
        track(bundle, event);
      } else {
        untrack(bundle, event);
      }
    }
    
    T customizerAdding(Bundle item, BundleEvent related)
    {
      return (T)customizer.addingBundle(item, related);
    }
    
    void customizerModified(Bundle item, BundleEvent related, T object)
    {
      customizer.modifiedBundle(item, related, object);
    }
    
    void customizerRemoved(Bundle item, BundleEvent related, T object)
    {
      customizer.removedBundle(item, related, object);
    }
  }
}

/* Location:
 * Qualified Name:     org.osgi.util.tracker.BundleTracker
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.util.tracker;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;

public abstract interface BundleTrackerCustomizer<T>
{
  public abstract T addingBundle(Bundle paramBundle, BundleEvent paramBundleEvent);
  
  public abstract void modifiedBundle(Bundle paramBundle, BundleEvent paramBundleEvent, T paramT);
  
  public abstract void removedBundle(Bundle paramBundle, BundleEvent paramBundleEvent, T paramT);
}

/* Location:
 * Qualified Name:     org.osgi.util.tracker.BundleTrackerCustomizer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.util.tracker;

import org.osgi.framework.AllServiceListener;

class ServiceTracker$AllTracked
  extends ServiceTracker<S, T>.Tracked
  implements AllServiceListener
{
  final ServiceTracker this$0;
  
  ServiceTracker$AllTracked(ServiceTracker paramServiceTracker)
  {
    super(paramServiceTracker);
  }
}

/* Location:
 * Qualified Name:     org.osgi.util.tracker.ServiceTracker.AllTracked
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.util.tracker;

import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;

class ServiceTracker$Tracked
  extends AbstractTracked<ServiceReference<S>, T, ServiceEvent>
  implements ServiceListener
{
  final ServiceTracker this$0;
  
  ServiceTracker$Tracked(ServiceTracker paramServiceTracker) {}
  
  public final void serviceChanged(ServiceEvent event)
  {
    if (closed) {
      return;
    }
    ServiceReference<S> reference = event
      .getServiceReference();
    switch (event.getType())
    {
    case 1: 
    case 2: 
      track(reference, event);
      
      break;
    case 4: 
    case 8: 
      untrack(reference, event);
    }
  }
  
  final void modified()
  {
    super.modified();
    this$0.modified();
  }
  
  final T customizerAdding(ServiceReference<S> item, ServiceEvent related)
  {
    return (T)this$0.customizer.addingService(item);
  }
  
  final void customizerModified(ServiceReference<S> item, ServiceEvent related, T object)
  {
    this$0.customizer.modifiedService(item, object);
  }
  
  final void customizerRemoved(ServiceReference<S> item, ServiceEvent related, T object)
  {
    this$0.customizer.removedService(item, object);
  }
}

/* Location:
 * Qualified Name:     org.osgi.util.tracker.ServiceTracker.Tracked
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.util.tracker;

import java.lang.reflect.Array;
import org.osgi.framework.AllServiceListener;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;

public class ServiceTracker<S, T>
  implements ServiceTrackerCustomizer<S, T>
{
  static final boolean DEBUG = false;
  protected final BundleContext context;
  protected final Filter filter;
  final ServiceTrackerCustomizer<S, T> customizer;
  final String listenerFilter;
  private final String trackClass;
  private final ServiceReference<S> trackReference;
  private volatile ServiceTracker<S, T>.Tracked tracked;
  private volatile ServiceReference<S> cachedReference;
  private volatile T cachedService;
  
  private ServiceTracker<S, T>.Tracked tracked()
  {
    return tracked;
  }
  
  public ServiceTracker(BundleContext context, ServiceReference<S> reference, ServiceTrackerCustomizer<S, T> customizer)
  {
    this.context = context;
    trackReference = reference;
    trackClass = null;
    this.customizer = (customizer == null ? this : customizer);
    listenerFilter = 
      ("(service.id=" + reference.getProperty("service.id").toString() + ")");
    try
    {
      filter = context.createFilter(listenerFilter);
    }
    catch (InvalidSyntaxException e)
    {
      IllegalArgumentException iae = new IllegalArgumentException(
        "unexpected InvalidSyntaxException: " + e.getMessage());
      iae.initCause(e);
      throw iae;
    }
  }
  
  public ServiceTracker(BundleContext context, String clazz, ServiceTrackerCustomizer<S, T> customizer)
  {
    this.context = context;
    trackReference = null;
    trackClass = clazz;
    this.customizer = (customizer == null ? this : customizer);
    
    listenerFilter = 
      ("(objectClass=" + clazz.toString() + ")");
    try
    {
      filter = context.createFilter(listenerFilter);
    }
    catch (InvalidSyntaxException e)
    {
      IllegalArgumentException iae = new IllegalArgumentException(
        "unexpected InvalidSyntaxException: " + e.getMessage());
      iae.initCause(e);
      throw iae;
    }
  }
  
  public ServiceTracker(BundleContext context, Filter filter, ServiceTrackerCustomizer<S, T> customizer)
  {
    this.context = context;
    trackReference = null;
    trackClass = null;
    listenerFilter = filter.toString();
    this.filter = filter;
    this.customizer = (customizer == null ? this : customizer);
    if ((context == null) || (filter == null)) {
      throw new NullPointerException();
    }
  }
  
  public ServiceTracker(BundleContext context, Class<S> clazz, ServiceTrackerCustomizer<S, T> customizer)
  {
    this(context, clazz.getName(), customizer);
  }
  
  public void open()
  {
    open(false);
  }
  
  public void open(boolean trackAllServices)
  {
    synchronized (this)
    {
      if (tracked != null) {
        return;
      }
      ServiceTracker<S, T>.Tracked t = trackAllServices ? new AllTracked() : new Tracked();
      synchronized (t)
      {
        try
        {
          context.addServiceListener(t, listenerFilter);
          ServiceReference[] references = (ServiceReference[])null;
          if (trackClass != null) {
            references = getInitialReferences(trackAllServices, 
              trackClass, null);
          } else if (trackReference != null)
          {
            if (trackReference.getBundle() != null)
            {
              ServiceReference[] single = { trackReference };
              references = single;
            }
          }
          else {
            references = getInitialReferences(trackAllServices, 
              null, listenerFilter);
          }
          t.setInitial(references);
        }
        catch (InvalidSyntaxException e)
        {
          throw new RuntimeException(
            "unexpected InvalidSyntaxException: " + 
            e.getMessage(), e);
        }
      }
      tracked = t;
    }
    ServiceTracker<S, T>.Tracked t;
    t.trackInitial();
  }
  
  private ServiceReference<S>[] getInitialReferences(boolean trackAllServices, String className, String filterString)
    throws InvalidSyntaxException
  {
    ServiceReference[] result = trackAllServices ? context
      .getAllServiceReferences(className, filterString) : 
      context.getServiceReferences(className, filterString);
    return result;
  }
  
  public void close()
  {
    synchronized (this)
    {
      ServiceTracker<S, T>.Tracked outgoing = tracked;
      if (outgoing == null) {
        return;
      }
      outgoing.close();
      ServiceReference[] references = getServiceReferences();
      tracked = null;
      try
      {
        context.removeServiceListener(outgoing);
      }
      catch (IllegalStateException localIllegalStateException) {}
    }
    ServiceReference[] references;
    ServiceTracker<S, T>.Tracked outgoing;
    modified();
    synchronized (outgoing)
    {
      outgoing.notifyAll();
    }
    if (references != null) {
      for (int i = 0; i < references.length; i++) {
        outgoing.untrack(references[i], null);
      }
    }
  }
  
  public T addingService(ServiceReference<S> reference)
  {
    T result = context.getService(reference);
    return result;
  }
  
  public void modifiedService(ServiceReference<S> reference, T service) {}
  
  public void removedService(ServiceReference<S> reference, T service)
  {
    context.ungetService(reference);
  }
  
  public T waitForService(long timeout)
    throws InterruptedException
  {
    if (timeout < 0L) {
      throw new IllegalArgumentException("timeout value is negative");
    }
    T object = getService();
    while (object == null)
    {
      ServiceTracker<S, T>.Tracked t = tracked();
      if (t == null) {
        return null;
      }
      synchronized (t)
      {
        if (t.size() == 0) {
          t.wait(timeout);
        }
      }
      object = getService();
      if (timeout > 0L) {
        return object;
      }
    }
    return object;
  }
  
  public ServiceReference<S>[] getServiceReferences()
  {
    ServiceTracker<S, T>.Tracked t = tracked();
    if (t == null) {
      return null;
    }
    synchronized (t)
    {
      int length = t.size();
      if (length == 0) {
        return null;
      }
      ServiceReference[] result = new ServiceReference[length];
      return (ServiceReference[])t.copyKeys(result);
    }
  }
  
  public ServiceReference<S> getServiceReference()
  {
    ServiceReference<S> reference = cachedReference;
    if (reference != null) {
      return reference;
    }
    ServiceReference[] references = getServiceReferences();
    int length = references == null ? 0 : references.length;
    if (length == 0) {
      return null;
    }
    int index = 0;
    if (length > 1)
    {
      int[] rankings = new int[length];
      int count = 0;
      int maxRanking = Integer.MIN_VALUE;
      for (int i = 0; i < length; i++)
      {
        Object property = references[i]
          .getProperty("service.ranking");
        int ranking = (property instanceof Integer) ? ((Integer)property)
          .intValue() : 
          0;
        rankings[i] = ranking;
        if (ranking > maxRanking)
        {
          index = i;
          maxRanking = ranking;
          count = 1;
        }
        else if (ranking == maxRanking)
        {
          count++;
        }
      }
      if (count > 1)
      {
        long minId = Long.MAX_VALUE;
        for (int i = 0; i < length; i++) {
          if (rankings[i] == maxRanking)
          {
            long id = ((Long)references[i]
              .getProperty("service.id"))
              .longValue();
            if (id < minId)
            {
              index = i;
              minId = id;
            }
          }
        }
      }
    }
    return cachedReference = references[index];
  }
  
  /* Error */
  public T getService(ServiceReference<S> reference)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 323	org/osgi/util/tracker/ServiceTracker:tracked	()Lorg/osgi/util/tracker/ServiceTracker$Tracked;
    //   4: astore_2
    //   5: aload_2
    //   6: ifnonnull +5 -> 11
    //   9: aconst_null
    //   10: areturn
    //   11: aload_2
    //   12: dup
    //   13: astore_3
    //   14: monitorenter
    //   15: aload_2
    //   16: aload_1
    //   17: invokevirtual 335	org/osgi/util/tracker/ServiceTracker$Tracked:getCustomizedObject	(Ljava/lang/Object;)Ljava/lang/Object;
    //   20: aload_3
    //   21: monitorexit
    //   22: areturn
    //   23: aload_3
    //   24: monitorexit
    //   25: athrow
    // Line number table:
    //   Java source line #655	-> byte code offset #0
    //   Java source line #656	-> byte code offset #5
    //   Java source line #657	-> byte code offset #9
    //   Java source line #659	-> byte code offset #11
    //   Java source line #660	-> byte code offset #15
    //   Java source line #659	-> byte code offset #23
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	26	0	this	ServiceTracker<S, T>
    //   0	26	1	reference	ServiceReference<S>
    //   4	12	2	t	ServiceTracker<S, T>.Tracked
    //   13	11	3	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   15	22	23	finally
    //   23	25	23	finally
  }
  
  public Object[] getServices()
  {
    ServiceTracker<S, T>.Tracked t = tracked();
    if (t == null) {
      return null;
    }
    synchronized (t)
    {
      ServiceReference[] references = getServiceReferences();
      int length = references == null ? 0 : references.length;
      if (length == 0) {
        return null;
      }
      Object[] objects = new Object[length];
      for (int i = 0; i < length; i++) {
        objects[i] = getService(references[i]);
      }
      return objects;
    }
  }
  
  public T getService()
  {
    T service = cachedService;
    if (service != null) {
      return service;
    }
    ServiceReference<S> reference = getServiceReference();
    if (reference == null) {
      return null;
    }
    return (T)(cachedService = getService(reference));
  }
  
  public void remove(ServiceReference<S> reference)
  {
    ServiceTracker<S, T>.Tracked t = tracked();
    if (t == null) {
      return;
    }
    t.untrack(reference, null);
  }
  
  /* Error */
  public int size()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 323	org/osgi/util/tracker/ServiceTracker:tracked	()Lorg/osgi/util/tracker/ServiceTracker$Tracked;
    //   4: astore_1
    //   5: aload_1
    //   6: ifnonnull +5 -> 11
    //   9: iconst_0
    //   10: ireturn
    //   11: aload_1
    //   12: dup
    //   13: astore_2
    //   14: monitorenter
    //   15: aload_1
    //   16: invokevirtual 329	org/osgi/util/tracker/ServiceTracker$Tracked:size	()I
    //   19: aload_2
    //   20: monitorexit
    //   21: ireturn
    //   22: aload_2
    //   23: monitorexit
    //   24: athrow
    // Line number table:
    //   Java source line #751	-> byte code offset #0
    //   Java source line #752	-> byte code offset #5
    //   Java source line #753	-> byte code offset #9
    //   Java source line #755	-> byte code offset #11
    //   Java source line #756	-> byte code offset #15
    //   Java source line #755	-> byte code offset #22
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	25	0	this	ServiceTracker<S, T>
    //   4	12	1	t	ServiceTracker<S, T>.Tracked
    //   13	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   15	21	22	finally
    //   22	24	22	finally
  }
  
  /* Error */
  public int getTrackingCount()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 323	org/osgi/util/tracker/ServiceTracker:tracked	()Lorg/osgi/util/tracker/ServiceTracker$Tracked;
    //   4: astore_1
    //   5: aload_1
    //   6: ifnonnull +5 -> 11
    //   9: iconst_m1
    //   10: ireturn
    //   11: aload_1
    //   12: dup
    //   13: astore_2
    //   14: monitorenter
    //   15: aload_1
    //   16: invokevirtual 328	org/osgi/util/tracker/ServiceTracker$Tracked:getTrackingCount	()I
    //   19: aload_2
    //   20: monitorexit
    //   21: ireturn
    //   22: aload_2
    //   23: monitorexit
    //   24: athrow
    // Line number table:
    //   Java source line #780	-> byte code offset #0
    //   Java source line #781	-> byte code offset #5
    //   Java source line #782	-> byte code offset #9
    //   Java source line #784	-> byte code offset #11
    //   Java source line #785	-> byte code offset #15
    //   Java source line #784	-> byte code offset #22
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	25	0	this	ServiceTracker<S, T>
    //   4	12	1	t	ServiceTracker<S, T>.Tracked
    //   13	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   15	21	22	finally
    //   22	24	22	finally
  }
  
  void modified()
  {
    cachedReference = null;
    cachedService = null;
  }
  
  /* Error */
  public java.util.SortedMap<ServiceReference<S>, T> getTracked()
  {
    // Byte code:
    //   0: new 157	java/util/TreeMap
    //   3: dup
    //   4: invokestatic 315	java/util/Collections:reverseOrder	()Ljava/util/Comparator;
    //   7: invokespecial 316	java/util/TreeMap:<init>	(Ljava/util/Comparator;)V
    //   10: astore_1
    //   11: aload_0
    //   12: invokespecial 323	org/osgi/util/tracker/ServiceTracker:tracked	()Lorg/osgi/util/tracker/ServiceTracker$Tracked;
    //   15: astore_2
    //   16: aload_2
    //   17: ifnonnull +5 -> 22
    //   20: aload_1
    //   21: areturn
    //   22: aload_2
    //   23: dup
    //   24: astore_3
    //   25: monitorenter
    //   26: aload_2
    //   27: aload_1
    //   28: invokevirtual 338	org/osgi/util/tracker/ServiceTracker$Tracked:copyEntries	(Ljava/util/Map;)Ljava/util/Map;
    //   31: checkcast 156	java/util/SortedMap
    //   34: aload_3
    //   35: monitorexit
    //   36: areturn
    //   37: aload_3
    //   38: monitorexit
    //   39: athrow
    // Line number table:
    //   Java source line #820	-> byte code offset #0
    //   Java source line #821	-> byte code offset #4
    //   Java source line #820	-> byte code offset #7
    //   Java source line #822	-> byte code offset #11
    //   Java source line #823	-> byte code offset #16
    //   Java source line #824	-> byte code offset #20
    //   Java source line #826	-> byte code offset #22
    //   Java source line #827	-> byte code offset #26
    //   Java source line #826	-> byte code offset #37
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	40	0	this	ServiceTracker<S, T>
    //   10	18	1	map	java.util.SortedMap<ServiceReference<S>, T>
    //   15	12	2	t	ServiceTracker<S, T>.Tracked
    //   24	14	3	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   26	36	37	finally
    //   37	39	37	finally
  }
  
  /* Error */
  public boolean isEmpty()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 323	org/osgi/util/tracker/ServiceTracker:tracked	()Lorg/osgi/util/tracker/ServiceTracker$Tracked;
    //   4: astore_1
    //   5: aload_1
    //   6: ifnonnull +5 -> 11
    //   9: iconst_1
    //   10: ireturn
    //   11: aload_1
    //   12: dup
    //   13: astore_2
    //   14: monitorenter
    //   15: aload_1
    //   16: invokevirtual 332	org/osgi/util/tracker/ServiceTracker$Tracked:isEmpty	()Z
    //   19: aload_2
    //   20: monitorexit
    //   21: ireturn
    //   22: aload_2
    //   23: monitorexit
    //   24: athrow
    // Line number table:
    //   Java source line #839	-> byte code offset #0
    //   Java source line #840	-> byte code offset #5
    //   Java source line #841	-> byte code offset #9
    //   Java source line #843	-> byte code offset #11
    //   Java source line #844	-> byte code offset #15
    //   Java source line #843	-> byte code offset #22
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	25	0	this	ServiceTracker<S, T>
    //   4	12	1	t	ServiceTracker<S, T>.Tracked
    //   13	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   15	21	22	finally
    //   22	24	22	finally
  }
  
  public T[] getServices(T[] array)
  {
    ServiceTracker<S, T>.Tracked t = tracked();
    if (t == null)
    {
      if (array.length > 0) {
        array[0] = null;
      }
      return array;
    }
    synchronized (t)
    {
      ServiceReference[] references = getServiceReferences();
      int length = references == null ? 0 : references.length;
      if (length == 0)
      {
        if (array.length > 0) {
          array[0] = null;
        }
        return array;
      }
      if (length > array.length) {
        array = (Object[])Array.newInstance(array.getClass()
          .getComponentType(), length);
      }
      for (int i = 0; i < length; i++) {
        array[i] = getService(references[i]);
      }
      if (array.length > length) {
        array[length] = null;
      }
      return array;
    }
  }
  
  private class Tracked
    extends AbstractTracked<ServiceReference<S>, T, ServiceEvent>
    implements ServiceListener
  {
    Tracked() {}
    
    public final void serviceChanged(ServiceEvent event)
    {
      if (closed) {
        return;
      }
      ServiceReference<S> reference = event
        .getServiceReference();
      switch (event.getType())
      {
      case 1: 
      case 2: 
        track(reference, event);
        
        break;
      case 4: 
      case 8: 
        untrack(reference, event);
      }
    }
    
    final void modified()
    {
      super.modified();
      ServiceTracker.this.modified();
    }
    
    final T customizerAdding(ServiceReference<S> item, ServiceEvent related)
    {
      return (T)customizer.addingService(item);
    }
    
    final void customizerModified(ServiceReference<S> item, ServiceEvent related, T object)
    {
      customizer.modifiedService(item, object);
    }
    
    final void customizerRemoved(ServiceReference<S> item, ServiceEvent related, T object)
    {
      customizer.removedService(item, object);
    }
  }
  
  private class AllTracked
    extends ServiceTracker<S, T>.Tracked
    implements AllServiceListener
  {
    AllTracked()
    {
      super();
    }
  }
}

/* Location:
 * Qualified Name:     org.osgi.util.tracker.ServiceTracker
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.osgi.util.tracker;

import org.osgi.framework.ServiceReference;

public abstract interface ServiceTrackerCustomizer<S, T>
{
  public abstract T addingService(ServiceReference<S> paramServiceReference);
  
  public abstract void modifiedService(ServiceReference<S> paramServiceReference, T paramT);
  
  public abstract void removedService(ServiceReference<S> paramServiceReference, T paramT);
}

/* Location:
 * Qualified Name:     org.osgi.util.tracker.ServiceTrackerCustomizer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

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