org.eclipse.osgi_3.8.2.v20130124-134944

apterType)) {
      return getAccessControlContext();
    }
    if (BundleWiring.class.equals(adapterType))
    {
      if (state == 1) {
        return null;
      }
      BundleDescription description = getBundleDescription();
      return description.getWiring();
    }
    if (BundleRevision.class.equals(adapterType))
    {
      if (state == 1) {
        return null;
      }
      return getBundleDescription();
    }
    return null;
  }
  
  private <A> void checkAdaptPermission(Class<A> adapterType)
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
      return;
    }
    sm.checkPermission(new AdaptPermission(adapterType.getName(), this, "adapt"));
  }
  
  public File getDataFile(String filename)
  {
    return framework.getDataFile(this, filename);
  }
  
  public Bundle getBundle()
  {
    return this;
  }
  
  public int getStartLevel()
  {
    if (getState() == 1) {
      throw new IllegalArgumentException(NLS.bind(Msg.BUNDLE_UNINSTALLED_EXCEPTION, getBundleData().getLocation()));
    }
    return getInternalStartLevel();
  }
  
  public void setStartLevel(int startlevel)
  {
    framework.startLevelManager.setBundleStartLevel(this, startlevel);
  }
  
  public boolean isPersistentlyStarted()
  {
    if (getState() == 1) {
      throw new IllegalArgumentException(NLS.bind(Msg.BUNDLE_UNINSTALLED_EXCEPTION, getBundleData().getLocation()));
    }
    return (getBundleData().getStatus() & 0x1) != 0;
  }
  
  public boolean isActivationPolicyUsed()
  {
    if (getState() == 1) {
      throw new IllegalArgumentException(NLS.bind(Msg.BUNDLE_UNINSTALLED_EXCEPTION, getBundleData().getLocation()));
    }
    return (getBundleData().getStatus() & 0x4) != 0;
  }
}

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.osgi.framework.debug.Debug;

public class AliasMapper
{
  private static Map<String, Object> processorAliasTable;
  private static Map<String, Object> osnameAliasTable;
  static Class class$0;
  
  /* Error */
  private static synchronized Map<String, Object> getProcessorAliasTable()
  {
    // Byte code:
    //   0: getstatic 143	org/eclipse/osgi/framework/internal/core/AliasMapper:processorAliasTable	Ljava/util/Map;
    //   3: ifnonnull +74 -> 77
    //   6: getstatic 141	org/eclipse/osgi/framework/internal/core/AliasMapper:class$0	Ljava/lang/Class;
    //   9: dup
    //   10: ifnonnull +28 -> 38
    //   13: pop
    //   14: ldc 3
    //   16: invokestatic 150	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   19: dup
    //   20: putstatic 141	org/eclipse/osgi/framework/internal/core/AliasMapper:class$0	Ljava/lang/Class;
    //   23: goto +15 -> 38
    //   26: new 76	java/lang/NoClassDefFoundError
    //   29: dup_x1
    //   30: swap
    //   31: invokevirtual 154	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   34: invokespecial 151	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   37: athrow
    //   38: ldc 5
    //   40: invokevirtual 149	java/lang/Class:getResourceAsStream	(Ljava/lang/String;)Ljava/io/InputStream;
    //   43: astore_0
    //   44: aload_0
    //   45: ifnull +32 -> 77
    //   48: aload_0
    //   49: invokestatic 160	org/eclipse/osgi/framework/internal/core/AliasMapper:initAliases	(Ljava/io/InputStream;)Ljava/util/Map;
    //   52: putstatic 143	org/eclipse/osgi/framework/internal/core/AliasMapper:processorAliasTable	Ljava/util/Map;
    //   55: goto +14 -> 69
    //   58: astore_1
    //   59: aload_0
    //   60: invokevirtual 146	java/io/InputStream:close	()V
    //   63: goto +4 -> 67
    //   66: pop
    //   67: aload_1
    //   68: athrow
    //   69: aload_0
    //   70: invokevirtual 146	java/io/InputStream:close	()V
    //   73: goto +4 -> 77
    //   76: pop
    //   77: getstatic 143	org/eclipse/osgi/framework/internal/core/AliasMapper:processorAliasTable	Ljava/util/Map;
    //   80: areturn
    // Line number table:
    //   Java source line #26	-> byte code offset #0
    //   Java source line #27	-> byte code offset #6
    //   Java source line #28	-> byte code offset #44
    //   Java source line #30	-> byte code offset #48
    //   Java source line #31	-> byte code offset #55
    //   Java source line #33	-> byte code offset #59
    //   Java source line #34	-> byte code offset #63
    //   Java source line #37	-> byte code offset #67
    //   Java source line #33	-> byte code offset #69
    //   Java source line #34	-> byte code offset #73
    //   Java source line #40	-> byte code offset #77
    // Local variable table:
    //   start	length	slot	name	signature
    //   43	27	0	in	InputStream
    //   58	10	1	localObject	Object
    //   26	1	2	localClassNotFoundException	ClassNotFoundException
    //   66	1	3	localIOException1	IOException
    //   76	1	4	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   14	19	26	java/lang/ClassNotFoundException
    //   48	58	58	finally
    //   59	63	66	java/io/IOException
    //   69	73	76	java/io/IOException
  }
  
  /* Error */
  private static synchronized Map<String, Object> getOSNameAliasTable()
  {
    // Byte code:
    //   0: getstatic 142	org/eclipse/osgi/framework/internal/core/AliasMapper:osnameAliasTable	Ljava/util/Map;
    //   3: ifnonnull +74 -> 77
    //   6: getstatic 141	org/eclipse/osgi/framework/internal/core/AliasMapper:class$0	Ljava/lang/Class;
    //   9: dup
    //   10: ifnonnull +28 -> 38
    //   13: pop
    //   14: ldc 3
    //   16: invokestatic 150	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   19: dup
    //   20: putstatic 141	org/eclipse/osgi/framework/internal/core/AliasMapper:class$0	Ljava/lang/Class;
    //   23: goto +15 -> 38
    //   26: new 76	java/lang/NoClassDefFoundError
    //   29: dup_x1
    //   30: swap
    //   31: invokevirtual 154	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   34: invokespecial 151	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   37: athrow
    //   38: ldc 4
    //   40: invokevirtual 149	java/lang/Class:getResourceAsStream	(Ljava/lang/String;)Ljava/io/InputStream;
    //   43: astore_0
    //   44: aload_0
    //   45: ifnull +32 -> 77
    //   48: aload_0
    //   49: invokestatic 160	org/eclipse/osgi/framework/internal/core/AliasMapper:initAliases	(Ljava/io/InputStream;)Ljava/util/Map;
    //   52: putstatic 142	org/eclipse/osgi/framework/internal/core/AliasMapper:osnameAliasTable	Ljava/util/Map;
    //   55: goto +14 -> 69
    //   58: astore_1
    //   59: aload_0
    //   60: invokevirtual 146	java/io/InputStream:close	()V
    //   63: goto +4 -> 67
    //   66: pop
    //   67: aload_1
    //   68: athrow
    //   69: aload_0
    //   70: invokevirtual 146	java/io/InputStream:close	()V
    //   73: goto +4 -> 77
    //   76: pop
    //   77: getstatic 142	org/eclipse/osgi/framework/internal/core/AliasMapper:osnameAliasTable	Ljava/util/Map;
    //   80: areturn
    // Line number table:
    //   Java source line #45	-> byte code offset #0
    //   Java source line #46	-> byte code offset #6
    //   Java source line #47	-> byte code offset #44
    //   Java source line #49	-> byte code offset #48
    //   Java source line #50	-> byte code offset #55
    //   Java source line #52	-> byte code offset #59
    //   Java source line #53	-> byte code offset #63
    //   Java source line #56	-> byte code offset #67
    //   Java source line #52	-> byte code offset #69
    //   Java source line #53	-> byte code offset #73
    //   Java source line #59	-> byte code offset #77
    // Local variable table:
    //   start	length	slot	name	signature
    //   43	27	0	in	InputStream
    //   58	10	1	localObject	Object
    //   26	1	2	localClassNotFoundException	ClassNotFoundException
    //   66	1	3	localIOException1	IOException
    //   76	1	4	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   14	19	26	java/lang/ClassNotFoundException
    //   48	58	58	finally
    //   59	63	66	java/io/IOException
    //   69	73	76	java/io/IOException
  }
  
  public String aliasProcessor(String processor)
  {
    processor = processor.toLowerCase();
    Map<String, Object> aliases = getProcessorAliasTable();
    if (aliases != null)
    {
      String alias = (String)aliases.get(processor);
      if (alias != null) {
        processor = alias;
      }
    }
    return processor;
  }
  
  public Object aliasOSName(String osname)
  {
    osname = osname.toLowerCase();
    Map<String, Object> aliases = getOSNameAliasTable();
    if (aliases != null)
    {
      Object aliasObject = aliases.get(osname);
      if (aliasObject != null) {
        if ((aliasObject instanceof String)) {
          osname = (String)aliasObject;
        } else {
          return aliasObject;
        }
      }
    }
    return osname;
  }
  
  protected static Map<String, Object> initAliases(InputStream in)
  {
    Map<String, Object> aliases = new HashMap(37);
    try
    {
      BufferedReader br;
      try
      {
        br = new BufferedReader(new InputStreamReader(in, "UTF8"));
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException)
      {
        BufferedReader br;
        br = new BufferedReader(new InputStreamReader(in));
      }
      Tokenizer tokenizer;
      String master;
      do
      {
        String line = br.readLine();
        if (line == null) {
          break;
        }
        tokenizer = new Tokenizer(line);
        master = tokenizer.getString("# \t");
      } while (master == null);
      aliases.put(master.toLowerCase(), master);
      for (;;)
      {
        String alias = tokenizer.getString("# \t");
        if (alias == null) {
          break;
        }
        String lowerCaseAlias = alias.toLowerCase();
        Object storedMaster = aliases.get(lowerCaseAlias);
        if (storedMaster == null)
        {
          aliases.put(lowerCaseAlias, master);
        }
        else if ((storedMaster instanceof String))
        {
          List<String> newMaster = new ArrayList();
          newMaster.add((String)storedMaster);
          newMaster.add(master);
          aliases.put(lowerCaseAlias, newMaster);
        }
        else
        {
          List<String> newMaster = (List)storedMaster;
          newMaster.add(master);
        }
      }
    }
    catch (IOException e)
    {
      if (Debug.DEBUG_GENERAL) {
        Debug.printStackTrace(e);
      }
    }
    return aliases;
  }
}

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

import java.security.PrivilegedExceptionAction;
import org.osgi.framework.BundleActivator;

class BundleContextImpl$1
  implements PrivilegedExceptionAction<Object>
{
  final BundleContextImpl this$0;
  
  BundleContextImpl$1(BundleContextImpl paramBundleContextImpl, BundleActivator paramBundleActivator) {}
  
  /* Error */
  public Object run()
    throws java.lang.Exception
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 87	org/eclipse/osgi/framework/internal/core/BundleContextImpl$1:val$bundleActivator	Lorg/osgi/framework/BundleActivator;
    //   4: ifnull +146 -> 150
    //   7: getstatic 88	org/eclipse/osgi/internal/profile/Profile:STARTUP	Z
    //   10: ifeq +38 -> 48
    //   13: ldc 2
    //   15: new 45	java/lang/StringBuffer
    //   18: dup
    //   19: ldc 3
    //   21: invokespecial 91	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   24: aload_0
    //   25: getfield 86	org/eclipse/osgi/framework/internal/core/BundleContextImpl$1:this$0	Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;
    //   28: getfield 85	org/eclipse/osgi/framework/internal/core/BundleContextImpl:bundle	Lorg/eclipse/osgi/framework/internal/core/BundleHost;
    //   31: invokevirtual 96	org/eclipse/osgi/framework/internal/core/BundleHost:getLocation	()Ljava/lang/String;
    //   34: invokevirtual 92	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   37: ldc 1
    //   39: invokevirtual 92	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   42: invokevirtual 90	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   45: invokestatic 97	org/eclipse/osgi/internal/profile/Profile:logTime	(Ljava/lang/String;Ljava/lang/String;)V
    //   48: aload_0
    //   49: getfield 86	org/eclipse/osgi/framework/internal/core/BundleContextImpl$1:this$0	Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;
    //   52: invokevirtual 95	org/eclipse/osgi/framework/internal/core/BundleContextImpl:setContextFinder	()Ljava/lang/Object;
    //   55: astore_1
    //   56: aload_0
    //   57: getfield 87	org/eclipse/osgi/framework/internal/core/BundleContextImpl$1:val$bundleActivator	Lorg/osgi/framework/BundleActivator;
    //   60: aload_0
    //   61: getfield 86	org/eclipse/osgi/framework/internal/core/BundleContextImpl$1:this$0	Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;
    //   64: invokeinterface 98 2 0
    //   69: goto +23 -> 92
    //   72: astore_2
    //   73: aload_1
    //   74: getstatic 84	java/lang/Boolean:FALSE	Ljava/lang/Boolean;
    //   77: if_acmpeq +13 -> 90
    //   80: invokestatic 94	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   83: aload_1
    //   84: checkcast 42	java/lang/ClassLoader
    //   87: invokevirtual 93	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   90: aload_2
    //   91: athrow
    //   92: aload_1
    //   93: getstatic 84	java/lang/Boolean:FALSE	Ljava/lang/Boolean;
    //   96: if_acmpeq +13 -> 109
    //   99: invokestatic 94	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   102: aload_1
    //   103: checkcast 42	java/lang/ClassLoader
    //   106: invokevirtual 93	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   109: getstatic 88	org/eclipse/osgi/internal/profile/Profile:STARTUP	Z
    //   112: ifeq +38 -> 150
    //   115: ldc 2
    //   117: new 45	java/lang/StringBuffer
    //   120: dup
    //   121: ldc 4
    //   123: invokespecial 91	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   126: aload_0
    //   127: getfield 86	org/eclipse/osgi/framework/internal/core/BundleContextImpl$1:this$0	Lorg/eclipse/osgi/framework/internal/core/BundleContextImpl;
    //   130: getfield 85	org/eclipse/osgi/framework/internal/core/BundleContextImpl:bundle	Lorg/eclipse/osgi/framework/internal/core/BundleHost;
    //   133: invokevirtual 96	org/eclipse/osgi/framework/internal/core/BundleHost:getLocation	()Ljava/lang/String;
    //   136: invokevirtual 92	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   139: ldc 1
    //   141: invokevirtual 92	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   144: invokevirtual 90	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   147: invokestatic 97	org/eclipse/osgi/internal/profile/Profile:logTime	(Ljava/lang/String;Ljava/lang/String;)V
    //   150: aconst_null
    //   151: areturn
    // Line number table:
    //   Java source line #704	-> byte code offset #0
    //   Java source line #705	-> byte code offset #7
    //   Java source line #706	-> byte code offset #13
    //   Java source line #708	-> byte code offset #48
    //   Java source line #711	-> byte code offset #56
    //   Java source line #712	-> byte code offset #69
    //   Java source line #713	-> byte code offset #73
    //   Java source line #714	-> byte code offset #80
    //   Java source line #715	-> byte code offset #90
    //   Java source line #713	-> byte code offset #92
    //   Java source line #714	-> byte code offset #99
    //   Java source line #716	-> byte code offset #109
    //   Java source line #717	-> byte code offset #115
    //   Java source line #719	-> byte code offset #150
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	152	0	this	1
    //   55	48	1	previousTCCL	Object
    //   72	19	2	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   56	72	72	finally
  }
}

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

import java.security.PrivilegedExceptionAction;

class BundleContextImpl$2
  implements PrivilegedExceptionAction<Object>
{
  final BundleContextImpl this$0;
  
  BundleContextImpl$2(BundleContextImpl paramBundleContextImpl) {}
  
  /* Error */
  public Object run()
    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 #34
    //   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 205
    //   9: aconst_null
    //   10: invokestatic 552	org/eclipse/osgi/internal/profile/Profile:logEnter	(Ljava/lang/String;Ljava/lang/String;)V
    //   13: new 239	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 229
    //   34: ifeq +11 -> 45
    //   37: aload_2
    //   38: checkcast 229	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 252	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 221	java/lang/Object
    //   76: dup
    //   77: iconst_0
    //   78: aload_3
    //   79: aastore
    //   80: dup
    //   81: iconst_1
    //   82: ldc_w 211
    //   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 224	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 205
    //   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 205
    //   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 #26
    //   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 240	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 229
    //   20: ifeq +11 -> 31
    //   23: aload_1
    //   24: checkcast 229	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 203
    //   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 252	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 221	java/lang/Object
    //   76: dup
    //   77: iconst_0
    //   78: aload_2
    //   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 224	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 #12
    //   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/
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 85 86 87

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