org.eclipse.osgi_3.7.2.v20120110-1415

n = getBundleDescription();
    if (bundleDescription == null) {
      return null;
    }
    proxy = new BundleLoaderProxy(this, bundleDescription);
    
    bundleDescription.setUserObject(proxy);
    return proxy;
  }
  
  public ClassLoader getClassLoader()
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(new RuntimePermission("getClassLoader"));
    }
    BundleLoaderProxy curProxy = getLoaderProxy();
    BundleLoader loader = curProxy == null ? null : curProxy.getBundleLoader();
    BundleClassLoader bcl = loader == null ? null : loader.createClassLoader();
    return (bcl instanceof ClassLoader) ? (ClassLoader)bcl : null;
  }
}

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

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.osgi.framework.util.KeyedHashSet;
import org.osgi.framework.Version;

public final class BundleRepository
{
  private List<AbstractBundle> bundlesByInstallOrder;
  private KeyedHashSet bundlesById;
  private Map<String, AbstractBundle[]> bundlesBySymbolicName;
  
  public BundleRepository(int initialCapacity)
  {
    synchronized (this)
    {
      bundlesByInstallOrder = new ArrayList(initialCapacity);
      bundlesById = new KeyedHashSet(initialCapacity, true);
      bundlesBySymbolicName = new HashMap(initialCapacity);
    }
  }
  
  public synchronized List<AbstractBundle> getBundles()
  {
    return bundlesByInstallOrder;
  }
  
  public synchronized AbstractBundle getBundle(long bundleId)
  {
    Long key = new Long(bundleId);
    return (AbstractBundle)bundlesById.getByKey(key);
  }
  
  public synchronized AbstractBundle[] getBundles(String symbolicName)
  {
    if ("system.bundle".equals(symbolicName)) {
      symbolicName = Constants.getInternalSymbolicName();
    }
    return (AbstractBundle[])bundlesBySymbolicName.get(symbolicName);
  }
  
  public synchronized AbstractBundle getBundle(String symbolicName, Version version)
  {
    AbstractBundle[] bundles = getBundles(symbolicName);
    if ((bundles != null) && 
      (bundles.length > 0)) {
      for (int i = 0; i < bundles.length; i++) {
        if (bundles[i].getVersion().equals(version)) {
          return bundles[i];
        }
      }
    }
    return null;
  }
  
  public synchronized void add(AbstractBundle bundle)
  {
    bundlesByInstallOrder.add(bundle);
    bundlesById.add(bundle);
    addSymbolicName(bundle);
  }
  
  private void addSymbolicName(AbstractBundle bundle)
  {
    String symbolicName = bundle.getSymbolicName();
    if (symbolicName == null) {
      return;
    }
    AbstractBundle[] bundles = (AbstractBundle[])bundlesBySymbolicName.get(symbolicName);
    if (bundles == null)
    {
      bundles = new AbstractBundle[1];
      bundles[0] = bundle;
      bundlesBySymbolicName.put(symbolicName, bundles);
      return;
    }
    List<AbstractBundle> list = new ArrayList(bundles.length + 1);
    
    Version newVersion = bundle.getVersion();
    boolean added = false;
    for (int i = 0; i < bundles.length; i++)
    {
      AbstractBundle oldBundle = bundles[i];
      Version oldVersion = oldBundle.getVersion();
      if ((!added) && (newVersion.compareTo(oldVersion) >= 0))
      {
        added = true;
        list.add(bundle);
      }
      list.add(oldBundle);
    }
    if (!added) {
      list.add(bundle);
    }
    bundles = new AbstractBundle[list.size()];
    list.toArray(bundles);
    bundlesBySymbolicName.put(symbolicName, bundles);
  }
  
  public synchronized boolean remove(AbstractBundle bundle)
  {
    boolean found = bundlesById.remove(bundle);
    if (!found) {
      return false;
    }
    bundlesByInstallOrder.remove(bundle);
    
    String symbolicName = bundle.getSymbolicName();
    if (symbolicName == null) {
      return true;
    }
    removeSymbolicName(symbolicName, bundle);
    return true;
  }
  
  private void removeSymbolicName(String symbolicName, AbstractBundle bundle)
  {
    AbstractBundle[] bundles = (AbstractBundle[])bundlesBySymbolicName.get(symbolicName);
    if (bundles == null) {
      return;
    }
    int numRemoved = 0;
    for (int i = 0; i < bundles.length; i++) {
      if (bundle == bundles[i])
      {
        numRemoved++;
        bundles[i] = null;
      }
    }
    if (numRemoved > 0) {
      if (bundles.length - numRemoved <= 0)
      {
        bundlesBySymbolicName.remove(symbolicName);
      }
      else
      {
        AbstractBundle[] newBundles = new AbstractBundle[bundles.length - numRemoved];
        int indexCnt = 0;
        for (int i = 0; i < bundles.length; i++) {
          if (bundles[i] != null)
          {
            newBundles[indexCnt] = bundles[i];
            indexCnt++;
          }
        }
        bundlesBySymbolicName.put(symbolicName, newBundles);
      }
    }
  }
  
  public synchronized void update(String oldSymbolicName, AbstractBundle bundle)
  {
    if (oldSymbolicName != null)
    {
      if (!oldSymbolicName.equals(bundle.getSymbolicName()))
      {
        removeSymbolicName(oldSymbolicName, bundle);
        addSymbolicName(bundle);
      }
    }
    else {
      addSymbolicName(bundle);
    }
  }
  
  public synchronized void removeAllBundles()
  {
    bundlesByInstallOrder.clear();
    bundlesById = new KeyedHashSet();
    bundlesBySymbolicName.clear();
  }
}

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

import java.io.IOException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
import org.eclipse.osgi.framework.internal.protocol.ProtocolActivator;
import org.eclipse.osgi.internal.baseadaptor.AdaptorMsg;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

public abstract class BundleResourceHandler
  extends URLStreamHandler
  implements ProtocolActivator
{
  public static final String SECURITY_CHECKED = "SECURITY_CHECKED";
  public static final String SECURITY_UNCHECKED = "SECURITY_UNCHECKED";
  public static final String BID_FWKID_SEPARATOR = ".fwk";
  private BaseAdaptor adaptor;
  protected BundleEntry bundleEntry;
  
  public BundleResourceHandler()
  {
    this(null, null);
  }
  
  public BundleResourceHandler(BundleEntry bundleEntry, BaseAdaptor adaptor)
  {
    this.bundleEntry = bundleEntry;
    this.adaptor = adaptor;
  }
  
  public void start(BundleContext context, FrameworkAdaptor baseAdaptor)
  {
    adaptor = ((BaseAdaptor)baseAdaptor);
  }
  
  protected void parseURL(URL url, String str, int start, int end)
  {
    if (end < start) {
      return;
    }
    if (url.getPath() != null) {
      bundleEntry = null;
    }
    String spec = "";
    if (start < end) {
      spec = str.substring(start, end);
    }
    end -= start;
    
    String path = url.getPath();
    String host = url.getHost();
    int resIndex = url.getPort();
    if (resIndex < 0) {
      resIndex = 0;
    }
    int pathIdx = 0;
    if (spec.startsWith("//"))
    {
      int bundleIdIdx = 2;
      pathIdx = spec.indexOf('/', bundleIdIdx);
      if (pathIdx == -1)
      {
        pathIdx = end;
        
        path = "";
      }
      int bundleIdEnd = spec.indexOf(':', bundleIdIdx);
      if ((bundleIdEnd > pathIdx) || (bundleIdEnd == -1)) {
        bundleIdEnd = pathIdx;
      }
      if (bundleIdEnd < pathIdx - 1) {
        try
        {
          resIndex = Integer.parseInt(spec.substring(bundleIdEnd + 1, pathIdx));
        }
        catch (NumberFormatException localNumberFormatException) {}
      }
      host = spec.substring(bundleIdIdx, bundleIdEnd);
    }
    if ((pathIdx < end) && (spec.charAt(pathIdx) == '/'))
    {
      path = spec.substring(pathIdx, end);
    }
    else if (end > pathIdx)
    {
      if ((path == null) || (path.equals(""))) {
        path = "/";
      }
      int last = path.lastIndexOf('/') + 1;
      if (last == 0) {
        path = spec.substring(pathIdx, end);
      } else {
        path = path.substring(0, last) + spec.substring(pathIdx, end);
      }
    }
    if (path == null) {
      path = "";
    }
    if ((path.endsWith("/.")) || (path.endsWith("/.."))) {
      path = path + '/';
    }
    int dotIndex;
    while ((dotIndex = path.indexOf("/./")) >= 0)
    {
      int dotIndex;
      path = path.substring(0, dotIndex + 1) + path.substring(dotIndex + 3);
    }
    while ((dotIndex = path.indexOf("/../")) >= 0) {
      if (dotIndex != 0) {
        path = path.substring(0, path.lastIndexOf('/', dotIndex - 1)) + path.substring(dotIndex + 3);
      } else {
        path = path.substring(dotIndex + 3);
      }
    }
    while ((dotIndex = path.indexOf("//")) >= 0) {
      path = path.substring(0, dotIndex + 1) + path.substring(dotIndex + 2);
    }
    String authorized = "SECURITY_UNCHECKED";
    long bundleId = getBundleID(host);
    Bundle bundle = adaptor == null ? null : adaptor.getBundle(bundleId);
    if (checkAuthorization(bundle)) {
      authorized = "SECURITY_CHECKED";
    }
    if (adaptor != null) {
      host = Long.toString(bundleId) + ".fwk" + Integer.toString(adaptor.hashCode());
    }
    setURL(url, url.getProtocol(), host, resIndex, authorized, null, path, null, url.getRef());
  }
  
  protected URLConnection openConnection(URL url)
    throws IOException
  {
    if (bundleEntry != null) {
      return new BundleURLConnection(url, bundleEntry);
    }
    String host = url.getHost();
    if (host == null) {
      throw new IOException(NLS.bind(AdaptorMsg.URL_NO_BUNDLE_ID, url.toExternalForm()));
    }
    AbstractBundle bundle = null;
    try
    {
      bundleID = getBundleID(host);
    }
    catch (NumberFormatException nfe)
    {
      long bundleID;
      throw ((MalformedURLException)new MalformedURLException(NLS.bind(AdaptorMsg.URL_INVALID_BUNDLE_ID, host)).initCause(nfe));
    }
    long bundleID;
    bundle = adaptor == null ? null : (AbstractBundle)adaptor.getBundle(bundleID);
    if (bundle == null) {
      throw new IOException(NLS.bind(AdaptorMsg.URL_NO_BUNDLE_FOUND, url.toExternalForm()));
    }
    if (!url.getAuthority().equals("SECURITY_CHECKED")) {
      checkAuthorization(bundle);
    }
    return new BundleURLConnection(url, findBundleEntry(url, bundle));
  }
  
  protected abstract BundleEntry findBundleEntry(URL paramURL, AbstractBundle paramAbstractBundle)
    throws IOException;
  
  protected String toExternalForm(URL url)
  {
    StringBuffer result = new StringBuffer(url.getProtocol());
    result.append("://");
    
    String host = url.getHost();
    if ((host != null) && (host.length() > 0)) {
      result.append(host);
    }
    int index = url.getPort();
    if (index > 0) {
      result.append(':').append(index);
    }
    String path = url.getPath();
    if (path != null)
    {
      if ((path.length() > 0) && (path.charAt(0) != '/')) {
        result.append("/");
      }
      result.append(path);
    }
    String ref = url.getRef();
    if ((ref != null) && (ref.length() > 0)) {
      result.append('#').append(ref);
    }
    return result.toString();
  }
  
  protected int hashCode(URL url)
  {
    int hash = 0;
    String protocol = url.getProtocol();
    if (protocol != null) {
      hash += protocol.hashCode();
    }
    String host = url.getHost();
    if (host != null) {
      hash += host.hashCode();
    }
    hash += url.getPort();
    
    String path = url.getPath();
    if (path != null) {
      hash += path.hashCode();
    }
    if (adaptor != null) {
      hash += adaptor.hashCode();
    }
    return hash;
  }
  
  protected boolean equals(URL url1, URL url2)
  {
    return sameFile(url1, url2);
  }
  
  protected synchronized InetAddress getHostAddress(URL url)
  {
    return null;
  }
  
  protected boolean hostsEqual(URL url1, URL url2)
  {
    String host1 = url1.getHost();
    String host2 = url2.getHost();
    if ((host1 != null) && (host2 != null)) {
      return host1.equalsIgnoreCase(host2);
    }
    return (host1 == null) && (host2 == null);
  }
  
  protected boolean sameFile(URL url1, URL url2)
  {
    if (url1.hashCode() != url2.hashCode()) {
      return false;
    }
    String p1 = url1.getProtocol();
    String p2 = url2.getProtocol();
    if ((p1 != p2) && ((p1 == null) || (!p1.equalsIgnoreCase(p2)))) {
      return false;
    }
    if (!hostsEqual(url1, url2)) {
      return false;
    }
    if (url1.getPort() != url2.getPort()) {
      return false;
    }
    String path1 = url1.getPath();
    String path2 = url2.getPath();
    if ((path1 != path2) && ((path1 == null) || (!path1.equals(path2)))) {
      return false;
    }
    return true;
  }
  
  protected boolean checkAuthorization(Bundle bundle)
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
      return true;
    }
    if (bundle == null) {
      return false;
    }
    sm.checkPermission(new AdminPermission(bundle, "resource"));
    return true;
  }
  
  protected static BaseClassLoader getBundleClassLoader(AbstractBundle bundle)
  {
    BundleLoader loader = bundle.getBundleLoader();
    if (loader == null) {
      return null;
    }
    return (BaseClassLoader)loader.createClassLoader();
  }
  
  private long getBundleID(String host)
  {
    int dotIndex = host.indexOf('.');
    return (dotIndex >= 0) && (dotIndex < host.length() - 1) ? Long.parseLong(host.substring(0, dotIndex)) : Long.parseLong(host);
  }
}

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

public class BundleSource
  extends URLConnection
{
  private InputStream in;
  
  protected BundleSource(InputStream in)
  {
    super(null);
    this.in = in;
  }
  
  public void connect()
    throws IOException
  {
    connected = true;
  }
  
  public InputStream getInputStream()
    throws IOException
  {
    return in;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.core.BundleSource
 * 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;
import java.net.URLConnection;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.internal.baseadaptor.AdaptorMsg;
import org.eclipse.osgi.util.NLS;

public class BundleURLConnection
  extends URLConnection
{
  protected final BundleEntry bundleEntry;
  protected InputStream in;
  protected String contentType;
  
  public BundleURLConnection(URL url, BundleEntry bundleEntry)
  {
    super(url);
    
    this.bundleEntry = bundleEntry;
    in = null;
    contentType = null;
  }
  
  public synchronized void connect()
    throws IOException
  {
    if (!connected) {
      if (bundleEntry != null)
      {
        in = bundleEntry.getInputStream();
        connected = true;
      }
      else
      {
        throw new IOException(NLS.bind(AdaptorMsg.RESOURCE_NOT_FOUND_EXCEPTION, url));
      }
    }
  }
  
  public int getContentLength()
  {
    return (int)bundleEntry.getSize();
  }
  
  public String getContentType()
  {
    if (contentType == null)
    {
      contentType = guessContentTypeFromName(bundleEntry.getName());
      if (contentType == null)
      {
        if (!connected) {
          try
          {
            connect();
          }
          catch (IOException localIOException1)
          {
            return null;
          }
        }
        try
        {
          if (in.markSupported()) {
            contentType = guessContentTypeFromStream(in);
          }
        }
        catch (IOException localIOException2) {}
      }
    }
    return contentType;
  }
  
  public boolean getDoInput()
  {
    return true;
  }
  
  public boolean getDoOutput()
  {
    return false;
  }
  
  public InputStream getInputStream()
    throws IOException
  {
    if (!connected) {
      connect();
    }
    return in;
  }
  
  public long getLastModified()
  {
    long lastModified = bundleEntry.getTime();
    if (lastModified == -1L) {
      return 0L;
    }
    return lastModified;
  }
  
  public URL getLocalURL()
  {
    return bundleEntry.getLocalURL();
  }
  
  public URL getFileURL()
  {
    return bundleEntry.getFileURL();
  }
}

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

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

class ConsoleManager$1
  extends FilterInputStream
{
  final ConsoleManager this$0;
  
  ConsoleManager$1(ConsoleManager paramConsoleManager, InputStream $anonymous0)
  {
    super($anonymous0);
  }
  
  public void close()
    throws IOException
  {}
}

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

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;

class ConsoleManager$2
  extends FilterOutputStream
{
  final ConsoleManager this$0;
  
  ConsoleManager$2(ConsoleManager paramConsoleManager, OutputStream $anonymous0)
  {
    super($anonymous0);
  }
  
  public void close()
    throws IOException
  {}
  
  public void write(byte[] var0, int var1, int var2)
    throws IOException
  {
    out.write(var0, var1, var2);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.core.ConsoleManager.2
 * 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.PrintStream;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import org.eclipse.osgi.util.NLS;

class ConsoleManager$ConsoleSocketGetter
  implements Runnable
{
  private final ServerSocket server;
  private volatile boolean shutdown = false;
  final ConsoleManager this$0;
  
  ConsoleManager$ConsoleSocketGetter(ConsoleManager arg1, ServerSocket server)
  {
    this.server = server;
    Method reuseAddress;
    try
    {
      reuseAddress = server.getClass().getMethod("setReuseAddress", new Class[] { Boolean.TYPE });
      reuseAddress.invoke(server, new Object[] { Boolean.TRUE });
    }
    catch (Exception localException) {}
    Thread t = new Thread(this, "ConsoleSocketGetter");
    t.setDaemon(false);
    t.start();
  }
  
  public void run()
  {
    System.out.println(NLS.bind(ConsoleMsg.CONSOLE_LISTENING_ON_PORT, server.getInetAddress().toString() + ':' + Integer.toString(server.getLocalPort())));
    while (!shutdown) {
      try
      {
        Socket socket = server.accept();
        if (socket == null) {
          throw new IOException("No socket available.  Probably caused by a shutdown.");
        }
        FrameworkConsoleSession session = new FrameworkConsoleSession(socket.getInputStream(), socket.getOutputStream(), socket); Class 
          tmp108_105 = ConsoleManager.class$0;
        if (tmp108_105 == null)
        {
          tmp108_105;
          try
          {
            tmpTernaryOp = (ConsoleManager.class$0 = Class.forName("org.eclipse.osgi.framework.console.ConsoleSession"));
          }
          catch (ClassNotFoundException localClassNotFoundException)
          {
            throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
          }
        }
        ConsoleManager.access$3(this$0).getSystemBundleContext().registerService(tmp108_105.getName(), session, null);
      }
      catch (Exception e)
      {
        if (!shutdown) {
          e.printStackTrace();
        }
      }
    }
  }
  
  public void shutdown()
  {
    if (shutdown) {
      return;
    }
    shutdown = true;
    try
    {
      server.close();
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }
}

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

import java.io.FilterInputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Dictionary;
import java.util.Hashtable;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.eclipse.osgi.framework.console.ConsoleSession;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class ConsoleManager
  implements ServiceTrackerCustomizer<ConsoleSession, FrameworkConsole>
{
  public static final String PROP_CONSOLE = "osgi.console";
  private static final String PROP_SYSTEM_IN_OUT = "console.systemInOut";
  private static final String CONSOLE_NAME = "OSGi Console";
  private static final String PROP_CONSOLE_ENABLED = "osgi.console.enable.builtin";
  private final Framework framework;
  private final ServiceTracker<CommandProvider, CommandProvider> cpTracker;
  private final ServiceTracker<ConsoleSession, FrameworkConsole> sessions;
  private final String consolePort;
  private final String consoleHost;
  private FrameworkCommandProvider fwkCommands;
  private ServiceRegistration<?> builtinSession;
  private ConsoleSocketGetter socketGetter;
  private final boolean isEnabled;
  
  class ConsoleSocketGetter
    implements Runnable
  {
    private final ServerSocket server;
    private volatile boolean shutdown = false;
    
    ConsoleSocketGetter(ServerSocket server)
    {
      this.server = server;
      Method reuseAddress;
      try
      {
        reuseAddress = server.getClass().getMethod("setReuseAddress", new Class[] { Boolean.TYPE });
        reuseAddress.invoke(server, new Object[] { Boolean.TRUE });
      }
      catch (Exception localException) {}
      Thread t = new Thread(this, "ConsoleSocketGetter");
      t.setDaemon(false);
      t.start();
    }
    
    public void run()
    {
      System.out.println(NLS.bind(ConsoleMsg.CONSOLE_LISTENING_ON_PORT, server.getInetAddress().toString() + ':' + Integer.toString(server.getLocalPort())));
      while (!shutdown) {
        try
        {
          Socket socket = server.accept();
          if (socket == null) {
            throw new IOException("No socket available.  Probably caused by a shutdown.");
          }
          FrameworkConsoleSession session = new FrameworkConsoleSession(socket.getInputStream(), socket.getOutputStream(), socket); Class 
            tmp108_105 = ConsoleManager.class$0;
          if (tmp108_105 == null)
          {
            tmp108_105;
            try
            {
              tmpTernaryOp = (ConsoleManager.class$0 = Class.forName("org.eclipse.osgi.framework.console.ConsoleSession"));
            }
            catch (ClassNotFoundException localClassNotFoundException)
            {
              throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
            }
          }
          framework.getSystemBundleContext().registerService(tmp108_105.getName(), session, null);
        }
        catch (Exception e)
        {
          if (!shutdown) {
            e.printStackTrace();
          }
        }
      }
    }
    
    public void shutdown()
    {
      if (shutdown) {
        return;
      }
      shutdown = true;
      try
      {
        server.close();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
  }
  
  public ConsoleManager(Framework framework, String consolePropValue)
  {
    String port = null;
    String host = null;
    if (consolePropValue != null)
    {
      int index = consolePropValue.lastIndexOf(":");
      if (index > -1) {
        host = consolePropValue.substring(0, index);
      }
      port = consolePropValue.substring(index + 1);
    }
    if (("false".equals(FrameworkProperties.getProperty("osgi.console.enable.builtin"))) || ("none".equals(port)))
    {
      isEnabled = false;
      this.framework = null;
      cpTracker = null;
      sessions = null;
      consoleHost = null;
      consolePort = null;
      return;
    }
    isEnabled = true;
    this.framework = framework;
    consoleHost = (host != null ? host.trim() : host);
    consolePort = (port != null ? port.trim() : port);
    cpTracker = new ServiceTracker(framework.getSystemBundleContext(), CommandProvider.class.getName(), null);
    sessions = new ServiceTracker(framework.getSystemBundleContext(), ConsoleSession.class.getName(), this);
  }
  
  public static ConsoleManager startConsole(Framework framework)
  {
    ConsoleManager consoleManager = new ConsoleManager(framework, FrameworkProperties.getProperty("osgi.console"));
    consoleManager.startConsole();
    return consoleManager;
  }
  
  private void startConsole()
  {
    if (!isEnabled) {
      return;
    }
    cpTracker.open();
    sessions.open();
    fwkCommands = new FrameworkCommandProvider(framework);
    fwkCommands.start();
    if (consolePort == null) {
      return;
    }
    int port = -1;
    try
    {
      if (consolePort.length() > 0) {
        port = Integer.parseInt(consolePort);
      }
    }
    catch (NumberFormatException localNumberFormatException) {}
    if (port < 0)
    {
      InputStream in = new FilterInputStream(System.in)
      {
        public void close()
          throws IOException
        {}
      };
      OutputStream out = new FilterOutputStream(System.out)
      {
        public void close()
          throws IOException
        {}
        
        public void write(byte[] var0, int var1, int var2)
          throws IOException
        {
          out.write(var0, var1, var2);
        }
      };
      FrameworkConsoleSession session = new FrameworkConsoleSession(in, out, null);
      Dictionary<String, Object> props = null;
      props = new Hashtable(1);
      props.put("console.systemInOut", Boolean.TRUE);
      builtinSession = framework.getSystemBundleContext().registerService(ConsoleSession.class.getName(), session, props);
    }
    else
    {
      try
      {
        if (consoleHost != null) {
          socketGetter = new ConsoleSocketGetter(new ServerSocket(port, 0, InetAddress.getByName(consoleHost)));
        } else {
          socketGetter = new ConsoleSocketGetter(new ServerSocket(port));
        }
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
  }
  
  public void stopConsole()
  {
    if (!isEnabled) {
      return;
    }
    if (builtinSession != null) {
      try
      {
        builtinSession.unregister();
      }
      catch (IllegalStateException localIllegalStateException) {}
    }
    sessions.close();
    cpTracker.close();
    if (socketGetter != null) {
      socketGetter.shutdown();
    }
    if (fwkCommands != null) {
      fwkCommands.stop();
    }
  }
  
  public FrameworkConsole addingService(ServiceReference<ConsoleSession> reference)
  {
    FrameworkConsole console = null;
    
    Boolean isSystemInOut = (Boolean)reference.getProperty("console.systemInOut");
    if (isSystemInOut == null) {
      isSystemInOut = Boolean.FALSE;
    }
    ConsoleSession session = (ConsoleSession)framework.getSystemBundleContext().getService(reference);
    console = new FrameworkConsole(framework.getSystemBundleContext(), session, isSystemInOut.booleanValue(), cpTracker);
    
    Thread t = new Thread(console, "OSGi Console");
    t.setDaemon(false);
    t.start();
    return console;
  }
  
  public void modifiedService(ServiceReference<ConsoleSession> reference, FrameworkConsole service) {}
  
  public void removedService(ServiceReference<ConsoleSession> reference, FrameworkConsole service)
  {
    service.shutdown();
  }
}

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

import org.eclipse.osgi.util.NLS;

public class ConsoleMsg
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.osgi.framework.internal.core.ConsoleMessages";
  public static String CONSOLE_LINES_TO_SCROLL_NEGATIVE_ERROR;
  public static String CONSOLE_NESTED_EXCEPTION;
  public static String CONSOLE_ERROR_READING_RESOURCE;
  public static String CONSOLE_RESOURCE_NOT_IN_BUNDLE;
  public static String CONSOLE_MORE;
  public static String CONSOLE_HELP_CONTROLLING_CONSOLE_HEADING;
  public static String CONSOLE_HELP_MORE;
  public static String CONSOLE_HELP_DISCONNECT;
  public static String CONSOLE_CONFIRM_MORE;
  public static String CONSOLE_CONFIRM_DISCONNECT;
  public static String CONSOLE_CONFIRM;
  public static String CONSOLE_CONFIRM_VALUES;
  public static String CONSOLE_Y;
  public static String CONSOLE_N;
  public static String CONSOLE_PROMPT_DEFAULT;
  public static String CONSOLE_INVALID_INPUT;
  public static String CONSOLE_TOO_MUCH_INVALID_INPUT;
  public static String CONSOLE_MORE_ENTER_LINES;
  public static String CONSOLE_LISTENING_ON_PORT;
  public static String CONSOLE_PROMPT;
  public static String CONSOLE_HELP_CONTROLLING_FRAMEWORK_HEADER;
  public static String CONSOLE_HELP_LAUNCH_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_SHUTDOWN_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_CLOSE_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_EXIT_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_GC_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_INIT_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_KEYVALUE_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_SETPROP_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_CONTROLLING_BUNDLES_HEADER;
  public static String CONSOLE_HELP_INSTALL_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_UNINSTALL_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_START_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_STOP_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_REFRESH_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_DISPLAYING_STATUS_HEADER;
  public static String CONSOLE_HELP_STATUS_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_STATE_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_SS_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_FILTER_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_SERVICES_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_PACKAGES_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_PACKAGES_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_BUNDLES_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_IDLOCATION_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_BUNDLE_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_HEADERS_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_EXTRAS_HEADER;
  public static String CONSOLE_HELP_COMMAND_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_GETPROP_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_GETPROP_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_EXEC_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_FORK_COMMAND_DESCRIPTION;
  public static String STARTLEVEL_HELP_HEADING;
  public static String CONSOLE_HELP_OPTIONAL_IDLOCATION_ARGUMENT_DESCRIPTION;
  public static String STARTLEVEL_HELP_SL;
  public static String STARTLEVEL_ARGUMENT_DESCRIPTION;
  public static String STARTLEVEL_HELP_SETFWSL;
  public static String STARTLEVEL_IDLOCATION_ARGUMENT_DESCRIPTION;
  public static String STARTLEVEL_HELP_SETBSL;
  public static String STARTLEVEL_HELP_SETIBSL;
  public static String CONSOLE_HELP_PROFILE_HEADING;
  public static String CONSOLE_HELP_PROFILELOG_DESCRIPTION;
  public static String CONSOLE_HELP_UPDATE_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_HELP_COMMAND_DESCRIPTION;
  public static String CONSOLE_NO_BUNDLE_SPECIFIED_ERROR;
  public static String CONSOLE_NOTHING_TO_INSTALL_ERROR;
  public static String CONSOLE_BUNDLE_ID_MESSAGE;
  public static String CONSOLE_NO_INSTALLED_BUNDLES_ERROR;
  public static String CONSOLE_REGISTERED_SERVICES_MESSAGE;
  public static String CONSOLE_FRAMEWORK_IS_LAUNCHED_MESSAGE;
  public static String CONSOLE_FRAMEWORK_IS_SHUTDOWN_MESSAGE;
  public static String CONSOLE_ID;
  public static String CONSOLE_BUNDLE_LOCATION_MESSAGE;
  public static String CONSOLE_STATE_BUNDLE_FILE_NAME_HEADER;
  public static String CONSOLE_BUNDLES_USING_SERVICE_MESSAGE;
  public static String CONSOLE_NO_REGISTERED_SERVICES_MESSAGE;
  public static String CONSOLE_NO_BUNDLES_USING_SERVICE_MESSAGE;
  public static String CONSOLE_REGISTERED_BY_BUNDLE_MESSAGE;
  public static String CONSOLE_IMPORTS_MESSAGE;
  public static String CONSOLE_STALE_MESSAGE;
  public static String CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE;
  public static String CONSOLE_NO_EXPORTED_PACKAGES_MESSAGE;
  public static String CONSOLE_REMOVAL_PENDING_MESSAGE;
  public static String CONSOLE_SERVICES_IN_USE_MESSAGE;
  public static String CONSOLE_NO_SERVICES_IN_USE_MESSAGE;
  public static String CONSOLE_ID_MESSAGE;
  public static String CONSOLE_STATUS_MESSAGE;
  public static String CONSOLE_DATA_ROOT_MESSAGE;
  public static String CONSOLE_IMPORTED_PACKAGES_MESSAGE;
  public static String CONSOLE_NO_IMPORTED_PACKAGES_MESSAGE;
  public static String CONSOLE_HOST_MESSAGE;
  public static String CONSOLE_EXPORTED_PACKAGES_MESSAGE;
  public static String CONSOLE_EXPORTED_REMOVAL_PENDING_MESSAGE;
  public static String CONSOLE_EXPORTED_MESSAGE;
  public static String CONSOLE_NO_HOST_MESSAGE;
  public static String CONSOLE_FRAGMENT_MESSAGE;
  public static String CONSOLE_NO_FRAGMENT_MESSAGE;
  public static String CONSOLE_NO_NAMED_CLASS_SPACES_MESSAGE;
  public static String CONSOLE_NAMED_CLASS_SPACE_MESSAGE;
  public static String CONSOLE_PROVIDED_MESSAGE;
  public static String CONSOLE_REQUIRED_BUNDLES_MESSAGE;
  public static String CONSOLE_NO_REQUIRED_BUNDLES_MESSAGE;
  public static String CONSOLE_TOTAL_MEMORY_MESSAGE;
  public static String CONSOLE_FREE_MEMORY_BEFORE_GARBAGE_COLLECTION_MESSAGE;
  public static String CONSOLE_FREE_MEMORY_AFTER_GARBAGE_COLLECTION_MESSAGE;
  public static String CONSOLE_MEMORY_GAINED_WITH_GARBAGE_COLLECTION_MESSAGE;
  public static String CONSOLE_FRAMEWORK_LAUNCHED_PLEASE_SHUTDOWN_MESSAGE;
  public static String CONSOLE_INVALID_BUNDLE_SPECIFICATION_ERROR;
  public static String CONSOLE_CAN_NOT_REFRESH_NO_PACKAGE_ADMIN_ERROR;
  public static String CONSOLE_NO_COMMAND_SPECIFIED_ERROR;
  public static String CONSOLE_STARTED_IN_MESSAGE;
  public static String CONSOLE_EXECUTED_RESULT_CODE_MESSAGE;
  public static String CONSOLE_BUNDLE_HEADERS_TITLE;
  public static String CONSOLE_SYSTEM_PROPERTIES_TITLE;
  public static String CONSOLE_NO_PARAMETERS_SPECIFIED_TITLE;
  public static String CONSOLE_SETTING_PROPERTIES_TITLE;
  public static String CONSOLE_STATE_BUNDLE_TITLE;
  public static String CONSOLE_THREADGROUP_TITLE;
  public static String CONSOLE_THREADTYPE_TITLE;
  public static String CONSOLE_REQUIRES_MESSAGE;
  public static String CONSOLE_CAN_NOT_USE_STARTLEVEL_NO_STARTLEVEL_SVC_ERROR;
  public static String CONSOLE_CANNOT_FIND_BUNDLE_ERROR;
  public static String CONSOLE_PROPS_COMMAND_DESCRIPTION;
  public static String CONSOLE_THREADS_COMMAND_DESCRIPTION;
  public static String STARTLEVEL_FRAMEWORK_ACTIVE_STARTLEVEL;
  public static String STARTLEVEL_BUNDLE_STARTLEVEL;
  public static String STARTLEVEL_NO_STARTLEVEL_GIVEN;
  public static String STARTLEVEL_NO_STARTLEVEL_OR_BUNDLE_GIVEN;
  public static String STARTLEVEL_INITIAL_BUNDLE_STARTLEVEL;
  public static String STARTLEVEL_POSITIVE_INTEGER;
  
  static
  {
    NLS.initializeMessages("org.eclipse.osgi.framework.internal.core.ConsoleMessages", ConsoleMsg.class);
  }
}

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

public class Constants
  implements org.osgi.framework.Constants
{
  public static final String OSGI_FRAMEWORK_VERSION = "1.3";
  public static final String OSGI_FRAMEWORK_VENDOR = "Eclipse";
  public static final String OSGI_BUNDLE_MANIFEST = "META-INF/MANIFEST.MF";
  public static final String OSGI_FRAMEWORK_PACKAGE = "org.osgi.framework";
  public static final String OSGI_RESOURCE_URL_PROTOCOL = "bundleresource";
  public static final String OSGI_ENTRY_URL_PROTOCOL = "bundleentry";
  public static final String OSGI_PROCESSOR_ALIASES = "processor.aliases";
  public static final String OSGI_OSNAME_ALIASES = "osname.aliases";
  public static final String OSGI_DEFAULT_DEFAULT_PERMISSIONS = "default.permissions";
  public static final String OSGI_BASE_IMPLIED_PERMISSIONS = "implied.permissions";
  public static final String OSGI_LOGSERVICE_NAME = "org.osgi.service.log.LogService";
  public static final String OSGI_PACKAGEADMIN_NAME = "org.osgi.service.packageadmin.PackageAdmin";
  public static final String OSGI_PERMISSIONADMIN_NAME = "org.osgi.service.permissionadmin.PermissionAdmin";
  public static final String OSGI_STARTLEVEL_NAME = "org.osgi.service.startlevel.StartLevel";
  public static final String JVM_VM_NAME = "java.vm.name";
  public static final String JVM_OS_ARCH = "os.arch";
  public static final String JVM_OS_NAME = "os.name";
  public static final String JVM_OS_VERSION = "os.version";
  public static final String JVM_USER_LANGUAGE = "user.language";
  public static final String JVM_USER_REGION = "user.region";
  public static final String J2ME_MICROEDITION_CONFIGURATION = "microedition.configuration";
  public static final String J2ME_MICROEDITION_PROFILES = "microedition.profiles";
  public static final int BUNDLE_STARTED = 1;
  public static final int BUNDLE_LAZY_START = 2;
  public static final int BUNDLE_ACTIVATION_POLICY = 4;
  public static final String OSGI_PROPERTIES = "osgi.framework.properties";
  public static final String DEFAULT_OSGI_PROPERTIES = "osgi.properties";
  private static String INTERNAL_SYSTEM_BUNDLE = "org.eclipse.osgi";
  public static final String OSGI_IMPL_VERSION_KEY = "osgi.framework.version";
  public static final String OSGI_JAVA_PROFILE = "osgi.java.profile";
  public static final String OSGI_JAVA_PROFILE_NAME = "osgi.java.profile.name";
  public static final String OSGI_JAVA_PROFILE_BOOTDELEGATION = "osgi.java.profile.bootdelegation";
  public static final String OSGI_BOOTDELEGATION_IGNORE = "ignore";
  public static final String OSGI_BOOTDELEGATION_OVERRIDE = "override";
  public static final String OSGI_BOOTDELEGATION_NONE = "none";
  public static final String OSGI_RESOLVER_MODE = "osgi.resolverMode";
  public static final String ST
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd