org.eclipse.osgi_3.7.2.v20120110-1415

    throws java.lang.Exception
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 53	org/eclipse/osgi/framework/internal/core/BundleContextImpl$2:this$0	Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;
    //   4: getfield 52	org/eclipse/osgi/framework/internal/core/BundleContextImpl:activator	Lorg/osgi/framework/BundleActivator;
    //   7: ifnull +67 -> 74
    //   10: aload_0
    //   11: getfield 53	org/eclipse/osgi/framework/internal/core/BundleContextImpl$2:this$0	Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;
    //   14: invokevirtual 57	org/eclipse/osgi/framework/internal/core/BundleContextImpl:setContextFinder	()Ljava/lang/Object;
    //   17: astore_1
    //   18: aload_0
    //   19: getfield 53	org/eclipse/osgi/framework/internal/core/BundleContextImpl$2:this$0	Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;
    //   22: getfield 52	org/eclipse/osgi/framework/internal/core/BundleContextImpl:activator	Lorg/osgi/framework/BundleActivator;
    //   25: aload_0
    //   26: getfield 53	org/eclipse/osgi/framework/internal/core/BundleContextImpl$2:this$0	Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;
    //   29: invokeinterface 58 2 0
    //   34: goto +23 -> 57
    //   37: astore_2
    //   38: aload_1
    //   39: getstatic 51	java/lang/Boolean:FALSE	Ljava/lang/Boolean;
    //   42: if_acmpeq +13 -> 55
    //   45: invokestatic 56	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   48: aload_1
    //   49: checkcast 24	java/lang/ClassLoader
    //   52: invokevirtual 55	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   55: aload_2
    //   56: athrow
    //   57: aload_1
    //   58: getstatic 51	java/lang/Boolean:FALSE	Ljava/lang/Boolean;
    //   61: if_acmpeq +13 -> 74
    //   64: invokestatic 56	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   67: aload_1
    //   68: checkcast 24	java/lang/ClassLoader
    //   71: invokevirtual 55	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   74: aconst_null
    //   75: areturn
    // Line number table:
    //   Java source line #766	-> byte code offset #0
    //   Java source line #768	-> byte code offset #10
    //   Java source line #771	-> byte code offset #18
    //   Java source line #772	-> byte code offset #37
    //   Java source line #773	-> byte code offset #38
    //   Java source line #774	-> byte code offset #45
    //   Java source line #775	-> byte code offset #55
    //   Java source line #773	-> byte code offset #57
    //   Java source line #774	-> byte code offset #64
    //   Java source line #777	-> byte code offset #74
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	76	0	this	2
    //   17	51	1	previousTCCL	Object
    //   37	19	2	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   18	37	37	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.core.BundleContextImpl.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.internal.core;

import java.io.File;
import java.io.InputStream;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.List;
import org.eclipse.osgi.event.BatchBundleListener;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.eventmgr.EventDispatcher;
import org.eclipse.osgi.internal.serviceregistry.ServiceReferenceImpl;
import org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl;
import org.eclipse.osgi.internal.serviceregistry.ServiceRegistry;
import org.eclipse.osgi.internal.serviceregistry.ServiceUse;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.framework.BundleListener;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;

public class BundleContextImpl
  implements BundleContext, EventDispatcher<Object, Object, Object>
{
  private static boolean SET_TCCL = "true".equals(FrameworkProperties.getProperty("eclipse.bundle.setTCCL", "true"));
  private volatile boolean valid;
  final BundleHost bundle;
  final Framework framework;
  private HashMap<ServiceRegistrationImpl<?>, ServiceUse<?>> servicesInUse;
  protected BundleActivator activator;
  private final Object contextLock = new Object();
  
  protected BundleContextImpl(BundleHost bundle)
  {
    this.bundle = bundle;
    valid = true;
    framework = framework;
    synchronized (contextLock)
    {
      servicesInUse = null;
    }
    activator = null;
  }
  
  protected void close()
  {
    valid = false;
    
    ServiceRegistry registry = framework.getServiceRegistry();
    
    registry.removeAllServiceListeners(this);
    framework.removeAllListeners(this);
    
    registry.unregisterServices(this);
    
    registry.releaseServicesInUse(this);
    synchronized (contextLock)
    {
      servicesInUse = null;
    }
  }
  
  public String getProperty(String key)
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPropertyAccess(key);
    }
    return framework.getProperty(key);
  }
  
  public Bundle getBundle()
  {
    checkValid();
    
    return getBundleImpl();
  }
  
  public AbstractBundle getBundleImpl()
  {
    return bundle;
  }
  
  public Bundle installBundle(String location)
    throws BundleException
  {
    return installBundle(location, null);
  }
  
  public Bundle installBundle(String location, InputStream in)
    throws BundleException
  {
    checkValid();
    
    return framework.installBundle(location, in, this);
  }
  
  public Bundle getBundle(long id)
  {
    return framework.getBundle(this, id);
  }
  
  public Bundle getBundle(String location)
  {
    return framework.getBundleByLocation(location);
  }
  
  public AbstractBundle getBundleByLocation(String location)
  {
    return framework.getBundleByLocation(location);
  }
  
  public Bundle[] getBundles()
  {
    return framework.getBundles(this);
  }
  
  public void addServiceListener(ServiceListener listener, String filter)
    throws InvalidSyntaxException
  {
    checkValid();
    if (listener == null) {
      throw new IllegalArgumentException();
    }
    framework.getServiceRegistry().addServiceListener(this, listener, filter);
  }
  
  public void addServiceListener(ServiceListener listener)
  {
    try
    {
      addServiceListener(listener, null);
    }
    catch (InvalidSyntaxException e)
    {
      if (Debug.DEBUG_GENERAL)
      {
        Debug.println("InvalidSyntaxException w/ null filter" + e.getMessage());
        Debug.printStackTrace(e);
      }
    }
  }
  
  public void removeServiceListener(ServiceListener listener)
  {
    checkValid();
    if (listener == null) {
      throw new IllegalArgumentException();
    }
    framework.getServiceRegistry().removeServiceListener(this, listener);
  }
  
  public void addBundleListener(BundleListener listener)
  {
    checkValid();
    if (listener == null) {
      throw new IllegalArgumentException();
    }
    if (Debug.DEBUG_EVENTS)
    {
      String listenerName = listener.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(listener));
      Debug.println("addBundleListener[" + bundle + "](" + listenerName + ")");
    }
    framework.addBundleListener(listener, this);
  }
  
  public void removeBundleListener(BundleListener listener)
  {
    checkValid();
    if (listener == null) {
      throw new IllegalArgumentException();
    }
    if (Debug.DEBUG_EVENTS)
    {
      String listenerName = listener.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(listener));
      Debug.println("removeBundleListener[" + bundle + "](" + listenerName + ")");
    }
    framework.removeBundleListener(listener, this);
  }
  
  public void addFrameworkListener(FrameworkListener listener)
  {
    checkValid();
    if (listener == null) {
      throw new IllegalArgumentException();
    }
    if (Debug.DEBUG_EVENTS)
    {
      String listenerName = listener.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(listener));
      Debug.println("addFrameworkListener[" + bundle + "](" + listenerName + ")");
    }
    framework.addFrameworkListener(listener, this);
  }
  
  public void removeFrameworkListener(FrameworkListener listener)
  {
    checkValid();
    if (listener == null) {
      throw new IllegalArgumentException();
    }
    if (Debug.DEBUG_EVENTS)
    {
      String listenerName = listener.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(listener));
      Debug.println("removeFrameworkListener[" + bundle + "](" + listenerName + ")");
    }
    framework.removeFrameworkListener(listener, this);
  }
  
  public ServiceRegistration<?> registerService(String[] clazzes, Object service, Dictionary<String, ?> properties)
  {
    checkValid();
    return framework.getServiceRegistry().registerService(this, clazzes, service, properties);
  }
  
  public ServiceRegistration<?> registerService(String clazz, Object service, Dictionary<String, ?> properties)
  {
    String[] clazzes = { clazz };
    
    return registerService(clazzes, service, properties);
  }
  
  public ServiceReference<?>[] getServiceReferences(String clazz, String filter)
    throws InvalidSyntaxException
  {
    checkValid();
    return framework.getServiceRegistry().getServiceReferences(this, clazz, filter, false);
  }
  
  public ServiceReference<?>[] getAllServiceReferences(String clazz, String filter)
    throws InvalidSyntaxException
  {
    checkValid();
    return framework.getServiceRegistry().getServiceReferences(this, clazz, filter, true);
  }
  
  public ServiceReference<?> getServiceReference(String clazz)
  {
    checkValid();
    
    return framework.getServiceRegistry().getServiceReference(this, clazz);
  }
  
  public <S> S getService(ServiceReference<S> reference)
  {
    checkValid();
    if (reference == null) {
      throw new NullPointerException("A null service reference is not allowed.");
    }
    synchronized (contextLock)
    {
      if (servicesInUse == null) {
        servicesInUse = new HashMap(10);
      }
    }
    S service = framework.getServiceRegistry().getService(this, (ServiceReferenceImpl)reference);
    return service;
  }
  
  public boolean ungetService(ServiceReference<?> reference)
  {
    checkValid();
    
    return framework.getServiceRegistry().ungetService(this, (ServiceReferenceImpl)reference);
  }
  
  public File getDataFile(String filename)
  {
    checkValid();
    
    return framework.getDataFile(bundle, filename);
  }
  
  protected void start()
    throws BundleException
  {
    activator = bundle.loadBundleActivator();
    if (activator != null) {
      try
      {
        startActivator(activator);
      }
      catch (BundleException be)
      {
        activator = null;
        throw be;
      }
    }
  }
  
  /* Error */
  protected void startActivator(final BundleActivator bundleActivator)
    throws BundleException
  {
    // Byte code:
    //   0: getstatic 489	org/eclipse/osgi/internal/profile/Profile:STARTUP	Z
    //   3: ifeq +10 -> 13
    //   6: ldc_w 206
    //   9: aconst_null
    //   10: invokestatic 552	org/eclipse/osgi/internal/profile/Profile:logEnter	(Ljava/lang/String;Ljava/lang/String;)V
    //   13: new 240	org/eclipse/osgi/framework/internal/core/BundleContextImpl$1
    //   16: dup
    //   17: aload_0
    //   18: aload_1
    //   19: invokespecial 530	org/eclipse/osgi/framework/internal/core/BundleContextImpl$1:<init>	(Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;Lorg/osgi/framework/BundleActivator;)V
    //   22: invokestatic 513	java/security/AccessController:doPrivileged	(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;
    //   25: pop
    //   26: goto +129 -> 155
    //   29: astore_2
    //   30: aload_2
    //   31: instanceof 230
    //   34: ifeq +11 -> 45
    //   37: aload_2
    //   38: checkcast 230	java/security/PrivilegedActionException
    //   41: invokevirtual 514	java/security/PrivilegedActionException:getException	()Ljava/lang/Exception;
    //   44: astore_2
    //   45: getstatic 477	org/eclipse/osgi/framework/debug/Debug:DEBUG_GENERAL	Z
    //   48: ifeq +7 -> 55
    //   51: aload_2
    //   52: invokestatic 518	org/eclipse/osgi/framework/debug/Debug:printStackTrace	(Ljava/lang/Throwable;)V
    //   55: aconst_null
    //   56: astore_3
    //   57: aload_1
    //   58: invokevirtual 497	java/lang/Object:getClass	()Ljava/lang/Class;
    //   61: invokevirtual 490	java/lang/Class:getName	()Ljava/lang/String;
    //   64: astore_3
    //   65: new 253	org/osgi/framework/BundleException
    //   68: dup
    //   69: getstatic 487	org/eclipse/osgi/framework/internal/core/Msg:BUNDLE_ACTIVATOR_EXCEPTION	Ljava/lang/String;
    //   72: iconst_3
    //   73: anewarray 222	java/lang/Object
    //   76: dup
    //   77: iconst_0
    //   78: aload_3
    //   79: aastore
    //   80: dup
    //   81: iconst_1
    //   82: ldc_w 212
    //   85: aastore
    //   86: dup
    //   87: iconst_2
    //   88: aload_0
    //   89: getfield 482	org/eclipse/osgi/framework/internal/core/BundleContextImpl:bundle	Lorg/eclipse/osgi/framework/internal/core/BundleHost;
    //   92: invokevirtual 533	org/eclipse/osgi/framework/internal/core/BundleHost:getSymbolicName	()Ljava/lang/String;
    //   95: ifnonnull +26 -> 121
    //   98: new 225	java/lang/StringBuffer
    //   101: dup
    //   102: invokespecial 501	java/lang/StringBuffer:<init>	()V
    //   105: aload_0
    //   106: getfield 482	org/eclipse/osgi/framework/internal/core/BundleContextImpl:bundle	Lorg/eclipse/osgi/framework/internal/core/BundleHost;
    //   109: invokevirtual 532	org/eclipse/osgi/framework/internal/core/BundleHost:getBundleId	()J
    //   112: invokevirtual 504	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   115: invokevirtual 502	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   118: goto +10 -> 128
    //   121: aload_0
    //   122: getfield 482	org/eclipse/osgi/framework/internal/core/BundleContextImpl:bundle	Lorg/eclipse/osgi/framework/internal/core/BundleHost;
    //   125: invokevirtual 533	org/eclipse/osgi/framework/internal/core/BundleHost:getSymbolicName	()Ljava/lang/String;
    //   128: aastore
    //   129: invokestatic 563	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   132: iconst_5
    //   133: aload_2
    //   134: invokespecial 565	org/osgi/framework/BundleException:<init>	(Ljava/lang/String;ILjava/lang/Throwable;)V
    //   137: athrow
    //   138: astore 4
    //   140: getstatic 489	org/eclipse/osgi/internal/profile/Profile:STARTUP	Z
    //   143: ifeq +9 -> 152
    //   146: ldc_w 206
    //   149: invokestatic 551	org/eclipse/osgi/internal/profile/Profile:logExit	(Ljava/lang/String;)V
    //   152: aload 4
    //   154: athrow
    //   155: getstatic 489	org/eclipse/osgi/internal/profile/Profile:STARTUP	Z
    //   158: ifeq +9 -> 167
    //   161: ldc_w 206
    //   164: invokestatic 551	org/eclipse/osgi/internal/profile/Profile:logExit	(Ljava/lang/String;)V
    //   167: return
    // Line number table:
    //   Java source line #699	-> byte code offset #0
    //   Java source line #700	-> byte code offset #6
    //   Java source line #702	-> byte code offset #13
    //   Java source line #722	-> byte code offset #29
    //   Java source line #723	-> byte code offset #30
    //   Java source line #724	-> byte code offset #37
    //   Java source line #727	-> byte code offset #45
    //   Java source line #728	-> byte code offset #51
    //   Java source line #731	-> byte code offset #55
    //   Java source line #732	-> byte code offset #57
    //   Java source line #734	-> byte code offset #65
    //   Java source line #735	-> byte code offset #138
    //   Java source line #736	-> byte code offset #140
    //   Java source line #737	-> byte code offset #146
    //   Java source line #738	-> byte code offset #152
    //   Java source line #736	-> byte code offset #155
    //   Java source line #737	-> byte code offset #161
    //   Java source line #739	-> byte code offset #167
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	168	0	this	BundleContextImpl
    //   0	168	1	bundleActivator	BundleActivator
    //   29	105	2	t	Throwable
    //   56	23	3	clazz	String
    //   138	15	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   13	26	29	java/lang/Throwable
    //   13	138	138	finally
  }
  
  Object setContextFinder()
  {
    if (!SET_TCCL) {
      return Boolean.FALSE;
    }
    Thread currentThread = Thread.currentThread();
    ClassLoader previousTCCL = currentThread.getContextClassLoader();
    ClassLoader contextFinder = framework.getContextFinder();
    if (previousTCCL != contextFinder)
    {
      currentThread.setContextClassLoader(framework.getContextFinder());
      return previousTCCL;
    }
    return Boolean.FALSE;
  }
  
  /* Error */
  protected void stop()
    throws BundleException
  {
    // Byte code:
    //   0: new 241	org/eclipse/osgi/framework/internal/core/BundleContextImpl$2
    //   3: dup
    //   4: aload_0
    //   5: invokespecial 531	org/eclipse/osgi/framework/internal/core/BundleContextImpl$2:<init>	(Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;)V
    //   8: invokestatic 513	java/security/AccessController:doPrivileged	(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;
    //   11: pop
    //   12: goto +134 -> 146
    //   15: astore_1
    //   16: aload_1
    //   17: instanceof 230
    //   20: ifeq +11 -> 31
    //   23: aload_1
    //   24: checkcast 230	java/security/PrivilegedActionException
    //   27: invokevirtual 514	java/security/PrivilegedActionException:getException	()Ljava/lang/Exception;
    //   30: astore_1
    //   31: getstatic 477	org/eclipse/osgi/framework/debug/Debug:DEBUG_GENERAL	Z
    //   34: ifeq +7 -> 41
    //   37: aload_1
    //   38: invokestatic 518	org/eclipse/osgi/framework/debug/Debug:printStackTrace	(Ljava/lang/Throwable;)V
    //   41: aload_0
    //   42: getfield 484	org/eclipse/osgi/framework/internal/core/BundleContextImpl:activator	Lorg/osgi/framework/BundleActivator;
    //   45: ifnonnull +9 -> 54
    //   48: ldc_w 204
    //   51: goto +13 -> 64
    //   54: aload_0
    //   55: getfield 484	org/eclipse/osgi/framework/internal/core/BundleContextImpl:activator	Lorg/osgi/framework/BundleActivator;
    //   58: invokevirtual 497	java/lang/Object:getClass	()Ljava/lang/Class;
    //   61: invokevirtual 490	java/lang/Class:getName	()Ljava/lang/String;
    //   64: astore_2
    //   65: new 253	org/osgi/framework/BundleException
    //   68: dup
    //   69: getstatic 487	org/eclipse/osgi/framework/internal/core/Msg:BUNDLE_ACTIVATOR_EXCEPTION	Ljava/lang/String;
    //   72: iconst_3
    //   73: anewarray 222	java/lang/Object
    //   76: dup
    //   77: iconst_0
    //   78: aload_2
    //   79: aastore
    //   80: dup
    //   81: iconst_1
    //   82: ldc_w 213
    //   85: aastore
    //   86: dup
    //   87: iconst_2
    //   88: aload_0
    //   89: getfield 482	org/eclipse/osgi/framework/internal/core/BundleContextImpl:bundle	Lorg/eclipse/osgi/framework/internal/core/BundleHost;
    //   92: invokevirtual 533	org/eclipse/osgi/framework/internal/core/BundleHost:getSymbolicName	()Ljava/lang/String;
    //   95: ifnonnull +26 -> 121
    //   98: new 225	java/lang/StringBuffer
    //   101: dup
    //   102: invokespecial 501	java/lang/StringBuffer:<init>	()V
    //   105: aload_0
    //   106: getfield 482	org/eclipse/osgi/framework/internal/core/BundleContextImpl:bundle	Lorg/eclipse/osgi/framework/internal/core/BundleHost;
    //   109: invokevirtual 532	org/eclipse/osgi/framework/internal/core/BundleHost:getBundleId	()J
    //   112: invokevirtual 504	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   115: invokevirtual 502	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   118: goto +10 -> 128
    //   121: aload_0
    //   122: getfield 482	org/eclipse/osgi/framework/internal/core/BundleContextImpl:bundle	Lorg/eclipse/osgi/framework/internal/core/BundleHost;
    //   125: invokevirtual 533	org/eclipse/osgi/framework/internal/core/BundleHost:getSymbolicName	()Ljava/lang/String;
    //   128: aastore
    //   129: invokestatic 563	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   132: iconst_5
    //   133: aload_1
    //   134: invokespecial 565	org/osgi/framework/BundleException:<init>	(Ljava/lang/String;ILjava/lang/Throwable;)V
    //   137: athrow
    //   138: astore_3
    //   139: aload_0
    //   140: aconst_null
    //   141: putfield 484	org/eclipse/osgi/framework/internal/core/BundleContextImpl:activator	Lorg/osgi/framework/BundleActivator;
    //   144: aload_3
    //   145: athrow
    //   146: aload_0
    //   147: aconst_null
    //   148: putfield 484	org/eclipse/osgi/framework/internal/core/BundleContextImpl:activator	Lorg/osgi/framework/BundleActivator;
    //   151: return
    // Line number table:
    //   Java source line #764	-> byte code offset #0
    //   Java source line #780	-> byte code offset #15
    //   Java source line #781	-> byte code offset #16
    //   Java source line #782	-> byte code offset #23
    //   Java source line #785	-> byte code offset #31
    //   Java source line #786	-> byte code offset #37
    //   Java source line #789	-> byte code offset #41
    //   Java source line #791	-> byte code offset #65
    //   Java source line #792	-> byte code offset #138
    //   Java source line #793	-> byte code offset #139
    //   Java source line #794	-> byte code offset #144
    //   Java source line #793	-> byte code offset #146
    //   Java source line #795	-> byte code offset #151
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	152	0	this	BundleContextImpl
    //   15	119	1	t	Throwable
    //   64	15	2	clazz	String
    //   138	7	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	12	15	java/lang/Throwable
    //   0	138	138	finally
  }
  
  /* Error */
  public java.util.Map<ServiceRegistrationImpl<?>, ServiceUse<?>> getServicesInUseMap()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 480	org/eclipse/osgi/framework/internal/core/BundleContextImpl:contextLock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 481	org/eclipse/osgi/framework/internal/core/BundleContextImpl:servicesInUse	Ljava/util/HashMap;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #804	-> byte code offset #0
    //   Java source line #805	-> byte code offset #7
    //   Java source line #804	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	BundleContextImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  public void dispatchEvent(Object originalListener, Object l, int action, Object object)
  {
    AbstractBundle tmpBundle = bundle;
    Object previousTCCL = setContextFinder();
    try
    {
      if (isValid()) {
        switch (action)
        {
        case 1: 
        case 2: 
          BundleListener listener = (BundleListener)l;
          if (Debug.DEBUG_EVENTS)
          {
            String listenerName = listener.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(listener));
            Debug.println("dispatchBundleEvent[" + tmpBundle + "](" + listenerName + ")");
          }
          BundleEvent event = (BundleEvent)object;
          switch (event.getType())
          {
          case -2147483647: 
            if ((listener instanceof BatchBundleListener)) {
              ((BatchBundleListener)listener).batchBegin();
            }
            break;
          case -2147483648: 
            if ((listener instanceof BatchBundleListener)) {
              ((BatchBundleListener)listener).batchEnd();
            }
            break;
          default: 
            listener.bundleChanged((BundleEvent)object);
          }
          break;
        case 3: 
          ServiceEvent event = (ServiceEvent)object;
          
          ServiceListener listener = (ServiceListener)l;
          if (Debug.DEBUG_EVENTS)
          {
            String listenerName = listener.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(listener));
            Debug.println("dispatchServiceEvent[" + tmpBundle + "](" + listenerName + ")");
          }
          listener.serviceChanged(event);
          
          break;
        case 4: 
          FrameworkListener listener = (FrameworkListener)l;
          if (Debug.DEBUG_EVENTS)
          {
            String listenerName = listener.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(listener));
            Debug.println("dispatchFrameworkEvent[" + tmpBundle + "](" + listenerName + ")");
          }
          listener.frameworkEvent((FrameworkEvent)object);
          break;
        default: 
          throw new InternalError();
        }
      }
    }
    catch (Throwable t)
    {
      t = t;
      if (Debug.DEBUG_GENERAL)
      {
        Debug.println("Exception in bottom level event dispatcher: " + t.getMessage());
        Debug.printStackTrace(t);
      }
      framework.adaptor.handleRuntimeError(t);
      if (action == 4)
      {
        FrameworkEvent event = (FrameworkEvent)object;
        if (event.getType() == 2) {}
      }
      else
      {
        framework.publishFrameworkEvent(2, tmpBundle, t);
      }
      if (previousTCCL == Boolean.FALSE) {
        return;
      }
      Thread.currentThread().setContextClassLoader((ClassLoader)previousTCCL); return;
    }
    finally
    {
      localObject1 = 
      
        finally;
      if (previousTCCL != Boolean.FALSE) {
        Thread.currentThread().setContextClassLoader((ClassLoader)previousTCCL);
      }
      throw ((Throwable)localObject1);
    }
    if (previousTCCL != Boolean.FALSE) {
      Thread.currentThread().setContextClassLoader((ClassLoader)previousTCCL);
    }
  }
  
  public Filter createFilter(String filter)
    throws InvalidSyntaxException
  {
    checkValid();
    
    return FilterImpl.newInstance(filter);
  }
  
  public void checkValid()
  {
    if (!isValid()) {
      throw new IllegalStateException(Msg.BUNDLE_CONTEXT_INVALID_EXCEPTION);
    }
  }
  
  protected boolean isValid()
  {
    return valid;
  }
  
  public Framework getFramework()
  {
    return framework;
  }
  
  public <S> ServiceRegistration<S> registerService(Class<S> clazz, S service, Dictionary<String, ?> properties)
  {
    ServiceRegistration<S> registration = registerService(clazz.getName(), service, properties);
    return registration;
  }
  
  public <S> ServiceReference<S> getServiceReference(Class<S> clazz)
  {
    ServiceReference<S> reference = getServiceReference(clazz.getName());
    return reference;
  }
  
  public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter)
    throws InvalidSyntaxException
  {
    ServiceReference[] refs = getServiceReferences(clazz.getName(), filter);
    if (refs == null)
    {
      Collection<ServiceReference<S>> empty = Collections.EMPTY_LIST;
      return empty;
    }
    List<ServiceReference<S>> result = new ArrayList(refs.length);
    ServiceReference[] arrayOfServiceReference1;
    int j = (arrayOfServiceReference1 = refs).length;
    for (int i = 0; i < j; i++)
    {
      ServiceReference<S> b = arrayOfServiceReference1[i];
      result.add(b);
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.core.BundleContextImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.internal.core;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.internal.permadmin.SecurityAdmin;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;

public class BundleFragment
  extends AbstractBundle
{
  protected BundleHost[] hosts;
  
  public BundleFragment(BundleData bundledata, Framework framework)
    throws BundleException
  {
    super(bundledata, framework);
    hosts = null;
  }
  
  protected void load()
  {
    if ((Debug.DEBUG_GENERAL) && 
      ((state & 0x2) == 0))
    {
      Debug.println("Bundle.load called when state != INSTALLED: " + this);
      Debug.printStackTrace(new Exception("Stack trace"));
    }
    if (framework.isActive())
    {
      SecurityManager sm = System.getSecurityManager();
      if ((sm != null) && (framework.securityAdmin != null)) {
        domain = framework.securityAdmin.createProtectionDomain(this);
      }
    }
  }
  
  protected boolean reload(AbstractBundle newBundle)
  {
    if ((Debug.DEBUG_GENERAL) && 
      ((state & 0x6) == 0))
    {
      Debug.println("Bundle.reload called when state != INSTALLED | RESOLVED: " + this);
      Debug.printStackTrace(new Exception("Stack trace"));
    }
    boolean exporting = false;
    if (framework.isActive())
    {
      if ((hosts != null) && 
        (state == 4))
      {
        exporting = true;
        hosts = null;
        state = 2;
      }
    }
    else {
      try
      {
        bundledata.close();
      }
      catch (IOException localIOException1) {}
    }
    if (!exporting) {
      try
      {
        bundledata.close();
      }
      catch (IOException localIOException2) {}
    }
    bundledata = bundledata;
    bundledata.setBundle(this);
    if ((framework.isActive()) && (System.getSecurityManager() != null) && (framework.securityAdmin != null)) {
      domain = framework.securityAdmin.createProtectionDomain(this);
    }
    return exporting;
  }
  
  protected void refresh()
  {
    if ((Debug.DEBUG_GENERAL) && 
      ((state & 0x7) == 0))
    {
      Debug.println("Bundle.refresh called when state != UNINSTALLED | INSTALLED | RESOLVED: " + this);
      Debug.printStackTrace(new Exception("Stack trace"));
    }
    if (state == 4)
    {
      hosts = null;
      state = 2;
    }
    manifestLocalization = null;
  }
  
  protected boolean unload()
  {
    if ((Debug.DEBUG_GENERAL) && 
      ((state & 0x7) == 0))
    {
      Debug.println("Bundle.unload called when state != UNINSTALLED | INSTALLED | RESOLVED: " + this);
      Debug.printStackTrace(new Exception("Stack trace"));
    }
    boolean exporting = false;
    if ((framework.isActive()) && 
      (hosts != null))
    {
      if (state == 4)
      {
        exporting = true;
        hosts = null;
        state = 2;
      }
      domain = null;
    }
    if (!exporting) {
      try
      {
        bundledata.close();
      }
      catch (IOException localIOException) {}
    }
    return exporting;
  }
  
  protected Class<?> loadClass(String name, boolean checkPermission)
    throws ClassNotFoundException
  {
    if (checkPermission)
    {
      try
      {
        framework.checkAdminPermission(this, "class");
      }
      catch (SecurityException e)
      {
        throw new ClassNotFoundException(name, e);
      }
      checkValid();
    }
    throw new ClassNotFoundException(NLS.bind(Msg.BUNDLE_FRAGMENT_CNFE, name));
  }
  
  public URL getResource(String name)
  {
    checkValid();
    
    return null;
  }
  
  public Enumeration<URL> getResources(String name)
  {
    checkValid();
    
    return null;
  }
  
  protected void startWorker(int options)
    throws BundleException
  {
    throw new BundleException(NLS.bind(Msg.BUNDLE_FRAGMENT_START, this), 2);
  }
  
  protected void stopWorker(int options)
    throws BundleException
  {
    throw new BundleException(NLS.bind(Msg.BUNDLE_FRAGMENT_STOP, this), 2);
  }
  
  public ServiceReference<?>[] getRegisteredServices()
  {
    checkValid();
    
    return null;
  }
  
  public ServiceReference<?>[] getServicesInUse()
  {
    checkValid();
    
    return null;
  }
  
  synchronized BundleHost[] getHosts()
  {
    return hosts;
  }
  
  protected boolean isFragment()
  {
    return true;
  }
  
  boolean addHost(BundleHost host)
  {
    if (host == null) {
      return false;
    }
    try
    {
      host.attachFragment(this);
    }
    catch (BundleException be)
    {
      framework.publishFrameworkEvent(2, host, be);
      return false;
    }
    synchronized (this)
    {
      if (hosts == null)
      {
        hosts = new BundleHost[] { host };
        return true;
      }
      for (int i = 0; i < hosts.length; i++) {
        if (host == hosts[i]) {
          return true;
        }
      }
      BundleHost[] newHosts = new BundleHost[hosts.length + 1];
      System.arraycopy(hosts, 0, newHosts, 0, hosts.length);
      newHosts[(newHosts.length - 1)] = host;
      hosts = newHosts;
    }
    return true;
  }
  
  protected BundleLoader getBundleLoader()
  {
    return null;
  }
  
  protected BundleContextImpl getContext()
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.core.BundleFragment
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.internal.core;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import org.eclipse.osgi.framework.adaptor.BundleClassLoader;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
import org.eclipse.osgi.framework.adaptor.StatusException;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.internal.loader.BundleLoaderProxy;
import org.eclipse.osgi.internal.permadmin.SecurityAdmin;
import org.eclipse.osgi.internal.serviceregistry.ServiceRegistry;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;

public class BundleHost
  extends AbstractBundle
{
  public static final int LAZY_TRIGGER = 1073741824;
  private BundleLoaderProxy proxy;
  protected BundleContextImpl context;
  protected BundleFragment[] fragments;
  
  public BundleHost(BundleData bundledata, Framework framework)
  {
    super(bundledata, framework);
    context = null;
    fragments = null;
  }
  
  protected void load()
  {
    if (Debug.DEBUG_GENERAL)
    {
      if ((state & 0x2) == 0)
      {
        Debug.println("Bundle.load called when state != INSTALLED: " + this);
        Debug.printStackTrace(new Exception("Stack trace"));
      }
      if (proxy != null)
      {
        Debug.println("Bundle.load called when proxy != null: " + this);
        Debug.printStackTrace(new Exception("Stack trace"));
      }
    }
    if (framework.isActive())
    {
      SecurityManager sm = System.getSecurityManager();
      if ((sm != null) && (framework.securityAdmin != null)) {
        domain = framework.securityAdmin.createProtectionDomain(this);
      }
    }
    proxy = null;
  }
  
  protected boolean reload(AbstractBundle newBundle)
  {
    if ((Debug.DEBUG_GENERAL) && 
      ((state & 0x6) == 0))
    {
      Debug.println("Bundle.reload called when state != INSTALLED | RESOLVED: " + this);
      Debug.printStackTrace(new Exception("Stack trace"));
    }
    boolean exporting = false;
    if (framework.isActive())
    {
      if (state == 4)
      {
        BundleLoaderProxy curProxy = getLoaderProxy();
        exporting = curProxy.inUse();
        if (exporting) {
          curProxy.getBundleLoader().createClassLoader();
        } else {
          BundleLoader.closeBundleLoader(proxy);
        }
        state = 2;
        proxy = null;
        fragments = null;
      }
    }
    else {
      try
      {
        bundledata.close();
      }
      catch (IOException localIOException) {}
    }
    bundledata = bundledata;
    bundledata.setBundle(this);
    if ((framework.isActive()) && (System.getSecurityManager() != null) && (framework.securityAdmin != null)) {
      domain = framework.securityAdmin.createProtectionDomain(this);
    }
    return exporting;
  }
  
  protected void refresh()
  {
    if ((Debug.DEBUG_GENERAL) && 
      ((state & 0x7) == 0))
    {
      Debug.println("Bundle.reload called when state != UNINSTALLED | INSTALLED | RESOLVED: " + this);
      Debug.printStackTrace(new Exception("Stack trace"));
    }
    if (state == 4)
    {
      BundleLoader.closeBundleLoader(proxy);
      proxy = null;
      fragments = null;
      state = 2;
    }
    manifestLocalization = null;
  }
  
  protected boolean unload()
  {
    if ((Debug.DEBUG_GENERAL) && 
      ((state & 0x7) == 0))
    {
      Debug.println("Bundle.unload called when state != UNINSTALLED | INSTALLED | RESOLVED: " + this);
      Debug.printStackTrace(new Exception("Stack trace"));
    }
    boolean exporting = false;
    if ((framework.isActive()) && 
      (state == 4))
    {
      BundleLoaderProxy curProxy = getLoaderProxy();
      exporting = curProxy.inUse();
      if (exporting) {
        curProxy.getBundleLoader().createClassLoader();
      } else {
        BundleLoader.closeBundleLoader(proxy);
      }
      state = 2;
      proxy = null;
      fragments = null;
      domain = null;
    }
    if (!exporting) {
      try
      {
        bundledata.close();
      }
      catch (IOException localIOException) {}
    }
    return exporting;
  }
  
  private BundleLoader checkLoader()
  {
    checkValid();
    if (!isResolved()) {
      if (!framework.packageAdmin.resolveBundles(new Bundle[] { this })) {
        return null;
      }
    }
    if ((Debug.DEBUG_GENERAL) && 
      ((state & 0x3C) == 0))
    {
      Debug.println("Bundle.checkLoader() called when state != STARTING | ACTIVE | STOPPING | RESOLVED: " + this);
      Debug.printStackTrace(new Exception("Stack trace"));
    }
    BundleLoader loader = getBundleLoader();
    if (loader == null)
    {
      if (Debug.DEBUG_GENERAL)
      {
        Debug.println("Bundle.checkLoader() called when loader == null: " + this);
        Debug.printStackTrace(new Exception("Stack trace"));
      }
      return null;
    }
    return loader;
  }
  
  protected Class<?> loadClass(String name, boolean checkPermission)
    throws ClassNotFoundException
  {
    if (checkPermission) {
      try
      {
        framework.checkAdminPermission(this, "class");
      }
      catch (SecurityException e)
      {
        throw new ClassNotFoundException(name, e);
      }
    }
    BundleLoader loader = checkLoader();
    if (loader == null) {
      throw new ClassNotFoundE
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-2019. Infinite Loop Ltd