org.eclipse.osgi_3.8.2.v20130124-134944

);
          if ((nativeCode != null) && (nativeCode.getSupplier() != null)) {
            try
            {
              BundleData data = bundle.getBundleData();
              data.installNativeCode(((NativeCodeDescription)nativeCode.getSupplier()).getNativePaths());
            }
            catch (BundleException e)
            {
              framework.publishFrameworkEvent(2, bundle, e);
            }
          }
        }
      }
    }
  }
  
  private AbstractBundle[] processDelta(BundleDelta[] bundleDeltas, boolean refreshPackages, State systemState)
  {
    List<AbstractBundle> bundlesList = new ArrayList(bundleDeltas.length);
    for (int i = 0; i < bundleDeltas.length; i++) {
      if (((bundleDeltas[i].getType() & 0x100) == 0) || ((bundleDeltas[i].getType() & 0x2) != 0))
      {
        AbstractBundle changedBundle = framework.getBundle(bundleDeltas[i].getBundle().getBundleId());
        if ((changedBundle != null) && (!bundlesList.contains(changedBundle))) {
          bundlesList.add(changedBundle);
        }
      }
    }
    AbstractBundle[] refresh = (AbstractBundle[])bundlesList.toArray(new AbstractBundle[bundlesList.size()]);
    
    Util.sort(refresh, 0, refresh.length);
    
    framework.startLevelManager.sortByDependency(refresh);
    boolean[] previouslyResolved = new boolean[refresh.length];
    int[] previousStates = new int[refresh.length];
    try
    {
      try
      {
        if (Debug.DEBUG_PACKAGEADMIN) {
          Debug.println("refreshPackages: Suspend each bundle and acquire its state change lock");
        }
        boolean restart = false;
        for (int i = refresh.length - 1; i >= 0; i--)
        {
          previouslyResolved[i] = refresh[i].isResolved();
          if (refresh[i] == framework.systemBundle) {
            restart = true;
          } else if (((bundledata.getType() & 0x2) != 0) && (previouslyResolved[i] != 0)) {
            restart = true;
          } else if ((bundledata.getType() & 0x4) != 0) {
            restart = true;
          } else if (((bundledata.getType() & 0x10) != 0) && (previouslyResolved[i] != 0)) {
            restart = true;
          }
        }
        if (restart)
        {
          FrameworkProperties.setProperty("osgi.forcedRestart", "true");
          framework.setForcedRestart(true);
          int i;
          AbstractBundle changedBundle;
          return null;
        }
        boolean restart;
        if (refreshPackages) {
          for (int i = refresh.length - 1; i >= 0; i--)
          {
            previousStates[i] = refresh[i].getState();
            suspendBundle(refresh[i]);
          }
        }
        if (Debug.DEBUG_PACKAGEADMIN) {
          Debug.println("refreshPackages: refresh the bundles");
        }
        synchronized (framework.bundles)
        {
          for (int i = refresh.length - 1; i >= 0; i--) {
            refresh[i].refresh();
          }
        }
        for (int i = refresh.length - 1; i >= 0; i--) {
          if (previouslyResolved[i] != 0) {
            framework.publishBundleEvent(64, refresh[i]);
          }
        }
        if (Debug.DEBUG_PACKAGEADMIN) {
          Debug.println("refreshPackages: applying deltas to bundles");
        }
        synchronized (framework.bundles)
        {
          applyDeltas(bundleDeltas);
        }
        int i;
        AbstractBundle changedBundle;
        if (!Debug.DEBUG_PACKAGEADMIN) {
          break label633;
        }
      }
      finally
      {
        if (Debug.DEBUG_PACKAGEADMIN) {
          Debug.println("refreshPackages: release the state change locks");
        }
        if (refreshPackages) {
          for (i = 0; i < refresh.length; i++)
          {
            changedBundle = refresh[i];
            changedBundle.completeStateChange();
          }
        }
      }
      Debug.println("refreshPackages: release the state change locks");
      label633:
      if (refreshPackages) {
        for (int i = 0; i < refresh.length; i++)
        {
          AbstractBundle changedBundle = refresh[i];
          changedBundle.completeStateChange();
        }
      }
      if (refreshPackages)
      {
        if (Debug.DEBUG_PACKAGEADMIN) {
          Debug.println("refreshPackages: clean up adaptor storage");
        }
        try
        {
          framework.adaptor.compactStorage();
        }
        catch (IOException e)
        {
          if (Debug.DEBUG_PACKAGEADMIN)
          {
            Debug.println("refreshPackages exception: " + e.getMessage());
            Debug.printStackTrace(e);
          }
          framework.publishFrameworkEvent(2, framework.systemBundle, new BundleException(Msg.BUNDLE_REFRESH_FAILURE, e));
        }
      }
      if (!Debug.DEBUG_PACKAGEADMIN) {
        break label856;
      }
    }
    catch (BundleException e)
    {
      if (Debug.DEBUG_PACKAGEADMIN)
      {
        Debug.println("refreshPackages exception: " + e.getMessage());
        Debug.printStackTrace(e.getNestedException() == null ? e : e.getNestedException());
      }
      framework.publishFrameworkEvent(2, framework.systemBundle, new BundleException(Msg.BUNDLE_REFRESH_FAILURE, e));
    }
    Debug.println("refreshPackages: send out RESOLVED events");
    label856:
    for (int i = 0; i < refresh.length; i++) {
      if (refresh[i].isResolved()) {
        framework.publishBundleEvent(32, refresh[i]);
      }
    }
    if (!framework.isActive()) {
      return refresh;
    }
    if (refreshPackages)
    {
      framework.securityAdmin.clearCaches();
      if (bundleDeltas.length > 0) {
        systemState.setTimeStamp(systemState.getTimeStamp() == Long.MAX_VALUE ? 0L : systemState.getTimeStamp() + 1L);
      }
    }
    resumeBundles(refresh, refreshPackages, previousStates);
    return refresh;
  }
  
  public RequiredBundle[] getRequiredBundles(String symbolicName)
  {
    AbstractBundle[] bundles;
    AbstractBundle[] bundles;
    if (symbolicName == null) {
      bundles = framework.getAllBundles();
    } else {
      bundles = framework.getBundleBySymbolicName(symbolicName);
    }
    if ((bundles == null) || (bundles.length == 0)) {
      return null;
    }
    List<RequiredBundle> result = new ArrayList(bundles.length);
    for (int i = 0; i < bundles.length; i++) {
      if ((!bundles[i].isFragment()) && (bundles[i].isResolved()) && (bundles[i].getSymbolicName() != null)) {
        if (bundles[i].hasPermission(new BundlePermission(bundles[i].getSymbolicName(), "provide"))) {
          result.add(((BundleHost)bundles[i]).getLoaderProxy());
        }
      }
    }
    return result.size() == 0 ? null : (RequiredBundle[])result.toArray(new RequiredBundle[result.size()]);
  }
  
  public Bundle[] getBundles(String symbolicName, String versionRange)
  {
    if (symbolicName == null) {
      throw new IllegalArgumentException();
    }
    AbstractBundle[] bundles = framework.getBundleBySymbolicName(symbolicName);
    if (bundles == null) {
      return null;
    }
    if (versionRange == null)
    {
      AbstractBundle[] result = new AbstractBundle[bundles.length];
      System.arraycopy(bundles, 0, result, 0, result.length);
      return result;
    }
    List<AbstractBundle> result = new ArrayList(bundles.length);
    VersionRange range = new VersionRange(versionRange);
    for (int i = 0; i < bundles.length; i++) {
      if (range.isIncluded(bundles[i].getVersion())) {
        result.add(bundles[i]);
      }
    }
    if (result.size() == 0) {
      return null;
    }
    return (Bundle[])result.toArray(new AbstractBundle[result.size()]);
  }
  
  public Bundle[] getFragments(Bundle bundle)
  {
    return ((AbstractBundle)bundle).getFragments();
  }
  
  public Bundle[] getHosts(Bundle bundle)
  {
    BundleHost[] hosts = ((AbstractBundle)bundle).getHosts();
    if (hosts == null) {
      return null;
    }
    Bundle[] result = new Bundle[hosts.length];
    for (int i = 0; i < hosts.length; i++) {
      result[i] = hosts[i];
    }
    return result;
  }
  
  Bundle getBundlePriv(Class<?> clazz)
  {
    ClassLoader cl = clazz.getClassLoader();
    if ((cl instanceof BundleClassLoader))
    {
      ClassLoaderDelegate delegate = ((BundleClassLoader)cl).getDelegate();
      if ((delegate instanceof BundleLoader)) {
        return ((BundleLoader)delegate).getBundle();
      }
    }
    if (cl == getClass().getClassLoader()) {
      return framework.systemBundle;
    }
    return null;
  }
  
  public Bundle getBundle(Class clazz)
  {
    if (System.getSecurityManager() == null) {
      return getBundlePriv(clazz);
    }
    return (Bundle)AccessController.doPrivileged(new GetBundleAction(this, clazz));
  }
  
  public int getBundleType(Bundle bundle)
  {
    return ((AbstractBundle)bundle).isFragment() ? 1 : 0;
  }
  
  protected void cleanup() {}
  
  protected void setResolvedBundles(InternalSystemBundle systemBundle)
  {
    checkSystemBundle(systemBundle);
    
    State state = framework.adaptor.getState();
    BundleDescription[] descriptions = state.getBundles();
    for (int i = 0; i < descriptions.length; i++) {
      if (descriptions[i].getBundleId() == 0L) {
        setFrameworkVersion(descriptions[i]);
      } else {
        setResolved(descriptions[i]);
      }
    }
  }
  
  private void checkSystemBundle(InternalSystemBundle systemBundle)
  {
    try
    {
      State state = framework.adaptor.getState();
      BundleDescription oldSystemBundle = state.getBundle(0L);
      boolean different = false;
      if ((oldSystemBundle == null) || (!systemBundle.getBundleData().getVersion().equals(oldSystemBundle.getVersion()))) {
        different = true;
      }
      if ((!different) && (FrameworkProperties.getProperty("osgi.dev") == null)) {
        return;
      }
      BundleDescription newSystemBundle = state.getFactory().createBundleDescription(state, systemBundle.getHeaders(""), systemBundle.getLocation(), 0L);
      if (newSystemBundle == null) {
        throw new BundleException(Msg.OSGI_SYSTEMBUNDLE_DESCRIPTION_ERROR);
      }
      if (!different)
      {
        ExportPackageDescription[] oldPackages = oldSystemBundle.getExportPackages();
        ExportPackageDescription[] newPackages = newSystemBundle.getExportPackages();
        if (oldPackages.length >= newPackages.length)
        {
          int i = 0;
          do
          {
            if (oldPackages[i].getName().equals(newPackages[i].getName()))
            {
              Object oldVersion = oldPackages[i].getVersion();
              Object newVersion = newPackages[i].getVersion();
              different = newVersion != null;
            }
            else
            {
              different = true;
            }
            i++;
            if (i >= newPackages.length) {
              break;
            }
          } while (!different);
        }
        else
        {
          different = true;
        }
      }
      if (different)
      {
        state.removeBundle(0L);
        state.addBundle(newSystemBundle);
        
        state.resolve(false);
      }
    }
    catch (BundleException e)
    {
      e.printStackTrace();
      throw new RuntimeException(NLS.bind(Msg.OSGI_SYSTEMBUNDLE_CREATE_EXCEPTION, e.getMessage()), e);
    }
  }
  
  private void setFrameworkVersion(BundleDescription systemBundle)
  {
    ExportPackageDescription[] packages = systemBundle.getExportPackages();
    for (int i = 0; i < packages.length; i++) {
      if (packages[i].getName().equals("org.osgi.framework"))
      {
        FrameworkProperties.setProperty("org.osgi.framework.version", packages[i].getVersion().toString());
        break;
      }
    }
    FrameworkProperties.setProperty("osgi.framework.version", systemBundle.getVersion().toString());
  }
  
  public Bundle getBundle()
  {
    return framework.getBundle(0L);
  }
  
  public void refreshBundles(Collection<Bundle> bundles, FrameworkListener[] listeners)
  {
    refreshPackages(bundles == null ? null : (Bundle[])bundles.toArray(new Bundle[bundles.size()]), false, listeners);
  }
  
  public boolean resolveBundles(Collection<Bundle> bundles)
  {
    return resolveBundles(bundles == null ? null : (Bundle[])bundles.toArray(new Bundle[bundles.size()]));
  }
  
  public Collection<Bundle> getRemovalPendingBundles()
  {
    BundleDescription[] removals = framework.adaptor.getState().getRemovalPending();
    Set<Bundle> result = new HashSet();
    for (int i = 0; i < removals.length; i++)
    {
      Object ref = removals[i].getUserObject();
      if ((ref instanceof BundleReference)) {
        result.add(((BundleReference)ref).getBundle());
      }
    }
    return result;
  }
  
  public Collection<Bundle> getDependencyClosure(Collection<Bundle> bundles)
  {
    Collection<BundleDescription> descriptions = getDescriptionClosure(bundles);
    Set<Bundle> result = new HashSet();
    for (Iterator localIterator = descriptions.iterator(); localIterator.hasNext();)
    {
      BundleDescription description = (BundleDescription)localIterator.next();
      Object userObject = description.getUserObject();
      if ((userObject instanceof BundleReference))
      {
        Bundle bundle = ((BundleReference)userObject).getBundle();
        if (bundle != null) {
          result.add(bundle);
        }
      }
    }
    return result;
  }
  
  private Collection<BundleDescription> getDescriptionClosure(Collection<Bundle> bundles)
  {
    State state = framework.adaptor.getState();
    Collection<BundleDescription> descriptions = new ArrayList();
    for (Iterator localIterator = bundles.iterator(); localIterator.hasNext();)
    {
      Bundle bundle = (Bundle)localIterator.next();
      BundleDescription description = state.getBundle(bundle.getBundleId());
      if (description != null) {
        descriptions.add(description);
      }
    }
    return state.getDependencyClosure(descriptions);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.core.PackageAdminImpl
 * 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.io.InputStream;
import java.net.URL;

public class ReferenceInputStream
  extends InputStream
{
  protected URL reference;
  
  public ReferenceInputStream(URL reference)
  {
    this.reference = reference;
  }
  
  public int read()
    throws IOException
  {
    throw new IOException();
  }
  
  public URL getReference()
  {
    return reference;
  }
}

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

import java.util.EventObject;
import org.osgi.framework.FrameworkListener;

class StartLevelEvent
  extends EventObject
{
  private static final long serialVersionUID = 3258125839085155891L;
  public static final int CHANGE_BUNDLE_SL = 0;
  public static final int CHANGE_FW_SL = 1;
  private final transient int type;
  private final transient int newSl;
  private final transient AbstractBundle bundle;
  private final transient FrameworkListener[] listeners;
  
  public StartLevelEvent(int type, int newSl, AbstractBundle bundle, FrameworkListener[] listeners)
  {
    super(bundle);
    this.type = type;
    this.newSl = newSl;
    this.bundle = bundle;
    this.listeners = listeners;
  }
  
  public int getType()
  {
    return type;
  }
  
  public int getNewSL()
  {
    return newSl;
  }
  
  public AbstractBundle getBundle()
  {
    return bundle;
  }
  
  public FrameworkListener[] getListeners()
  {
    return listeners;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.core.StartLevelEvent
 * 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.eclipse.osgi.framework.adaptor.BundleData;

class StartLevelManager$1
  implements PrivilegedExceptionAction<Object>
{
  final StartLevelManager this$0;
  
  StartLevelManager$1(StartLevelManager paramStartLevelManager, AbstractBundle paramAbstractBundle) {}
  
  public Object run()
    throws Exception
  {
    val$b.getBundleData().save();
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.core.StartLevelManager.1
 * 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.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap;
import org.eclipse.osgi.framework.eventmgr.EventDispatcher;
import org.eclipse.osgi.framework.eventmgr.EventManager;
import org.eclipse.osgi.framework.eventmgr.ListenerQueue;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.osgi.service.resolver.StateHelper;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkListener;
import org.osgi.service.startlevel.StartLevel;

public class StartLevelManager
  implements EventDispatcher<Object, Object, StartLevelEvent>, StartLevel
{
  protected static EventManager eventManager;
  protected static Map<Object, Object> startLevelListeners;
  protected int initialBundleStartLevel = 1;
  private int activeSL = 0;
  private final Object lock = new Object();
  private final Framework framework;
  
  protected StartLevelManager(Framework framework)
  {
    this.framework = framework;
  }
  
  protected void initialize()
  {
    initialBundleStartLevel = framework.adaptor.getInitialBundleStartLevel();
    
    eventManager = new EventManager("Start Level Event Dispatcher");
    startLevelListeners = new CopyOnWriteIdentityMap();
    startLevelListeners.put(this, this);
  }
  
  protected void cleanup()
  {
    eventManager.close();
    eventManager = null;
    startLevelListeners.clear();
    startLevelListeners = null;
  }
  
  public int getInitialBundleStartLevel()
  {
    return initialBundleStartLevel;
  }
  
  public void setInitialBundleStartLevel(int startlevel)
  {
    framework.checkAdminPermission(framework.systemBundle, "startlevel");
    if (startlevel <= 0) {
      throw new IllegalArgumentException();
    }
    initialBundleStartLevel = startlevel;
    framework.adaptor.setInitialBundleStartLevel(startlevel);
  }
  
  public int getStartLevel()
  {
    return activeSL;
  }
  
  public void setStartLevel(int newSL, Bundle callerBundle, FrameworkListener[] listeners)
  {
    if (newSL <= 0) {
      throw new IllegalArgumentException(NLS.bind(Msg.STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL, newSL));
    }
    framework.checkAdminPermission(framework.systemBundle, "startlevel");
    if (Debug.DEBUG_STARTLEVEL) {
      Debug.println("StartLevelImpl: setStartLevel: " + newSL + "; callerBundle = " + callerBundle.getBundleId());
    }
    issueEvent(new StartLevelEvent(1, newSL, (AbstractBundle)callerBundle, listeners));
  }
  
  public void setStartLevel(int newSL)
  {
    setStartLevel(newSL, framework.systemBundle, new FrameworkListener[0]);
  }
  
  protected void shutdown()
  {
    doSetStartLevel(0, new FrameworkListener[0]);
  }
  
  /* Error */
  void doSetStartLevel(int newSL, FrameworkListener[] listeners)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 476	org/eclipse/osgi/framework/internal/core/StartLevelManager:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_3
    //   6: monitorenter
    //   7: invokestatic 493	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   10: invokevirtual 491	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   13: astore 4
    //   15: aload_0
    //   16: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   19: invokevirtual 520	org/eclipse/osgi/framework/internal/core/Framework:getContextFinder	()Lorg/eclipse/core/runtime/internal/adaptor/ContextFinder;
    //   22: astore 5
    //   24: aload 5
    //   26: aload 4
    //   28: if_acmpne +9 -> 37
    //   31: aconst_null
    //   32: astore 5
    //   34: goto +11 -> 45
    //   37: invokestatic 493	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   40: aload 5
    //   42: invokevirtual 492	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   45: aload_0
    //   46: getfield 474	org/eclipse/osgi/framework/internal/core/StartLevelManager:activeSL	I
    //   49: istore 6
    //   51: iload_1
    //   52: iload 6
    //   54: if_icmple +131 -> 185
    //   57: iload 6
    //   59: ifne +7 -> 66
    //   62: iconst_1
    //   63: goto +4 -> 67
    //   66: iconst_0
    //   67: istore 7
    //   69: iload 6
    //   71: istore 8
    //   73: goto +55 -> 128
    //   76: getstatic 465	org/eclipse/osgi/framework/debug/Debug:DEBUG_STARTLEVEL	Z
    //   79: ifeq +23 -> 102
    //   82: new 237	java/lang/StringBuffer
    //   85: dup
    //   86: ldc 7
    //   88: invokespecial 485	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   91: iload 6
    //   93: invokevirtual 486	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   96: invokevirtual 484	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   99: invokestatic 498	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   102: iinc 6 1
    //   105: aload_0
    //   106: iload 8
    //   108: iconst_1
    //   109: iadd
    //   110: aload_0
    //   111: aload_0
    //   112: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   115: getfield 467	org/eclipse/osgi/framework/internal/core/Framework:bundles	Lorg/eclipse/osgi/framework/internal/core/BundleRepository;
    //   118: iconst_0
    //   119: invokevirtual 545	org/eclipse/osgi/framework/internal/core/StartLevelManager:getInstalledBundles	(Lorg/eclipse/osgi/framework/internal/core/BundleRepository;Z)[Lorg/eclipse/osgi/framework/internal/core/AbstractBundle;
    //   122: invokevirtual 536	org/eclipse/osgi/framework/internal/core/StartLevelManager:incFWSL	(I[Lorg/eclipse/osgi/framework/internal/core/AbstractBundle;)V
    //   125: iinc 8 1
    //   128: iload 8
    //   130: iload_1
    //   131: if_icmplt -55 -> 76
    //   134: iload 7
    //   136: ifeq +137 -> 273
    //   139: aload_0
    //   140: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   143: getfield 468	org/eclipse/osgi/framework/internal/core/Framework:systemBundle	Lorg/eclipse/osgi/framework/internal/core/InternalSystemBundle;
    //   146: bipush 32
    //   148: putfield 469	org/eclipse/osgi/framework/internal/core/InternalSystemBundle:state	I
    //   151: aload_0
    //   152: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   155: iconst_2
    //   156: aload_0
    //   157: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   160: getfield 468	org/eclipse/osgi/framework/internal/core/Framework:systemBundle	Lorg/eclipse/osgi/framework/internal/core/InternalSystemBundle;
    //   163: invokevirtual 523	org/eclipse/osgi/framework/internal/core/Framework:publishBundleEvent	(ILorg/osgi/framework/Bundle;)V
    //   166: aload_0
    //   167: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   170: iconst_1
    //   171: aload_0
    //   172: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   175: getfield 468	org/eclipse/osgi/framework/internal/core/Framework:systemBundle	Lorg/eclipse/osgi/framework/internal/core/InternalSystemBundle;
    //   178: aconst_null
    //   179: invokevirtual 525	org/eclipse/osgi/framework/internal/core/Framework:publishFrameworkEvent	(ILorg/osgi/framework/Bundle;Ljava/lang/Throwable;)V
    //   182: goto +91 -> 273
    //   185: aload_0
    //   186: aload_0
    //   187: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   190: getfield 467	org/eclipse/osgi/framework/internal/core/Framework:bundles	Lorg/eclipse/osgi/framework/internal/core/BundleRepository;
    //   193: iconst_1
    //   194: invokevirtual 545	org/eclipse/osgi/framework/internal/core/StartLevelManager:getInstalledBundles	(Lorg/eclipse/osgi/framework/internal/core/BundleRepository;Z)[Lorg/eclipse/osgi/framework/internal/core/AbstractBundle;
    //   197: astore 7
    //   199: iload 6
    //   201: istore 8
    //   203: goto +45 -> 248
    //   206: getstatic 465	org/eclipse/osgi/framework/debug/Debug:DEBUG_STARTLEVEL	Z
    //   209: ifeq +23 -> 232
    //   212: new 237	java/lang/StringBuffer
    //   215: dup
    //   216: ldc 6
    //   218: invokespecial 485	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   221: iload 6
    //   223: invokevirtual 486	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   226: invokevirtual 484	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   229: invokestatic 498	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   232: iinc 6 -1
    //   235: aload_0
    //   236: iload 8
    //   238: iconst_1
    //   239: isub
    //   240: aload 7
    //   242: invokevirtual 535	org/eclipse/osgi/framework/internal/core/StartLevelManager:decFWSL	(I[Lorg/eclipse/osgi/framework/internal/core/AbstractBundle;)V
    //   245: iinc 8 -1
    //   248: iload 8
    //   250: iload_1
    //   251: if_icmpgt -45 -> 206
    //   254: iload_1
    //   255: ifne +18 -> 273
    //   258: aload_0
    //   259: aload_0
    //   260: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   263: getfield 467	org/eclipse/osgi/framework/internal/core/Framework:bundles	Lorg/eclipse/osgi/framework/internal/core/BundleRepository;
    //   266: invokespecial 541	org/eclipse/osgi/framework/internal/core/StartLevelManager:unloadAllBundles	(Lorg/eclipse/osgi/framework/internal/core/BundleRepository;)V
    //   269: aload_0
    //   270: invokespecial 533	org/eclipse/osgi/framework/internal/core/StartLevelManager:stopSystemBundle	()V
    //   273: aload_0
    //   274: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   277: bipush 8
    //   279: aload_0
    //   280: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   283: getfield 468	org/eclipse/osgi/framework/internal/core/Framework:systemBundle	Lorg/eclipse/osgi/framework/internal/core/InternalSystemBundle;
    //   286: aconst_null
    //   287: aload_2
    //   288: invokevirtual 526	org/eclipse/osgi/framework/internal/core/Framework:publishFrameworkEvent	(ILorg/osgi/framework/Bundle;Ljava/lang/Throwable;[Lorg/osgi/framework/FrameworkListener;)V
    //   291: getstatic 465	org/eclipse/osgi/framework/debug/Debug:DEBUG_STARTLEVEL	Z
    //   294: ifeq +75 -> 369
    //   297: ldc 3
    //   299: invokestatic 498	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   302: goto +67 -> 369
    //   305: astore 6
    //   307: aload_0
    //   308: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   311: iconst_2
    //   312: aload_0
    //   313: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   316: getfield 468	org/eclipse/osgi/framework/internal/core/Framework:systemBundle	Lorg/eclipse/osgi/framework/internal/core/InternalSystemBundle;
    //   319: aload 6
    //   321: aload_2
    //   322: invokevirtual 526	org/eclipse/osgi/framework/internal/core/Framework:publishFrameworkEvent	(ILorg/osgi/framework/Bundle;Ljava/lang/Throwable;[Lorg/osgi/framework/FrameworkListener;)V
    //   325: aload 6
    //   327: athrow
    //   328: astore 6
    //   330: aload_0
    //   331: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   334: iconst_2
    //   335: aload_0
    //   336: getfield 479	org/eclipse/osgi/framework/internal/core/StartLevelManager:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   339: getfield 468	org/eclipse/osgi/framework/internal/core/Framework:systemBundle	Lorg/eclipse/osgi/framework/internal/core/InternalSystemBundle;
    //   342: aload 6
    //   344: aload_2
    //   345: invokevirtual 526	org/eclipse/osgi/framework/internal/core/Framework:publishFrameworkEvent	(ILorg/osgi/framework/Bundle;Ljava/lang/Throwable;[Lorg/osgi/framework/FrameworkListener;)V
    //   348: aload 6
    //   350: athrow
    //   351: astore 9
    //   353: aload 5
    //   355: ifnull +11 -> 366
    //   358: invokestatic 493	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   361: aload 4
    //   363: invokevirtual 492	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   366: aload 9
    //   368: athrow
    //   369: aload 5
    //   371: ifnull +11 -> 382
    //   374: invokestatic 493	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   377: aload 4
    //   379: invokevirtual 492	java/lang/Thread:setContextClassLoader	(Ljava/lang/ClassLoader;)V
    //   382: aload_3
    //   383: monitorexit
    //   384: goto +6 -> 390
    //   387: aload_3
    //   388: monitorexit
    //   389: athrow
    //   390: return
    // Line number table:
    //   Java source line #225	-> byte code offset #0
    //   Java source line #226	-> byte code offset #7
    //   Java source line #227	-> byte code offset #15
    //   Java source line #228	-> byte code offset #24
    //   Java source line #229	-> byte code offset #31
    //   Java source line #231	-> byte code offset #37
    //   Java source line #233	-> byte code offset #45
    //   Java source line #234	-> byte code offset #51
    //   Java source line #235	-> byte code offset #57
    //   Java source line #236	-> byte code offset #69
    //   Java source line #237	-> byte code offset #76
    //   Java source line #238	-> byte code offset #82
    //   Java source line #240	-> byte code offset #102
    //   Java source line #243	-> byte code offset #105
    //   Java source line #236	-> byte code offset #125
    //   Java source line #245	-> byte code offset #134
    //   Java source line #246	-> byte code offset #139
    //   Java source line #247	-> byte code offset #151
    //   Java source line #248	-> byte code offset #166
    //   Java source line #250	-> byte code offset #182
    //   Java source line #251	-> byte code offset #185
    //   Java source line #252	-> byte code offset #199
    //   Java source line #253	-> byte code offset #206
    //   Java source line #254	-> byte code offset #212
    //   Java source line #256	-> byte code offset #232
    //   Java source line #257	-> byte code offset #235
    //   Java source line #252	-> byte code offset #245
    //   Java source line #259	-> byte code offset #254
    //   Java source line #261	-> byte code offset #258
    //   Java source line #262	-> byte code offset #269
    //   Java source line #265	-> byte code offset #273
    //   Java source line #266	-> byte code offset #291
    //   Java source line #267	-> byte code offset #297
    //   Java source line #269	-> byte code offset #302
    //   Java source line #270	-> byte code offset #307
    //   Java source line #271	-> byte code offset #325
    //   Java source line #272	-> byte code offset #328
    //   Java source line #273	-> byte code offset #330
    //   Java source line #274	-> byte code offset #348
    //   Java source line #275	-> byte code offset #351
    //   Java source line #276	-> byte code offset #353
    //   Java source line #277	-> byte code offset #358
    //   Java source line #278	-> byte code offset #366
    //   Java source line #276	-> byte code offset #369
    //   Java source line #277	-> byte code offset #374
    //   Java source line #225	-> byte code offset #382
    //   Java source line #280	-> byte code offset #390
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	391	0	this	StartLevelManager
    //   0	391	1	newSL	int
    //   0	391	2	listeners	FrameworkListener[]
    //   5	383	3	Ljava/lang/Object;	Object
    //   13	365	4	previousTCCL	ClassLoader
    //   22	348	5	contextFinder	ClassLoader
    //   49	184	6	tempSL	int
    //   305	21	6	e	Error
    //   328	21	6	e	RuntimeException
    //   67	68	7	launching	boolean
    //   197	44	7	sortedBundles	AbstractBundle[]
    //   71	58	8	i	int
    //   201	48	8	i	int
    //   351	16	9	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   45	302	305	java/lang/Error
    //   45	302	328	java/lang/RuntimeException
    //   45	351	351	finally
    //   7	384	387	finally
    //   387	389	387	finally
  }
  
  protected void saveActiveStartLevel(int newSL)
  {
    synchronized (lock)
    {
      activeSL = newSL;
    }
  }
  
  public boolean isBundlePersistentlyStarted(Bundle bundle)
  {
    return ((AbstractBundle)bundle).isPersistentlyStarted();
  }
  
  public boolean isBundleActivationPolicyUsed(Bundle bundle)
  {
    return ((AbstractBundle)bundle).isActivationPolicyUsed();
  }
  
  public int getBundleStartLevel(Bundle bundle)
  {
    return ((AbstractBundle)bundle).getStartLevel();
  }
  
  public void setBundleStartLevel(Bundle bundle, int newSL)
  {
    String exceptionText = null;
    if (bundle.getBundleId() == 0L) {
      exceptionText = Msg.STARTLEVEL_CANT_CHANGE_SYSTEMBUNDLE_STARTLEVEL;
    } else if (bundle.getState() == 1) {
      exceptionText = NLS.bind(Msg.BUNDLE_UNINSTALLED_EXCEPTION, ((AbstractBundle)bundle).getBundleData().getLocation());
    } else if (newSL <= 0) {
      exceptionText = NLS.bind(Msg.STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL, newSL);
    }
    if (exceptionText != null) {
      throw new IllegalArgumentException(exceptionText);
    }
    framework.checkAdminPermission(bundle, "execute");
    try
    {
      if (newSL != ((AbstractBundle)bundle).getInternalStartLevel())
      {
        final AbstractBundle b = (AbstractBundle)bundle;
        b.getBundleData().setStartLevel(newSL);
        try
        {
          AccessController.doPrivileged(new PrivilegedExceptionAction()
          {
            public Object run()
              throws Exception
            {
              b.getBundleData().save();
              return null;
            }
          });
        }
        catch (PrivilegedActionException e)
        {
          if ((e.getException() instanceof IOException)) {
            throw ((IOException)e.getException());
          }
          throw ((RuntimeException)e.getException());
        }
        issueEvent(new StartLevelEvent(0, newSL, (AbstractBundle)bundle, new FrameworkListener[0]));
      }
    }
    catch (IOException e)
    {
      framework.publishFrameworkEvent(2, bundle, e);
    }
  }
  
  private void issueEvent(StartLevelEvent sle)
  {
    ListenerQueue<Object, Object, StartLevelEvent> queue = new ListenerQueue(eventManager);
    
    queue.queueListeners(startLevelListeners.entrySet(), this);
    
    queue.dispatchEventAsynchronous(sle.getType(), sle);
  }
  
  public void dispatchEvent(Object listener, Object listenerObject, int eventAction, StartLevelEvent event)
  {
    try
    {
      switch (eventAction)
      {
      case 0: 
        setBundleSL(event);
        break;
      case 1: 
        doSetStartLevel(event.getNewSL(), event.getListeners());
      }
    }
    catch (Throwable t)
    {
      framework.adaptor.handleRuntimeError(t);
    }
  }
  
  protected void incFWSL(int incToSL, AbstractBundle[] launchBundles)
  {
    if (Debug.DEBUG_STARTLEVEL) {
      Debug.println("SLL: incFWSL: saving activeSL of " + incToSL);
    }
    saveActiveStartLevel(incToSL);
    
    resumeBundles(launchBundles, incToSL);
  }
  
  AbstractBundle[] getInstalledBundles(BundleRepository bundles, boolean sortByDependency)
  {
    synchronized (bundles)
    {
      List<AbstractBundle> allBundles = bundles.getBundles();
      AbstractBundle[] installedBundles = new AbstractBundle[allBundles.size()];
      allBundles.toArray(installedBundles);
      
      Util.sort(installedBundles, 0, installedBundles.length);
      if (sortByDependency) {
        sortByDependency(installedBundles);
      }
    }
    AbstractBundle[] installedBundles;
    return installedBundles;
  }
  
  void sortByDependency(AbstractBundle[] bundles)
  {
    synchronized (framework.bundles)
    {
      if (bundles.length <= 1) {
        return;
      }
      int currentSL = bundles[0].getInternalStartLevel();
      int currentSLindex = 0;
      boolean lazy = false;
      for (int i = 0; i < bundles.length; i++)
      {
        if (currentSL != bundles[i].getInternalStartLevel())
        {
          if (lazy) {
            sortByDependencies(bundles, currentSLindex, i);
          }
          currentSL = bundles[i].getInternalStartLevel();
          currentSLindex = i;
          lazy = false;
        }
        lazy |= (bundles[i].getBundleData().getStatus() & 0x2) != 0;
      }
      if (lazy) {
        sortByDependencies(bundles, currentSLindex, bundles.length);
      }
    }
  }
  
  private void sortByDependencies(AbstractBundle[] bundles, int start, int end)
  {
    if (end - start <= 1) {
      return;
    }
    List<BundleDescription> descList = new ArrayList(end - start);
    List<AbstractBundle> missingDescs = new ArrayList(0);
    for (int i = start; i < end; i++)
    {
      BundleDescription desc = bundles[i].getBundleDescription();
      if (desc != null) {
        descList.add(desc);
      } else {
        missingDescs.add(bundles[i]);
      }
    }
    if (descList.size() <= 1) {
      return;
    }
    BundleDescription[] descriptions = (BundleDescription[])descList.toArray(new BundleDescription[descList.size()]);
    framework.adaptor.getPlatformAdmin().getStateHelper().sortBundles(descriptions);
    for (int i = start; i < descriptions.length + start; i++) {
      bundles[i] = framework.bundles.getBundle(descriptions[(i - start)].getBundleId());
    }
    if (missingDescs.size() > 0)
    {
      Iterator<AbstractBundle> missing = missingDescs.iterator();
      for (int i = start + descriptions.length; (i < end) && (missing.hasNext()); i++) {
        bundles[i] = ((AbstractBundle)missing.next());
      }
    }
  }
  
  private void resumeBundles(AbstractBundle[] launch, int currentSL)
  {
    resumeBundles(launch, true, currentSL);
    
    resumeBundles(launch, false, currentSL);
  }
  
  private void resumeBundles(AbstractBundle[] launch, boolean lazyOnly, int currentSL)
  {
    for (int i = 0; (i < launch.length) && (!framework.isForcedRestart()); i++)
    {
      int bsl = launch[i].getInternalStartLevel();
      if (bsl >= currentSL)
      {
        if (bsl != currentSL) {
          brea
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-2017. Infinite Loop Ltd