org.eclipse.equinox.simpleconfigurator_1.0.301.v20120914-163612

16:44:50.670 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.simpleconfigurator_1.0.301.v20120914-163612.jar
package org.eclipse.equinox.internal.provisional.configurator;

import java.io.IOException;
import java.net.URL;

public abstract interface Configurator
{
  public abstract void applyConfiguration(URL paramURL)
    throws IOException;
  
  public abstract void applyConfiguration()
    throws IOException;
  
  public abstract URL getUrlInUse();
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.provisional.configurator.Configurator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator;

import java.util.Dictionary;
import java.util.Hashtable;
import org.eclipse.equinox.internal.provisional.configurator.Configurator;
import org.eclipse.equinox.internal.simpleconfigurator.utils.EquinoxUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

public class Activator
  implements BundleActivator
{
  public static final boolean DEBUG = false;
  private ServiceRegistration configuratorRegistration;
  private ServiceRegistration commandRegistration;
  
  public void start(BundleContext context)
    throws Exception
  {
    SimpleConfiguratorImpl bundleConfigurator = new SimpleConfiguratorImpl(context, context.getBundle());
    bundleConfigurator.applyConfiguration();
    
    Dictionary props = new Hashtable();
    props.put("service.vendor", "Eclipse");
    props.put("service.pid", "org.eclipse.equinox.simpleconfigurator");
    ServiceFactory configurationFactory = new SimpleConfiguratorFactory(context);
    configuratorRegistration = context.registerService(Configurator.class.getName(), configurationFactory, props);
    try
    {
      if (context.getBundle().loadClass("org.eclipse.osgi.framework.console.CommandProvider") != null) {
        commandRegistration = EquinoxUtils.registerConsoleCommands(context);
      }
    }
    catch (ClassNotFoundException localClassNotFoundException2) {}
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    if (configuratorRegistration != null)
    {
      configuratorRegistration.unregister();
      configuratorRegistration = null;
    }
    if (commandRegistration != null)
    {
      commandRegistration.unregister();
      commandRegistration = null;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.Activator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator;

import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;

class ConfigApplier$1
  implements FrameworkListener
{
  final ConfigApplier this$0;
  private final boolean[] val$flag;
  
  ConfigApplier$1(ConfigApplier paramConfigApplier, boolean[] paramArrayOfBoolean)
  {
    this$0 = paramConfigApplier;val$flag = paramArrayOfBoolean;
  }
  
  public void frameworkEvent(FrameworkEvent event)
  {
    if (event.getType() == 4) {
      synchronized (val$flag)
      {
        val$flag[0] = true;
        val$flag.notifyAll();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.ConfigApplier.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo;
import org.eclipse.equinox.internal.simpleconfigurator.utils.EquinoxUtils;
import org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils;
import org.eclipse.equinox.internal.simpleconfigurator.utils.StateResolverUtils;
import org.eclipse.equinox.internal.simpleconfigurator.utils.Utils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.startlevel.StartLevel;

class ConfigApplier
{
  private static final String LAST_BUNDLES_INFO = "last.bundles.info";
  private static final String PROP_DEVMODE = "osgi.dev";
  private final BundleContext manipulatingContext;
  private final PackageAdmin packageAdminService;
  private final StartLevel startLevelService;
  private final boolean runningOnEquinox;
  private final boolean inDevMode;
  private final Bundle callingBundle;
  private final URI baseLocation;
  
  ConfigApplier(BundleContext context, Bundle callingBundle)
  {
    manipulatingContext = context;
    this.callingBundle = callingBundle;
    runningOnEquinox = "Eclipse".equals(context.getProperty("org.osgi.framework.vendor"));
    inDevMode = (manipulatingContext.getProperty("osgi.dev") != null);
    baseLocation = (runningOnEquinox ? EquinoxUtils.getInstallLocationURI(context) : null);
    
    ServiceReference packageAdminRef = manipulatingContext.getServiceReference(PackageAdmin.class.getName());
    if (packageAdminRef == null) {
      throw new IllegalStateException("No PackageAdmin service is available.");
    }
    packageAdminService = ((PackageAdmin)manipulatingContext.getService(packageAdminRef));
    
    ServiceReference startLevelRef = manipulatingContext.getServiceReference(StartLevel.class.getName());
    if (startLevelRef == null) {
      throw new IllegalStateException("No StartLevelService service is available.");
    }
    startLevelService = ((StartLevel)manipulatingContext.getService(startLevelRef));
  }
  
  void install(URL url, boolean exclusiveMode)
    throws IOException
  {
    List bundleInfoList = SimpleConfiguratorUtils.readConfiguration(url, baseLocation);
    if (bundleInfoList.size() == 0) {
      return;
    }
    BundleInfo[] expectedState = Utils.getBundleInfosFromList(bundleInfoList);
    
    String systemBundleSymbolicName = manipulatingContext.getBundle(0L).getSymbolicName();
    Version systemBundleVersion = manipulatingContext.getBundle(0L).getVersion();
    if (systemBundleSymbolicName != null) {
      for (int i = 0; i < expectedState.length; i++)
      {
        String symbolicName = expectedState[i].getSymbolicName();
        if (systemBundleSymbolicName.equals(symbolicName))
        {
          Version version = Version.parseVersion(expectedState[i].getVersion());
          if (!systemBundleVersion.equals(version)) {
            throw new IllegalStateException("The System Bundle was updated. The framework must be restarted to finalize the configuration change");
          }
        }
      }
    }
    HashSet toUninstall = null;
    if (!exclusiveMode)
    {
      BundleInfo[] lastInstalledBundles = getLastState();
      if (lastInstalledBundles != null)
      {
        toUninstall = new HashSet(Arrays.asList(lastInstalledBundles));
        toUninstall.removeAll(Arrays.asList(expectedState));
      }
      saveStateAsLast(url);
    }
    Collection prevouslyResolved = getResolvedBundles();
    Collection toRefresh = new ArrayList();
    Collection toStart = new ArrayList();
    if (exclusiveMode)
    {
      toRefresh.addAll(installBundles(expectedState, toStart));
      toRefresh.addAll(uninstallBundles(expectedState, packageAdminService));
    }
    else
    {
      toRefresh.addAll(installBundles(expectedState, toStart));
      if (toUninstall != null) {
        toRefresh.addAll(uninstallBundles(toUninstall));
      }
    }
    refreshPackages((Bundle[])toRefresh.toArray(new Bundle[toRefresh.size()]), manipulatingContext);
    if (toRefresh.size() > 0) {
      try
      {
        manipulatingContext.getBundle().loadClass("org.eclipse.osgi.service.resolver.PlatformAdmin");
        
        Bundle[] additionalRefresh = StateResolverUtils.getAdditionalRefresh(prevouslyResolved, manipulatingContext);
        if (additionalRefresh.length > 0) {
          refreshPackages(additionalRefresh, manipulatingContext);
        }
      }
      catch (ClassNotFoundException localClassNotFoundException) {}
    }
    startBundles((Bundle[])toStart.toArray(new Bundle[toStart.size()]));
  }
  
  private Collection getResolvedBundles()
  {
    Collection resolved = new HashSet();
    Bundle[] allBundles = manipulatingContext.getBundles();
    for (int i = 0; i < allBundles.length; i++) {
      if ((allBundles[i].getState() & 0x3) == 0) {
        resolved.add(allBundles[i]);
      }
    }
    return resolved;
  }
  
  private Collection uninstallBundles(HashSet toUninstall)
  {
    Collection removedBundles = new ArrayList(toUninstall.size());
    Bundle[] matchingBundles;
    int j;
    for (Iterator iterator = toUninstall.iterator(); iterator.hasNext(); (matchingBundles != null) && (j < matchingBundles.length))
    {
      BundleInfo current = (BundleInfo)iterator.next();
      matchingBundles = packageAdminService.getBundles(current.getSymbolicName(), getVersionRange(current.getVersion()));
      j = 0; continue;
      try
      {
        removedBundles.add(matchingBundles[j]);
        matchingBundles[j].uninstall();
      }
      catch (BundleException localBundleException) {}
      j++;
    }
    return removedBundles;
  }
  
  /* Error */
  private void saveStateAsLast(URL url)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aconst_null
    //   3: astore_3
    //   4: aload_0
    //   5: invokespecial 461	org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier:getLastBundleInfo	()Ljava/io/File;
    //   8: astore 4
    //   10: new 210	java/io/FileOutputStream
    //   13: dup
    //   14: aload 4
    //   16: invokespecial 427	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   19: astore_3
    //   20: aload_1
    //   21: invokevirtual 450	java/net/URL:openStream	()Ljava/io/InputStream;
    //   24: astore_2
    //   25: aload_2
    //   26: aload_3
    //   27: invokestatic 477	org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils:transferStreams	(Ljava/io/InputStream;Ljava/io/OutputStream;)V
    //   30: goto +24 -> 54
    //   33: astore 5
    //   35: aload_3
    //   36: ifnull +7 -> 43
    //   39: aload_3
    //   40: invokevirtual 429	java/io/OutputStream:close	()V
    //   43: aload_2
    //   44: ifnull +7 -> 51
    //   47: aload_2
    //   48: invokevirtual 428	java/io/InputStream:close	()V
    //   51: aload 5
    //   53: athrow
    //   54: aload_3
    //   55: ifnull +7 -> 62
    //   58: aload_3
    //   59: invokevirtual 429	java/io/OutputStream:close	()V
    //   62: aload_2
    //   63: ifnull +11 -> 74
    //   66: aload_2
    //   67: invokevirtual 428	java/io/InputStream:close	()V
    //   70: goto +4 -> 74
    //   73: pop
    //   74: return
    // Line number table:
    //   Java source line #138	-> byte code offset #0
    //   Java source line #139	-> byte code offset #2
    //   Java source line #141	-> byte code offset #4
    //   Java source line #144	-> byte code offset #10
    //   Java source line #145	-> byte code offset #20
    //   Java source line #146	-> byte code offset #25
    //   Java source line #147	-> byte code offset #33
    //   Java source line #148	-> byte code offset #35
    //   Java source line #149	-> byte code offset #39
    //   Java source line #150	-> byte code offset #43
    //   Java source line #151	-> byte code offset #47
    //   Java source line #152	-> byte code offset #51
    //   Java source line #148	-> byte code offset #54
    //   Java source line #149	-> byte code offset #58
    //   Java source line #150	-> byte code offset #62
    //   Java source line #151	-> byte code offset #66
    //   Java source line #153	-> byte code offset #73
    //   Java source line #156	-> byte code offset #74
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	75	0	this	ConfigApplier
    //   0	75	1	url	URL
    //   1	66	2	sourceStream	java.io.InputStream
    //   3	56	3	destinationStream	java.io.OutputStream
    //   8	7	4	lastBundlesTxt	File
    //   33	19	5	localObject	Object
    //   73	1	6	localIOException	IOException
    // Exception table:
    //   from	to	target	type
    //   10	33	33	finally
    //   10	70	73	java/io/IOException
  }
  
  private File getLastBundleInfo()
  {
    return manipulatingContext.getDataFile("last.bundles.info");
  }
  
  private BundleInfo[] getLastState()
  {
    File lastBundlesInfo = getLastBundleInfo();
    if (!lastBundlesInfo.isFile()) {
      return null;
    }
    try
    {
      return (BundleInfo[])SimpleConfiguratorUtils.readConfiguration(lastBundlesInfo.toURL(), baseLocation).toArray(new BundleInfo[1]);
    }
    catch (IOException localIOException) {}
    return null;
  }
  
  private ArrayList installBundles(BundleInfo[] finalList, Collection toStart)
  {
    ArrayList toRefresh = new ArrayList();
    
    String useReferenceProperty = manipulatingContext.getProperty("org.eclipse.equinox.simpleconfigurator.useReference");
    boolean useReference = useReferenceProperty == null ? runningOnEquinox : Boolean.valueOf(useReferenceProperty).booleanValue();
    for (int i = 0; i < finalList.length; i++) {
      if (finalList[i] != null)
      {
        String symbolicName = finalList[i].getSymbolicName();
        String version = finalList[i].getVersion();
        
        Bundle[] matches = null;
        if ((symbolicName != null) && (version != null)) {
          matches = packageAdminService.getBundles(symbolicName, getVersionRange(version));
        }
        String bundleLocation = SimpleConfiguratorUtils.getBundleLocation(finalList[i], useReference);
        
        Bundle current = matches.length == 0 ? null : matches == null ? null : matches[0];
        if (current == null)
        {
          try
          {
            current = manipulatingContext.installBundle(bundleLocation);
            if ((symbolicName != null) && (version != null)) {
              try
              {
                Version v = new Version(version);
                if ((!symbolicName.equals(current.getSymbolicName())) || (!v.equals(current.getVersion()))) {
                  current.update();
                }
              }
              catch (IllegalArgumentException localIllegalArgumentException1) {}
            }
            toRefresh.add(current);
          }
          catch (BundleException e)
          {
            continue;
          }
        }
        else if ((inDevMode) && (current.getBundleId() != 0L) && (current != manipulatingContext.getBundle()) && (!bundleLocation.equals(current.getLocation())) && (!current.getLocation().startsWith("initial@")))
        {
          try
          {
            current.uninstall();
            toRefresh.add(current);
          }
          catch (BundleException e)
          {
            continue;
          }
          try
          {
            current = manipulatingContext.installBundle(bundleLocation);
            
            toRefresh.add(current);
          }
          catch (BundleException e)
          {
            continue;
          }
        }
        if (finalList[i].isMarkedAsStarted()) {
          toStart.add(current);
        }
        int startLevel = finalList[i].getStartLevel();
        if (startLevel >= 1) {
          if (current.getBundleId() != 0L) {
            if (packageAdminService.getBundleType(current) != 1) {
              if (!"org.eclipse.equinox.simpleconfigurator".equals(current.getSymbolicName())) {
                try
                {
                  startLevelService.setBundleStartLevel(current, startLevel);
                }
                catch (IllegalArgumentException ex)
                {
                  Utils.log(4, null, null, "Failed to set start level of Bundle:" + finalList[i], ex);
                }
              }
            }
          }
        }
      }
    }
    return toRefresh;
  }
  
  private void refreshPackages(Bundle[] bundles, BundleContext context)
  {
    if ((bundles.length == 0) || (packageAdminService == null)) {
      return;
    }
    boolean[] flag = new boolean[1];
    FrameworkListener listener = new FrameworkListener()
    {
      private final boolean[] val$flag;
      
      public void frameworkEvent(FrameworkEvent event)
      {
        if (event.getType() == 4) {
          synchronized (val$flag)
          {
            val$flag[0] = true;
            val$flag.notifyAll();
          }
        }
      }
    };
    context.addFrameworkListener(listener);
    packageAdminService.refreshPackages(bundles);
    synchronized (flag)
    {
      while (flag[0] == 0) {
        try
        {
          flag.wait();
        }
        catch (InterruptedException localInterruptedException) {}
      }
    }
    context.removeFrameworkListener(listener);
  }
  
  private void startBundles(Bundle[] bundles)
  {
    for (int i = 0; i < bundles.length; i++)
    {
      Bundle bundle = bundles[i];
      if (bundle.getState() == 1) {
        System.err.println("Could not start: " + bundle.getSymbolicName() + '(' + bundle.getLocation() + ':' + bundle.getBundleId() + ')' + ". It's state is uninstalled.");
      } else if ((bundle.getState() != 8) || ((bundle != callingBundle) && (bundle != manipulatingContext.getBundle()))) {
        if (packageAdminService.getBundleType(bundle) != 1) {
          if (bundle.getBundleId() != 0L) {
            try
            {
              bundle.start();
            }
            catch (BundleException e)
            {
              e.printStackTrace();
            }
          }
        }
      }
    }
  }
  
  private Collection uninstallBundles(BundleInfo[] finalList, PackageAdmin packageAdmin)
  {
    Bundle[] allBundles = manipulatingContext.getBundles();
    
    Set removedBundles = new HashSet(allBundles.length);
    for (int i = 0; i < allBundles.length; i++) {
      if (allBundles[i].getBundleId() != 0L) {
        removedBundles.add(allBundles[i]);
      }
    }
    for (int i = 0; i < finalList.length; i++) {
      if (finalList[i] != null)
      {
        Bundle[] toAdd = packageAdmin.getBundles(finalList[i].getSymbolicName(), getVersionRange(finalList[i].getVersion()));
        for (int j = 0; (toAdd != null) && (j < toAdd.length); j++) {
          removedBundles.remove(toAdd[j]);
        }
      }
    }
    for (Iterator iter = removedBundles.iterator(); iter.hasNext();) {
      try
      {
        Bundle bundle = (Bundle)iter.next();
        if (bundle.getLocation().startsWith("initial@")) {
          iter.remove();
        } else {
          bundle.uninstall();
        }
      }
      catch (BundleException e)
      {
        e.printStackTrace();
      }
    }
    return removedBundles;
  }
  
  private String getVersionRange(String version)
  {
    return version == null ? null : new StringBuffer().append('[').append(version).append(',').append(version).append(']').toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.ConfigApplier
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

public class SimpleConfiguratorFactory
  implements ServiceFactory
{
  private BundleContext context;
  
  public SimpleConfiguratorFactory(BundleContext context)
  {
    this.context = context;
  }
  
  public Object getService(Bundle bundle, ServiceRegistration registration)
  {
    return new SimpleConfiguratorImpl(context, bundle);
  }
  
  public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {}
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.SimpleConfiguratorFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.List;
import org.eclipse.equinox.internal.provisional.configurator.Configurator;
import org.eclipse.equinox.internal.simpleconfigurator.utils.EquinoxUtils;
import org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils;
import org.eclipse.equinox.internal.simpleconfigurator.utils.Utils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

public class SimpleConfiguratorImpl
  implements Configurator
{
  private static URL configurationURL = null;
  private static Object configurationLock = new Object();
  private BundleContext context;
  private ConfigApplier configApplier;
  private Bundle bundle;
  
  public SimpleConfiguratorImpl(BundleContext context, Bundle bundle)
  {
    this.context = context;
    this.bundle = bundle;
  }
  
  public URL getConfigurationURL()
    throws IOException
  {
    String specifiedURL = context.getProperty("org.eclipse.equinox.simpleconfigurator.configUrl");
    if (specifiedURL == null) {
      specifiedURL = "file:org.eclipse.equinox.simpleconfigurator/bundles.info";
    }
    try
    {
      if (!specifiedURL.startsWith("file:")) {
        return new URL(specifiedURL);
      }
    }
    catch (MalformedURLException localMalformedURLException1)
    {
      return null;
    }
    try
    {
      boolean done = false;
      URL url = null;
      String file = specifiedURL;
      while (!done) {
        try
        {
          url = Utils.buildURL(file);
          file = url.getFile();
        }
        catch (MalformedURLException localMalformedURLException2)
        {
          done = true;
        }
      }
      if ((url != null) && (new File(url.getFile()).isAbsolute())) {
        return url;
      }
      URL[] configURL = EquinoxUtils.getConfigAreaURL(context);
      if (configURL != null)
      {
        File userConfig = new File(configURL[0].getFile(), url.getFile());
        if (configURL.length == 1) {
          return userConfig.exists() ? userConfig.toURL() : null;
        }
        File sharedConfig = new File(configURL[1].getFile(), url.getFile());
        if (!userConfig.exists()) {
          return sharedConfig.exists() ? sharedConfig.toURL() : null;
        }
        if (!sharedConfig.exists()) {
          return userConfig.toURL();
        }
        URI base = EquinoxUtils.getInstallLocationURI(context);
        
        URL sharedConfigURL = sharedConfig.toURL();
        List sharedBundles = SimpleConfiguratorUtils.readConfiguration(sharedConfigURL, base);
        
        URL userConfigURL = userConfig.toURL();
        List userBundles = SimpleConfiguratorUtils.readConfiguration(userConfigURL, base);
        
        return userBundles.containsAll(sharedBundles) ? userConfigURL : sharedConfigURL;
      }
    }
    catch (MalformedURLException localMalformedURLException3)
    {
      return null;
    }
    try
    {
      return Utils.buildURL(specifiedURL);
    }
    catch (MalformedURLException localMalformedURLException4) {}
    return null;
  }
  
  public void applyConfiguration(URL url)
    throws IOException
  {
    synchronized (configurationLock)
    {
      if (url == null) {
        return;
      }
      configurationURL = url;
      if (configApplier == null) {
        configApplier = new ConfigApplier(context, bundle);
      }
      configApplier.install(url, isExclusiveInstallation());
    }
  }
  
  private boolean isExclusiveInstallation()
  {
    String value = context.getProperty("org.eclipse.equinox.simpleconfigurator.exclusiveInstallation");
    if ((value == null) || (value.trim().length() == 0)) {
      value = "true";
    }
    return Boolean.valueOf(value).booleanValue();
  }
  
  public void applyConfiguration()
    throws IOException
  {
    synchronized (configurationLock)
    {
      configurationURL = getConfigurationURL();
      applyConfiguration(configurationURL);
    }
  }
  
  /* Error */
  public URL getUrlInUse()
  {
    // Byte code:
    //   0: getstatic 140	org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl:configurationLock	Ljava/lang/Object;
    //   3: dup
    //   4: astore_1
    //   5: monitorenter
    //   6: getstatic 141	org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl:configurationURL	Ljava/net/URL;
    //   9: aload_1
    //   10: monitorexit
    //   11: areturn
    //   12: aload_1
    //   13: monitorexit
    //   14: athrow
    // Line number table:
    //   Java source line #148	-> byte code offset #0
    //   Java source line #149	-> byte code offset #6
    //   Java source line #148	-> byte code offset #12
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	15	0	this	SimpleConfiguratorImpl
    //   4	9	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   6	11	12	finally
    //   12	14	12	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.SimpleConfiguratorImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator.console;

import java.io.IOException;
import java.net.URL;
import org.eclipse.equinox.internal.provisional.configurator.Configurator;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;

public class ApplyCommand
{
  private URL configURL;
  private CommandInterpreter interpreter;
  private BundleContext context;
  
  public ApplyCommand(CommandInterpreter interpreter, BundleContext context, URL configURL)
  {
    this.interpreter = interpreter;
    this.context = context;
    this.configURL = configURL;
  }
  
  public void run()
  {
    ServiceTracker tracker = new ServiceTracker(context, Configurator.class.getName(), null);
    tracker.open();
    Configurator configurator = (Configurator)tracker.getService();
    if (configurator != null) {
      try
      {
        if (configURL != null) {
          configurator.applyConfiguration(configURL);
        } else {
          configurator.applyConfiguration();
        }
        if (configurator.getUrlInUse() != null) {
          break label141;
        }
        interpreter.println("Config URL not set.");
      }
      catch (IOException e)
      {
        interpreter.println(e.getMessage());
      }
    } else {
      interpreter.println("No configurator registered");
    }
    label141:
    tracker.close();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.console.ApplyCommand
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator.console;

import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.equinox.internal.simpleconfigurator.utils.Utils;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.osgi.framework.BundleContext;

public class ConfiguratorCommandProvider
  implements CommandProvider
{
  public static final String NEW_LINE = "\r\n";
  private BundleContext context;
  
  public ConfiguratorCommandProvider(BundleContext context)
  {
    this.context = context;
  }
  
  private URL toURL(CommandInterpreter interpreter, String urlString)
  {
    try
    {
      return Utils.buildURL(urlString);
    }
    catch (MalformedURLException e)
    {
      interpreter.println(e.getMessage());
    }
    return null;
  }
  
  public void _confapply(CommandInterpreter interpreter)
  {
    String parameter = interpreter.nextArgument();
    URL configURL = null;
    if (parameter != null) {
      configURL = toURL(interpreter, parameter);
    }
    new ApplyCommand(interpreter, context, configURL).run();
  }
  
  public Object _help(CommandInterpreter intp)
  {
    String commandName = intp.nextArgument();
    if (commandName == null) {
      return new Boolean(false);
    }
    String help = getHelp(commandName);
    if (help.length() > 0) {
      return help;
    }
    return new Boolean(false);
  }
  
  public String getHelp()
  {
    return getHelp(null);
  }
  
  private String getHelp(String commandName)
  {
    StringBuffer help = new StringBuffer();
    if (commandName == null)
    {
      help.append("---");
      help.append("Configurator Commands");
      help.append("---");
      help.append("\r\n");
    }
    if ((commandName == null) || ("confapply".equals(commandName)))
    {
      help.append("\tconfapply [<config URL>] - Applies a configuration");
      help.append("\r\n");
    }
    return help.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.console.ConfiguratorCommandProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator.utils;

import java.net.URI;

public class BundleInfo
{
  public static final int NO_LEVEL = -1;
  private String symbolicName = null;
  private String version = null;
  private URI location;
  private URI baseLocation;
  private boolean markedAsStarted = false;
  private int startLevel = -1;
  
  public BundleInfo(String symbolic, String version, URI location, int startLevel, boolean started)
  {
    symbolicName = symbolic;
    this.version = version;
    this.location = location;
    markedAsStarted = started;
    this.startLevel = startLevel;
  }
  
  public URI getLocation()
  {
    return location;
  }
  
  public int getStartLevel()
  {
    return startLevel;
  }
  
  public String getSymbolicName()
  {
    return symbolicName;
  }
  
  public String getVersion()
  {
    return version;
  }
  
  public boolean isMarkedAsStarted()
  {
    return markedAsStarted;
  }
  
  public URI getBaseLocation()
  {
    return baseLocation;
  }
  
  public void setBaseLocation(URI baseLocation)
  {
    this.baseLocation = baseLocation;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("BundleInfo(");
    if (symbolicName != null) {
      buffer.append(symbolicName);
    }
    buffer.append(", ");
    if (version != null) {
      buffer.append(version);
    }
    if (baseLocation != null)
    {
      buffer.append(", baseLocation=");
      buffer.append(baseLocation);
    }
    buffer.append(", location=");
    buffer.append(location);
    buffer.append(", startLevel=");
    buffer.append(startLevel);
    buffer.append(", toBeStarted=");
    buffer.append(markedAsStarted);
    buffer.append(')');
    return buffer.toString();
  }
  
  public int hashCode()
  {
    int result = 1;
    result = 31 * result + (symbolicName == null ? 0 : symbolicName.hashCode());
    result = 31 * result + (version == null ? 0 : version.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    BundleInfo other = (BundleInfo)obj;
    if (symbolicName == null)
    {
      if (symbolicName != null) {
        return false;
      }
    }
    else if (!symbolicName.equals(symbolicName)) {
      return false;
    }
    if (version == null)
    {
      if (version != null) {
        return false;
      }
    }
    else if (!version.equals(version)) {
      return false;
    }
    if ((location == null) || (location == null)) {
      return true;
    }
    URI absoluteLocation = baseLocation == null ? location : URIUtil.append(baseLocation, location.toString());
    URI otherAbsoluteLocation = baseLocation == null ? location : URIUtil.append(baseLocation, location.toString());
    return URIUtil.sameURI(absoluteLocation, otherAbsoluteLocation);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator.utils;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import org.eclipse.equinox.internal.simpleconfigurator.console.ConfiguratorCommandProvider;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.eclipse.osgi.service.datalocation.Location;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;

public class EquinoxUtils
{
  public static URL[] getConfigAreaURL(BundleContext context)
  {
    Location configLocation = getConfigLocation(context);
    if (configLocation == null) {
      return null;
    }
    URL baseURL = configLocation.getURL();
    if ((configLocation.getParentLocation() != null) && (configLocation.getURL() != null))
    {
      if (baseURL == null) {
        return new URL[] { configLocation.getParentLocation().getURL() };
      }
      return new URL[] { baseURL, configLocation.getParentLocation().getURL() };
    }
    if (baseURL != null) {
      return new URL[] { baseURL };
    }
    return null;
  }
  
  public static Location getConfigLocation(BundleContext context)
  {
    Filter filter = null;
    try
    {
      filter = context.createFilter(Location.CONFIGURATION_FILTER);
    }
    catch (InvalidSyntaxException localInvalidSyntaxException) {}
    ServiceTracker configLocationTracker = new ServiceTracker(context, filter, null);
    configLocationTracker.open();
    try
    {
      return (Location)configLocationTracker.getService();
    }
    finally
    {
      configLocationTracker.close();
    }
  }
  
  public static URI getInstallLocationURI(BundleContext context)
  {
    try
    {
      ServiceReference[] references = context.getServiceReferences(Location.class.getName(), Location.INSTALL_FILTER);
      if ((references != null) && (references.length > 0))
      {
        ServiceReference reference = references[0];
        Location installLocation = (Location)context.getService(reference);
        if (installLocation != null)
        {
          try
          {
            if (installLocation.isSet())
            {
              URL location = installLocation.getURL();
              return URIUtil.toURI(location);
            }
          }
          catch (URISyntaxException localURISyntaxException) {}finally
          {
            context.ungetService(reference);
          }
          context.ungetService(reference);
        }
      }
    }
    catch (InvalidSyntaxException localInvalidSyntaxException) {}
    return null;
  }
  
  public static ServiceRegistration registerConsoleCommands(BundleContext context)
  {
    return context.registerService(CommandProvider.class.getName(), new ConfiguratorCommandProvider(context), null);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.utils.EquinoxUtils
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator.utils;

public class SimpleConfiguratorConstants
{
  public static final String PROP_KEY_EXCLUSIVE_INSTALLATION = "org.eclipse.equinox.simpleconfigurator.exclusiveInstallation";
  public static final String PROP_KEY_USE_REFERENCE = "org.eclipse.equinox.simpleconfigurator.useReference";
  public static final String PROP_KEY_CONFIGURL = "org.eclipse.equinox.simpleconfigurator.configUrl";
  public static final String CONFIG_LIST = "bundles.info";
  public static final String CONFIGURATOR_FOLDER = "org.eclipse.equinox.simpleconfigurator";
  public static final String TARGET_CONFIGURATOR_NAME = "org.eclipse.equinox.simpleconfigurator";
  public static final String PARAMETER_BASEURL = "org.eclipse.equinox.simpleconfigurator.baseUrl";
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorConstants
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator.utils;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import org.osgi.framework.Version;

public class SimpleConfiguratorUtils
{
  private static final String UNC_PREFIX = "//";
  private static final String VERSION_PREFIX = "#version=";
  public static final String ENCODING_UTF8 = "#encoding=UTF-8";
  public static final Version COMPATIBLE_VERSION = new Version(1, 0, 0);
  private static final String FILE_SCHEME = "file";
  private static final String REFERENCE_PREFIX = "reference:";
  private static final String FILE_PREFIX = "file:";
  private static final String COMMA = ",";
  private static final String ENCODED_COMMA = "%2C";
  
  public static List readConfiguration(URL url, URI base)
    throws IOException
  {
    InputStream stream = null;
    try
    {
      stream = url.openStream();
    }
    catch (IOException e)
    {
      if ((e instanceof FileNotFoundException)) {
        return Collections.EMPTY_LIST;
      }
      throw e;
    }
    try
    {
      return readConfiguration(stream, base);
    }
    finally
    {
      stream.close();
    }
  }
  
  /* Error */
  public static List readConfiguration(InputStream stream, URI base)
    throws IOException
  {
    // Byte code:
    //   0: new 176	java/util/ArrayList
    //   3: dup
    //   4: invokespecial 330	java/util/ArrayList:<init>	()V
    //   7: astore_2
    //   8: new 157	java/io/BufferedInputStream
    //   11: dup
    //   12: aload_0
    //   13: invokespecial 289	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   16: astore_3
    //   17: aload_3
    //   18: invokestatic 340	org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils:determineEncoding	(Ljava/io/BufferedInputStream;)Ljava/lang/String;
    //   21: astore 4
    //   23: new 159	java/io/BufferedReader
    //   26: dup
    //   27: aload 4
    //   29: ifnonnull +14 -> 43
    //   32: new 164	java/io/InputStreamReader
    //   35: dup
    //   36: aload_3
    //   37: invokespecial 296	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   40: goto +13 -> 53
    //   43: new 164	java/io/InputStreamReader
    //   46: dup
    //   47: aload_3
    //   48: aload 4
    //   50: invokespecial 297	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;Ljava/lang/String;)V
    //   53: invokespecial 292	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   56: astore 5
    //   58: goto +61 -> 119
    //   61: aload 6
    //   63: invokevirtual 310	java/lang/String:trim	()Ljava/lang/String;
    //   66: astore 6
    //   68: aload 6
    //   70: invokevirtual 307	java/lang/String:length	()I
    //   73: ifne +6 -> 79
    //   76: goto +43 -> 119
    //   79: aload 6
    //   81: ldc 1
    //   83: invokevirtual 315	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   86: ifeq +11 -> 97
    //   89: aload 6
    //   91: invokestatic 339	org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils:parseCommentLine	(Ljava/lang/String;
1 2

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