org.eclipse.osgi_3.8.2.v20130124-134944

16:47:18.721 INFO  jd.cli.Main - Decompiling org.eclipse.osgi_3.8.2.v20130124-134944.jar
package org.eclipse.core.runtime.adaptor;

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

class EclipseStarter$1
  implements BundleListener
{
  private final Bundle val$systemBundle;
  
  EclipseStarter$1(Bundle paramBundle, Runnable paramRunnable) {}
  
  public void bundleChanged(BundleEvent event)
  {
    if ((event.getBundle() == val$systemBundle) && (event.getType() == 4)) {
      val$handler.run();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.adaptor.EclipseStarter.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.adaptor;

import java.net.URL;

class EclipseStarter$InitialBundle
{
  public final String locationString;
  public final URL location;
  public final int level;
  public final boolean start;
  
  EclipseStarter$InitialBundle(String locationString, URL location, int level, boolean start)
  {
    this.locationString = locationString;
    this.location = location;
    this.level = level;
    this.start = start;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.adaptor.EclipseStarter.InitialBundle
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.adaptor;

import org.eclipse.core.runtime.internal.adaptor.Semaphore;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.framework.SynchronousBundleListener;

class EclipseStarter$StartupEventListener
  implements SynchronousBundleListener, FrameworkListener
{
  private final Semaphore semaphore;
  private final int frameworkEventType;
  
  public EclipseStarter$StartupEventListener(Semaphore semaphore, int frameworkEventType)
  {
    this.semaphore = semaphore;
    this.frameworkEventType = frameworkEventType;
  }
  
  public void bundleChanged(BundleEvent event)
  {
    if ((event.getBundle().getBundleId() == 0L) && (event.getType() == 256)) {
      semaphore.release();
    }
  }
  
  public void frameworkEvent(FrameworkEvent event)
  {
    if (event.getType() == frameworkEventType) {
      semaphore.release();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.adaptor.EclipseStarter.StartupEventListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.adaptor;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.internal.adaptor.DefaultStartupMonitor;
import org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorMsg;
import org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher;
import org.eclipse.core.runtime.internal.adaptor.EclipseEnvironmentInfo;
import org.eclipse.core.runtime.internal.adaptor.LocationHelper;
import org.eclipse.core.runtime.internal.adaptor.MessageHelper;
import org.eclipse.core.runtime.internal.adaptor.Semaphore;
import org.eclipse.osgi.framework.adaptor.FilePath;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.framework.internal.core.ConsoleManager;
import org.eclipse.osgi.framework.internal.core.Constants;
import org.eclipse.osgi.framework.internal.core.Framework;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.internal.baseadaptor.BaseStorageHook;
import org.eclipse.osgi.internal.profile.Profile;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.osgi.service.resolver.ResolverError;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateHelper;
import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.eclipse.osgi.service.runnable.ApplicationLauncher;
import org.eclipse.osgi.service.runnable.StartupMonitor;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.framework.BundleListener;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.SynchronousBundleListener;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.startlevel.StartLevel;

public class EclipseStarter
{
  private static FrameworkAdaptor adaptor;
  private static BundleContext context;
  private static boolean initialize = false;
  public static boolean debug = false;
  private static boolean running = false;
  private static Framework framework = null;
  private static ServiceRegistration<?> defaultMonitorRegistration = null;
  private static ServiceRegistration<?> appLauncherRegistration = null;
  private static ServiceRegistration<?> splashStreamRegistration = null;
  private static final String CLEAN = "-clean";
  private static final String CONSOLE = "-console";
  private static final String CONSOLE_LOG = "-consoleLog";
  private static final String DEBUG = "-debug";
  private static final String INITIALIZE = "-initialize";
  private static final String DEV = "-dev";
  private static final String WS = "-ws";
  private static final String OS = "-os";
  private static final String ARCH = "-arch";
  private static final String NL = "-nl";
  private static final String NL_EXTENSIONS = "-nlExtensions";
  private static final String CONFIGURATION = "-configuration";
  private static final String USER = "-user";
  private static final String NOEXIT = "-noExit";
  private static final String LAUNCHER = "-launcher";
  private static final String DATA = "-data";
  public static final String PROP_BUNDLES = "osgi.bundles";
  public static final String PROP_BUNDLES_STARTLEVEL = "osgi.bundles.defaultStartLevel";
  public static final String PROP_EXTENSIONS = "osgi.framework.extensions";
  public static final String PROP_INITIAL_STARTLEVEL = "osgi.startLevel";
  public static final String PROP_DEBUG = "osgi.debug";
  public static final String PROP_DEV = "osgi.dev";
  public static final String PROP_CLEAN = "osgi.clean";
  public static final String PROP_CONSOLE = "osgi.console";
  public static final String PROP_CONSOLE_CLASS = "osgi.consoleClass";
  public static final String PROP_CHECK_CONFIG = "osgi.checkConfiguration";
  public static final String PROP_OS = "osgi.os";
  public static final String PROP_WS = "osgi.ws";
  public static final String PROP_NL = "osgi.nl";
  private static final String PROP_NL_EXTENSIONS = "osgi.nl.extensions";
  public static final String PROP_ARCH = "osgi.arch";
  public static final String PROP_ADAPTOR = "osgi.adaptor";
  public static final String PROP_SYSPATH = "osgi.syspath";
  public static final String PROP_LOGFILE = "osgi.logfile";
  public static final String PROP_FRAMEWORK = "osgi.framework";
  public static final String PROP_INSTALL_AREA = "osgi.install.area";
  public static final String PROP_FRAMEWORK_SHAPE = "osgi.framework.shape";
  public static final String PROP_NOSHUTDOWN = "osgi.noShutdown";
  private static final String PROP_FORCED_RESTART = "osgi.forcedRestart";
  public static final String PROP_EXITCODE = "eclipse.exitcode";
  public static final String PROP_EXITDATA = "eclipse.exitdata";
  public static final String PROP_CONSOLE_LOG = "eclipse.consoleLog";
  public static final String PROP_IGNOREAPP = "eclipse.ignoreApp";
  public static final String PROP_REFRESH_BUNDLES = "eclipse.refreshBundles";
  private static final String PROP_ALLOW_APPRELAUNCH = "eclipse.allowAppRelaunch";
  private static final String PROP_APPLICATION_LAUNCHDEFAULT = "eclipse.application.launchDefault";
  private static final String FILE_SCHEME = "file:";
  private static final String REFERENCE_SCHEME = "reference:";
  private static final String REFERENCE_PROTOCOL = "reference";
  private static final String INITIAL_LOCATION = "initial@";
  protected static final String DEFAULT_ADAPTOR_CLASS = "org.eclipse.osgi.baseadaptor.BaseAdaptor";
  private static final int DEFAULT_INITIAL_STARTLEVEL = 6;
  private static final String DEFAULT_BUNDLES_STARTLEVEL = "4";
  private static FrameworkLog log;
  private static Map<String, String[]> searchCandidates = new HashMap(4);
  private static EclipseAppLauncher appLauncher;
  private static List<Runnable> shutdownHandlers;
  private static ConsoleManager consoleMgr = null;
  
  public static void main(String[] args)
    throws Exception
  {
    if (FrameworkProperties.getProperty("eclipse.startTime") == null) {
      FrameworkProperties.setProperty("eclipse.startTime", Long.toString(System.currentTimeMillis()));
    }
    if (FrameworkProperties.getProperty("osgi.noShutdown") == null) {
      FrameworkProperties.setProperty("osgi.noShutdown", "true");
    }
    if (FrameworkProperties.getProperty(Constants.OSGI_COMPATIBILITY_BOOTDELEGATION) == null) {
      FrameworkProperties.setProperty(Constants.OSGI_COMPATIBILITY_BOOTDELEGATION, "false");
    }
    Object result = run(args, null);
    if (((result instanceof Integer)) && (!Boolean.valueOf(FrameworkProperties.getProperty("osgi.noShutdown")).booleanValue())) {
      System.exit(((Integer)result).intValue());
    }
  }
  
  public static Object run(String[] args, Runnable endSplashHandler)
    throws Exception
  {
    if (Profile.STARTUP) {
      Profile.logEnter("EclipseStarter.run()", null);
    }
    if (running) {
      throw new IllegalStateException(EclipseAdaptorMsg.ECLIPSE_STARTUP_ALREADY_RUNNING);
    }
    boolean startupFailed = true;
    try
    {
      startup(args, endSplashHandler);
      startupFailed = false;
      if ((Boolean.valueOf(FrameworkProperties.getProperty("eclipse.ignoreApp")).booleanValue()) || (isForcedRestart()))
      {
        FrameworkLogEntry logEntry;
        String report;
        return null;
      }
      FrameworkLogEntry logEntry;
      String report;
      return run(null);
    }
    catch (Throwable e)
    {
      if (endSplashHandler != null) {
        endSplashHandler.run();
      }
      FrameworkLogEntry logEntry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, startupFailed ? EclipseAdaptorMsg.ECLIPSE_STARTUP_STARTUP_ERROR : EclipseAdaptorMsg.ECLIPSE_STARTUP_APP_ERROR, 1, e, null);
      if (log != null) {
        log.log(logEntry);
      } else {
        e.printStackTrace();
      }
    }
    finally
    {
      try
      {
        FrameworkLogEntry logEntry;
        String report;
        if (isForcedRestart()) {
          FrameworkProperties.setProperty("eclipse.exitcode", "23");
        }
        if (!Boolean.valueOf(FrameworkProperties.getProperty("osgi.noShutdown")).booleanValue()) {
          shutdown();
        }
      }
      catch (Throwable e)
      {
        FrameworkLogEntry logEntry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_SHUTDOWN_ERROR, 1, e, null);
        if (log != null) {
          log.log(logEntry);
        } else {
          e.printStackTrace();
        }
      }
      if (Profile.STARTUP) {
        Profile.logExit("EclipseStarter.run()");
      }
      String report = Profile.getProfileLog();
      if ((report != null) && (report.length() > 0)) {
        System.out.println(report);
      }
    }
    if (FrameworkProperties.getProperty("eclipse.exitcode") == null)
    {
      FrameworkProperties.setProperty("eclipse.exitcode", "13");
      FrameworkProperties.setProperty("eclipse.exitdata", NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_CHECK_LOG, log == null ? null : log.getFile().getPath()));
    }
    return null;
  }
  
  public static boolean isRunning()
  {
    return running;
  }
  
  public static BundleContext startup(String[] args, Runnable endSplashHandler)
    throws Exception
  {
    if (Profile.STARTUP) {
      Profile.logEnter("EclipseStarter.startup()", null);
    }
    if (running) {
      throw new IllegalStateException(EclipseAdaptorMsg.ECLIPSE_STARTUP_ALREADY_RUNNING);
    }
    FrameworkProperties.initializeProperties();
    processCommandLine(args);
    LocationManager.initializeLocations();
    loadConfigurationInfo();
    finalizeProperties();
    
    Profile.initProps();
    if (Profile.STARTUP) {
      Profile.logTime("EclipseStarter.startup()", "props inited");
    }
    adaptor = createAdaptor();
    log = adaptor.getFrameworkLog();
    if (Profile.STARTUP) {
      Profile.logTime("EclipseStarter.startup()", "adapter created");
    }
    framework = new Framework(adaptor);
    if (Profile.STARTUP) {
      Profile.logTime("EclipseStarter.startup()", "OSGi created");
    }
    context = framework.getBundle(0L).getBundleContext();
    registerFrameworkShutdownHandlers();
    publishSplashScreen(endSplashHandler);
    if (Profile.STARTUP) {
      Profile.logTime("EclipseStarter.startup()", "osgi launched");
    }
    consoleMgr = ConsoleManager.startConsole(framework);
    if (Profile.STARTUP) {
      Profile.logTime("EclipseStarter.startup()", "console started");
    }
    framework.launch();
    
    long stateStamp = adaptor.getState().getTimeStamp();
    Bundle[] startBundles = loadBasicBundles();
    if ((startBundles == null) || (("true".equals(FrameworkProperties.getProperty("eclipse.refreshBundles"))) && (refreshPackages(getCurrentBundles(false)))))
    {
      waitForShutdown();
      return context;
    }
    if (Profile.STARTUP) {
      Profile.logTime("EclipseStarter.startup()", "loading basic bundles");
    }
    setStartLevel(getStartLevel());
    if (Profile.STARTUP) {
      Profile.logTime("EclipseStarter.startup()", "StartLevel set");
    }
    ensureBundlesActive(startBundles);
    try
    {
      consoleMgr.checkForConsoleBundle();
    }
    catch (BundleException e)
    {
      FrameworkLogEntry entry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, e.getMessage(), 0, e, null);
      log.log(entry);
    }
    if ((debug) || (FrameworkProperties.getProperty("osgi.dev") != null)) {
      if (stateStamp != adaptor.getState().getTimeStamp()) {
        logUnresolvedBundles(context.getBundles());
      }
    }
    running = true;
    if (Profile.STARTUP) {
      Profile.logExit("EclipseStarter.startup()");
    }
    return context;
  }
  
  private static int getStartLevel()
  {
    String level = FrameworkProperties.getProperty("osgi.startLevel");
    if (level != null) {
      try
      {
        return Integer.parseInt(level);
      }
      catch (NumberFormatException localNumberFormatException)
      {
        if (debug) {
          System.out.println("Start level = " + level + "  parsed. Using hardcoded default: 6");
        }
      }
    }
    return 6;
  }
  
  public static Object run(Object argument)
    throws Exception
  {
    if (Profile.STARTUP) {
      Profile.logEnter("EclipseStarter.run(Object)()", null);
    }
    if (!running) {
      throw new IllegalStateException(EclipseAdaptorMsg.ECLIPSE_STARTUP_NOT_RUNNING);
    }
    if (initialize) {
      return new Integer(0);
    }
    try
    {
      if (appLauncher == null)
      {
        boolean launchDefault = Boolean.valueOf(FrameworkProperties.getProperty("eclipse.application.launchDefault", "true")).booleanValue();
        
        appLauncher = new EclipseAppLauncher(context, Boolean.valueOf(FrameworkProperties.getProperty("eclipse.allowAppRelaunch")).booleanValue(), launchDefault, log);
        appLauncherRegistration = context.registerService(ApplicationLauncher.class.getName(), appLauncher, null);
        
        return appLauncher.start(argument);
      }
      return appLauncher.reStart(argument);
    }
    catch (Exception e)
    {
      if ((log != null) && (context != null)) {
        logUnresolvedBundles(context.getBundles());
      }
      throw e;
    }
  }
  
  public static void shutdown()
    throws Exception
  {
    if ((!running) || (framework == null)) {
      return;
    }
    if (appLauncherRegistration != null) {
      appLauncherRegistration.unregister();
    }
    if (splashStreamRegistration != null) {
      splashStreamRegistration.unregister();
    }
    if (defaultMonitorRegistration != null) {
      defaultMonitorRegistration.unregister();
    }
    if (appLauncher != null) {
      appLauncher.shutdown();
    }
    appLauncherRegistration = null;
    appLauncher = null;
    splashStreamRegistration = null;
    defaultMonitorRegistration = null;
    if (consoleMgr != null)
    {
      consoleMgr.stopConsole();
      consoleMgr = null;
    }
    framework.close();
    framework = null;
    context = null;
    running = false;
  }
  
  /* Error */
  private static void ensureBundlesActive(Bundle[] bundles)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: iconst_0
    //   3: istore_2
    //   4: goto +189 -> 193
    //   7: aload_0
    //   8: iload_2
    //   9: aaload
    //   10: invokeinterface 1551 1 0
    //   15: bipush 32
    //   17: if_icmpeq +173 -> 190
    //   20: aload_0
    //   21: iload_2
    //   22: aaload
    //   23: invokeinterface 1551 1 0
    //   28: iconst_2
    //   29: if_icmpne +43 -> 72
    //   32: getstatic 1297	org/eclipse/core/runtime/adaptor/EclipseStarter:log	Lorg/eclipse/osgi/framework/log/FrameworkLog;
    //   35: new 808	org/eclipse/osgi/framework/log/FrameworkLogEntry
    //   38: dup
    //   39: ldc_w 723
    //   42: iconst_4
    //   43: iconst_0
    //   44: getstatic 1311	org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg:ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED	Ljava/lang/String;
    //   47: aload_0
    //   48: iload_2
    //   49: aaload
    //   50: invokeinterface 1555 1 0
    //   55: invokestatic 1502	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   58: iconst_0
    //   59: aconst_null
    //   60: aconst_null
    //   61: invokespecial 1491	org/eclipse/osgi/framework/log/FrameworkLogEntry:<init>	(Ljava/lang/String;IILjava/lang/String;ILjava/lang/Throwable;[Lorg/eclipse/osgi/framework/log/FrameworkLogEntry;)V
    //   64: invokeinterface 1536 2 0
    //   69: goto +121 -> 190
    //   72: aload_1
    //   73: ifnonnull +55 -> 128
    //   76: new 828	org/osgi/util/tracker/ServiceTracker
    //   79: dup
    //   80: getstatic 1298	org/eclipse/core/runtime/adaptor/EclipseStarter:context	Lorg/osgi/framework/BundleContext;
    //   83: getstatic 1285	org/eclipse/core/runtime/adaptor/EclipseStarter:class$1	Ljava/lang/Class;
    //   86: dup
    //   87: ifnonnull +29 -> 116
    //   90: pop
    //   91: ldc_w 727
    //   94: invokestatic 1344	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   97: dup
    //   98: putstatic 1285	org/eclipse/core/runtime/adaptor/EclipseStarter:class$1	Ljava/lang/Class;
    //   101: goto +15 -> 116
    //   104: new 759	java/lang/NoClassDefFoundError
    //   107: dup_x1
    //   108: swap
    //   109: invokevirtual 1382	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   112: invokespecial 1354	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   115: athrow
    //   116: invokevirtual 1342	java/lang/Class:getName	()Ljava/lang/String;
    //   119: aconst_null
    //   120: invokespecial 1507	org/osgi/util/tracker/ServiceTracker:<init>	(Lorg/osgi/framework/BundleContext;Ljava/lang/String;Lorg/osgi/util/tracker/ServiceTrackerCustomizer;)V
    //   123: astore_1
    //   124: aload_1
    //   125: invokevirtual 1505	org/osgi/util/tracker/ServiceTracker:open	()V
    //   128: aload_1
    //   129: invokevirtual 1506	org/osgi/util/tracker/ServiceTracker:getService	()Ljava/lang/Object;
    //   132: checkcast 827	org/osgi/service/startlevel/StartLevel
    //   135: astore_3
    //   136: aload_3
    //   137: ifnull +53 -> 190
    //   140: aload_3
    //   141: aload_0
    //   142: iload_2
    //   143: aaload
    //   144: invokeinterface 1574 2 0
    //   149: aload_3
    //   150: invokeinterface 1572 1 0
    //   155: if_icmpgt +35 -> 190
    //   158: getstatic 1297	org/eclipse/core/runtime/adaptor/EclipseStarter:log	Lorg/eclipse/osgi/framework/log/FrameworkLog;
    //   161: new 808	org/eclipse/osgi/framework/log/FrameworkLogEntry
    //   164: dup
    //   165: ldc_w 723
    //   168: iconst_4
    //   169: iconst_0
    //   170: getstatic 1310	org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg:ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_ACTIVE	Ljava/lang/String;
    //   173: aload_0
    //   174: iload_2
    //   175: aaload
    //   176: invokestatic 1502	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   179: iconst_0
    //   180: aconst_null
    //   181: aconst_null
    //   182: invokespecial 1491	org/eclipse/osgi/framework/log/FrameworkLogEntry:<init>	(Ljava/lang/String;IILjava/lang/String;ILjava/lang/Throwable;[Lorg/eclipse/osgi/framework/log/FrameworkLogEntry;)V
    //   185: invokeinterface 1536 2 0
    //   190: iinc 2 1
    //   193: iload_2
    //   194: aload_0
    //   195: arraylength
    //   196: if_icmplt -189 -> 7
    //   199: goto +16 -> 215
    //   202: astore 4
    //   204: aload_1
    //   205: ifnull +7 -> 212
    //   208: aload_1
    //   209: invokevirtual 1504	org/osgi/util/tracker/ServiceTracker:close	()V
    //   212: aload 4
    //   214: athrow
    //   215: aload_1
    //   216: ifnull +7 -> 223
    //   219: aload_1
    //   220: invokevirtual 1504	org/osgi/util/tracker/ServiceTracker:close	()V
    //   223: return
    // Line number table:
    //   Java source line #406	-> byte code offset #0
    //   Java source line #408	-> byte code offset #2
    //   Java source line #409	-> byte code offset #7
    //   Java source line #410	-> byte code offset #20
    //   Java source line #412	-> byte code offset #32
    //   Java source line #413	-> byte code offset #69
    //   Java source line #416	-> byte code offset #72
    //   Java source line #417	-> byte code offset #76
    //   Java source line #418	-> byte code offset #124
    //   Java source line #420	-> byte code offset #128
    //   Java source line #421	-> byte code offset #136
    //   Java source line #422	-> byte code offset #158
    //   Java source line #408	-> byte code offset #190
    //   Java source line #426	-> byte code offset #199
    //   Java source line #427	-> byte code offset #204
    //   Java source line #428	-> byte code offset #208
    //   Java source line #429	-> byte code offset #212
    //   Java source line #427	-> byte code offset #215
    //   Java source line #428	-> byte code offset #219
    //   Java source line #430	-> byte code offset #223
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	224	0	bundles	Bundle[]
    //   1	219	1	tracker	org.osgi.util.tracker.ServiceTracker<StartLevel, StartLevel>
    //   3	191	2	i	int
    //   135	15	3	sl	StartLevel
    //   202	11	4	localObject	Object
    //   104	1	5	localClassNotFoundException	ClassNotFoundException
    // Exception table:
    //   from	to	target	type
    //   91	97	104	java/lang/ClassNotFoundException
    //   2	202	202	finally
  }
  
  private static void logUnresolvedBundles(Bundle[] bundles)
  {
    State state = adaptor.getState();
    FrameworkLog logService = adaptor.getFrameworkLog();
    StateHelper stateHelper = adaptor.getPlatformAdmin().getStateHelper();
    
    VersionConstraint[] leafConstraints = stateHelper.getUnsatisfiedLeaves(state.getBundles());
    
    Map<BundleDescription, List<VersionConstraint>> missing = new HashMap();
    for (int i = 0; i < leafConstraints.length; i++) {
      if ((!(leafConstraints[i] instanceof BundleSpecification)) || (!((BundleSpecification)leafConstraints[i]).isOptional())) {
        if ((leafConstraints[i] instanceof ImportPackageSpecification))
        {
          if (!"optional".equals(((ImportPackageSpecification)leafConstraints[i]).getDirective("resolution"))) {
            if ("dynamic".equals(((ImportPackageSpecification)leafConstraints[i]).getDirective("resolution"))) {}
          }
        }
        else
        {
          BundleDescription bundle = leafConstraints[i].getBundle();
          List<VersionConstraint> constraints = (List)missing.get(bundle);
          if (constraints == null)
          {
            constraints = new ArrayList();
            missing.put(bundle, constraints);
          }
          constraints.add(leafConstraints[i]);
        }
      }
    }
    if (missing.size() > 0)
    {
      FrameworkLogEntry[] rootChildren = new FrameworkLogEntry[missing.size()];
      int rootIndex = 0;
      for (Iterator<BundleDescription> iter = missing.keySet().iterator(); iter.hasNext(); rootIndex++)
      {
        BundleDescription description = (BundleDescription)iter.next();
        String symbolicName = description.getSymbolicName() == null ? "org.eclipse.osgi" : description.getSymbolicName();
        String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, description.getLocation());
        List<VersionConstraint> constraints = (List)missing.get(description);
        FrameworkLogEntry[] logChildren = new FrameworkLogEntry[constraints.size()];
        for (int i = 0; i < logChildren.length; i++) {
          logChildren[i] = new FrameworkLogEntry(symbolicName, 2, 0, MessageHelper.getResolutionFailureMessage((VersionConstraint)constraints.get(i)), 0, null, null);
        }
        rootChildren[rootIndex] = new FrameworkLogEntry("org.eclipse.osgi", 2, 0, generalMessage, 0, null, logChildren);
      }
      logService.log(new FrameworkLogEntry("org.eclipse.osgi", 2, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ROOTS_NOT_RESOLVED, 0, null, rootChildren));
    }
    List<FrameworkLogEntry> allChildren = new ArrayList();
    for (int i = 0; i < bundles.length; i++) {
      if (bundles[i].getState() == 2)
      {
        String symbolicName = bundles[i].getSymbolicName() == null ? "org.eclipse.osgi" : bundles[i].getSymbolicName();
        String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, bundles[i]);
        BundleDescription description = state.getBundle(bundles[i].getBundleId());
        if (description != null)
        {
          FrameworkLogEntry[] logChildren = null;
          VersionConstraint[] unsatisfied = stateHelper.getUnsatisfiedConstraints(description);
          if (unsatisfied.length > 0)
          {
            logChildren = new FrameworkLogEntry[unsatisfied.length];
            for (int j = 0; j < unsatisfied.length; j++) {
              logChildren[j] = new FrameworkLogEntry(symbolicName, 2, 0, MessageHelper.getResolutionFailureMessage(unsatisfied[j]), 0, null, null);
            }
          }
          else
          {
            ResolverError[] resolverErrors = state.getResolverErrors(description);
            if (resolverErrors.length > 0)
            {
              logChildren = new FrameworkLogEntry[resolverErrors.length];
              for (int j = 0; j < resolverErrors.length; j++) {
                logChildren[j] = new FrameworkLogEntry(symbolicName, 2, 0, resolverErrors[j].toString(), 0, null, null);
              }
            }
          }
          allChildren.add(new FrameworkLogEntry("org.eclipse.osgi", 2, 0, generalMessage, 0, null, logChildren));
        }
      }
    }
    if (allChildren.size() > 0) {
      logService.log(new FrameworkLogEntry("org.eclipse.osgi", 2, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ALL_NOT_RESOLVED, 0, null, (FrameworkLogEntry[])allChildren.toArray(new FrameworkLogEntry[allChildren.size()])));
    }
  }
  
  private static void publishSplashScreen(Runnable endSplashHandler)
  {
    if (endSplashHandler == null) {
      return;
    }
    try
    {
      Method method = endSplashHandler.getClass().getMethod("getOutputStream", new Class[0]);
      Object outputStream = method.invoke(endSplashHandler, new Object[0]);
      if ((outputStream instanceof OutputStream))
      {
        Dictionary<String, Object> osProperties = new Hashtable();
        osProperties.put("name", "splashstream");
        splashStreamRegistration = context.registerService(OutputStream.class.getName(), outputStream, osProperties);
      }
    }
    catch (Exception localException) {}
    try
    {
      Dictionary<String, Object> monitorProps = new Hashtable();
      monitorProps.put("service.ranking", new Integer(Integer.MIN_VALUE));
      defaultMonitorRegistration = context.registerService(StartupMonitor.class.getName(), new DefaultStartupMonitor(endSplashHandler), monitorProps);
    }
    catch (IllegalStateException localIllegalStateException) {}
  }
  
  private static URL searchForBundle(String name, String parent)
    throws MalformedURLException
  {
    URL url = null;
    File fileLocation = null;
    boolean reference = false;
    try
    {
      new URL(name);
      url = new URL(new File(parent).toURL(), name);
    }
    catch (MalformedURLException localMalformedURLException)
    {
      File child = new File(name);
      fileLocation = child.isAbsolute() ? child : new File(parent, name);
      url = new URL("reference", null, fileLocation.toURL().toExternalForm());
      reference = true;
    }
    if (!reference)
    {
      URL baseURL = url;
      if (url.getProtocol().equals("reference"))
      {
        reference = true;
        String baseSpec = url.getFile();
        if (baseSpec.startsWith("file:"))
        {
          File child = new File(baseSpec.substring(5));
          baseURL = child.isAbsolute() ? child.toURL() : new File(parent, child.getPath()).toURL();
        }
        else
        {
          baseURL = new URL(baseSpec);
        }
      }
      fileLocation = new File(baseURL.getFile());
      if (!fileLocation.isAbsolute()) {
        fileLocation = new File(parent, fileLocation.toString());
      }
    }
    if (reference)
    {
      String result = searchFor(fileLocation.getName(), new File(fileLocation.getParent()).getAbsolutePath());
      if (result != null) {
        url = new URL("reference", null, "file:" + result);
      } else {
        return null;
      }
    }
    try
    {
      URLConnection result = url.openConnection();
      result.connect();
      return url;
    }
    catch (IOException localIOException) {}
    return null;
  }
  
  private static Bundle[] loadBasicBundles()
  {
    long startTime = System.currentTimeMillis();
    String osgiBundles = FrameworkProperties.getProperty("osgi.bundles");
    String osgiExtensions = FrameworkProperties.getProperty("osgi.framework.extensions");
    if ((osgiExtensions != null) && (osgiExtensions.length() > 0))
    {
      osgiBundles = osgiExtensions + ',' + osgiBundles;
      FrameworkProperties.setProperty("osgi.bundles", osgiBundles);
    }
    String[] installEntries = getArrayFromList(osgiBundles, ",");
    
    InitialBundle[] initialBundles = getInitialBundles(installEntries);
    
    Bundle[] curInitBundles = getCurrentBundles(true);
    
    List<Bundle> toRefresh = new ArrayList(curInitBundles.length);
    
    uninstallBundles(curInitBundles, initialBundles, toRefresh);
    
    List<Bundle> startBundles = new ArrayList(installEntries.length);
    List<Bundle> lazyActivationBundles = new ArrayList(installEntries.length);
    installBundles(initialBundles, curInitBundles, startBundles, lazyActivationBundles, toRefresh);
    if ((!toRefresh.isEmpty()) && (refreshPackages((Bundle[])toRefresh.toArray(new Bundle[toRefresh.size()])))) {
      return null;
    }
    Bundle[] startInitBundles = (Bundle[])startBundles.toArray(new Bundle[startBundles.size()]);
    Bundle[] lazyInitBundles = (Bundle[])lazyActivationBundles.toArray(new Bundle[lazyActivationBundles.size()]);
    startBundles(startInitBundles, lazyInitBundles);
    if (debug) {
      System.out.println("Time to load bundles: " + (System.currentTimeMillis() - startTime));
    }
    return startInitBundles;
  }
  
  private static InitialBundle[] getInitialBundles(String[] installEntries)
  {
    searchCandidates.clear();
    List<InitialBundle> result = new ArrayList(installEntries.length);
    int defaultStartLevel = Integer.parseInt(FrameworkProperties.getProperty("osgi.bundles.defaultStartLevel", "4"));
    String syspath = getSysPath();
    try
    {
      syspath = new File(syspath).getCanonicalPath();
    }
    catch (IOException localIOException1) {}
    for (int i = 0; i < installEntries.length; i++)
    {
      String name = installEntries[i];
      int level = defaultStartLevel;
      boolean start = false;
      int index = name.lastIndexOf('@');
      if (index >= 0)
      {
        String[] attributes = getArrayFromList(name.substring(index + 1, name.length()), ":");
        for (int j = 0; j < attributes.length; j++)
        {
          String attribute = attributes[j];
          if (attribute.equals("start")) {
            start = true;
          } else {
            try
            {
              level = Integer.parseInt(attribute);
            }
            catch (NumberFormatException localNumberFormatException)
            {
              index = name.length();
            }
          }
        }
        name = name.substring(0, index);
      }
      try
      {
        URL location = searchForBundle(name, syspath);
        if (location == null)
        {
          FrameworkLogEntry entry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_BUNDLE_NOT_FOUND, installEntries[i]), 0, null, null);
          log.log(entry);
        }
        else
        {
          location = makeRelative(LocationManager.getInstallLocation().getURL(), location);
          String locationString = "initial@" + location.toExternalForm();
          result.add(new InitialBundle(locationString, location, level, start));
        }
      }
      catch (IOException e)
      {
        log.log(new FrameworkLogEntry("org.eclipse.osgi", 4, 0, e.getMessage(), 0, e, null));
      }
    }
    return (InitialBundle[])result.toArray(new InitialBundle[result.size()]);
  }
  
  private static boolean refreshPackages(Bundle[] bundles)
  {
    ServiceReference<?> packageAdminRef = context.getServiceReference(PackageAdmin.class.getName());
    PackageAdmin packageAdmin = null;
    if (packageAdminRef != null) {
      packageAdmin = (PackageAdmin)context.getService(packageAdminRef);
    }
    if (packageAdmin == null) {
      return false;
    }
    Semaphore semaphore = new Semaphore(0);
    StartupEventListener listener = new StartupEventListener(semaphore, 4);
    context.addFrameworkListener(listener);
    context.addBundleListener(listener);
    packageAdmin.refreshPackages(bundles);
    context.ungetService(packageAdminRef);
    updateSplash(semaphore, listener);
    if (isForcedRestart()) {
      return true;
    }
    return false;
  }
  
  private static void waitForShutdown()
  {
    if (!isForcedRestart()) {
      return;
    }
    Bundle systemBundle = framework.getBundle(0L);
    int i = 0;
    while ((i < 5000) && ((systemBundle.getState() & 0x38) != 0))
    {
      i += 200;
      try
      {
        Thread.sleep(200L);
      }
      catch (InterruptedException localInterruptedException)
      {
        break;
      }
    }
  }
  
  private static FrameworkAdaptor createAdaptor()
    throws Exception
  {
    String adaptorClassName = FrameworkProperties.getProperty("osgi.adaptor", "org.eclipse.osgi.baseadaptor.BaseAdaptor");
    Class<?> adaptorClass = Class.forName(adaptorClassName);
    Class[] constructorArgs = { String[].class };
    Constructor<?> constructor = adaptorClass.getConstructor(constructorArgs);
    return (FrameworkAdaptor)constructor.newInstance(new Object[] { new String[0] });
  }
  
  private static String[] processCommandLine(String[] args)
    throws Exception
  {
    EclipseEnvironmentInfo.setAllArgs(args);
    if (args.length == 0)
    {
      EclipseEnvironmentInfo.setFrameworkArgs(args);
      EclipseEnvironmentInfo.setAllArgs(args);
      return args;
    }
    int[] configArgs = new int[args.length];
    configArgs[0] = -1;
    int configArgIndex = 0;
    for (int i = 0; i < args.length; i++)
    {
      boolean found = false;
      if ((args[i].equalsIgnoreCase("-debug")) && ((i + 1 == args.length) || ((i + 1 < args.length) && (args[(i + 1)].startsWith("-")))))
      {
        FrameworkProperties.setProperty("osgi.debug", "");
        debug = true;
        found = true;
      }
      if ((args[i].equalsIgnoreCase("-dev")) && ((i + 1 == args.length) || ((i + 1 < args.length) && (args[(i + 1)].startsWith("-")))))
      {
        FrameworkProperties.setProperty("osgi.dev", "");
        found = true;
      }
      if (args[i].equalsIgnoreCase("-initialize"))
      {
        initialize = true;
        found = true;
      }
      if (args[i].equalsIgnoreCase("-clean"))
      {
        FrameworkProperties.setProperty("osgi.clean", "true");
        found = true;
      }
      if (args[i].equalsIgnoreCase("-consoleLog"))
      {
        FrameworkProperties.setProperty("eclipse.consoleLog", "true");
        found = true;
      }
      if ((args[i].equalsIgnoreCase("-console")) && ((i + 1 == args.length) || ((i + 1 < args.length) && (args[(i + 1)].startsWith("-")))))
      {
        FrameworkProperties.setProperty("osgi.console", "");
        found = true;
      }
      if (args[i].equalsIgnoreCase("-noExit"))
      {
        FrameworkProperties.setProperty("osgi.noShutdown", "true");
        found = true;
      }
      if (found)
      {
        configArgs[(configArgIndex++)] = i;
      }
      else if ((i != args.length - 1) && (!args[(i + 1)].startsWith("-")))
      {
        String arg = args[(++i)];
        if (args[(i - 1)].equalsIgnoreCase("-console"))
        {
          FrameworkProperties.setProperty("osgi.console", arg);
          found = true;
        }
        if (args[(i - 1)].equalsIgnoreCase("-configuration"))
        {
          FrameworkProperties.setProperty("osgi.configuration.area", arg);
          found = true;
        }
        if (args[(i - 1)].equalsIgnoreCase("-data"))
        {
          FrameworkProperties.setProperty("osgi.instance.area", arg);
          found = true;
        }
        if (args[(i - 1)].equalsIgnoreCase("-user"))
        {
          FrameworkProperties.setProperty("osgi.user.area", arg);
          found = true;
        }
        if (args[(i - 1)].equalsIgnoreCase("-launcher"))
        {
          FrameworkProperties.setProperty("eclipse.launcher", arg);
          found = true;
        }
        if (args[(i - 1)].equalsIgnoreCase("-dev"))
        {
          FrameworkProperties.setProperty("osgi.dev", arg);
          found = true;
        }
        if (args[(i - 1)].equalsIgnoreCase("-debug"))
        {
          FrameworkProperties.setProperty("osgi.debug", arg);
          debug = true;
          found = true;
        }
        if (args[(i - 1)].equa
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