org.eclipse.equinox.console_1.0.0.v20120522-1841

16:43:49.142 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.console_1.0.0.v20120522-1841.jar
package org.eclipse.equinox.console.command.adapter;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class Activator$CommandCustomizer
  implements ServiceTrackerCustomizer<CommandProvider, List<ServiceRegistration<?>>>
{
  private BundleContext context;
  
  public Activator$CommandCustomizer(Activator paramActivator, BundleContext context)
  {
    this.context = context;
  }
  
  public List<ServiceRegistration<?>> addingService(ServiceReference<CommandProvider> reference)
  {
    if (reference.getProperty("osgi.command.function") != null) {
      return null;
    }
    CommandProvider command = (CommandProvider)context.getService(reference);
    try
    {
      Method[] commandMethods = this$0.getCommandMethods(command);
      if (commandMethods.length > 0)
      {
        List<ServiceRegistration<?>> registrations = new ArrayList();
        registrations.add(context.registerService(Object.class, new CommandProviderAdapter(command, commandMethods), this$0.getAttributes(commandMethods)));
        return registrations;
      }
      context.ungetService(reference);
      return null;
    }
    catch (Exception localException)
    {
      context.ungetService(reference);
    }
    return null;
  }
  
  public void modifiedService(ServiceReference<CommandProvider> reference, List<ServiceRegistration<?>> service) {}
  
  public void removedService(ServiceReference<CommandProvider> reference, List<ServiceRegistration<?>> registrations)
  {
    for (ServiceRegistration<?> serviceRegistration : registrations) {
      serviceRegistration.unregister();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.console.command.adapter.Activator.CommandCustomizer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.console.command.adapter;

import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
import org.eclipse.equinox.console.telnet.TelnetCommand;
import org.eclipse.osgi.framework.console.ConsoleSession;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class Activator$ProcessorCustomizer
  implements ServiceTrackerCustomizer<CommandProcessor, ServiceTracker<ConsoleSession, CommandSession>>
{
  private final BundleContext context;
  
  public Activator$ProcessorCustomizer(BundleContext context)
  {
    this.context = context;
  }
  
  public ServiceTracker<ConsoleSession, CommandSession> addingService(ServiceReference<CommandProcessor> reference)
  {
    CommandProcessor processor = (CommandProcessor)context.getService(reference);
    if (processor == null) {
      return null;
    }
    if (Activator.access$0())
    {
      Activator.access$1(false);
      Activator.access$2(new TelnetCommand(processor, context));
      Activator.access$3().startService();
    }
    else
    {
      Activator.access$3().addCommandProcessor(processor);
    }
    ServiceTracker<ConsoleSession, CommandSession> tracker = new ServiceTracker(context, ConsoleSession.class, new Activator.SessionCustomizer(context, processor));
    tracker.open();
    return tracker;
  }
  
  public void modifiedService(ServiceReference<CommandProcessor> reference, ServiceTracker<ConsoleSession, CommandSession> service) {}
  
  public void removedService(ServiceReference<CommandProcessor> reference, ServiceTracker<ConsoleSession, CommandSession> tracker)
  {
    tracker.close();
    CommandProcessor processor = (CommandProcessor)context.getService(reference);
    Activator.access$3().removeCommandProcessor(processor);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.console.command.adapter.Activator.ProcessorCustomizer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.console.command.adapter;

import org.apache.felix.service.command.CommandSession;
import org.eclipse.osgi.framework.console.ConsoleSession;

class Activator$SessionCustomizer$1
  implements Runnable
{
  Activator$SessionCustomizer$1(Activator.SessionCustomizer paramSessionCustomizer, CommandSession paramCommandSession, ConsoleSession paramConsoleSession) {}
  
  /* Error */
  public void run()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
    //   4: ldc 1
    //   6: ldc 2
    //   8: invokeinterface 66 3 0
    //   13: aload_0
    //   14: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
    //   17: ldc 5
    //   19: ldc 4
    //   21: invokeinterface 66 3 0
    //   26: aload_0
    //   27: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
    //   30: ldc 3
    //   32: invokeinterface 65 2 0
    //   37: pop
    //   38: goto +46 -> 84
    //   41: astore_1
    //   42: aload_1
    //   43: invokevirtual 61	java/lang/Exception:printStackTrace	()V
    //   46: aload_0
    //   47: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
    //   50: invokeinterface 64 1 0
    //   55: aload_0
    //   56: getfield 60	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$equinoxSession	Lorg/eclipse/osgi/framework/console/ConsoleSession;
    //   59: invokevirtual 63	org/eclipse/osgi/framework/console/ConsoleSession:close	()V
    //   62: goto +38 -> 100
    //   65: astore_2
    //   66: aload_0
    //   67: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
    //   70: invokeinterface 64 1 0
    //   75: aload_0
    //   76: getfield 60	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$equinoxSession	Lorg/eclipse/osgi/framework/console/ConsoleSession;
    //   79: invokevirtual 63	org/eclipse/osgi/framework/console/ConsoleSession:close	()V
    //   82: aload_2
    //   83: athrow
    //   84: aload_0
    //   85: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
    //   88: invokeinterface 64 1 0
    //   93: aload_0
    //   94: getfield 60	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$equinoxSession	Lorg/eclipse/osgi/framework/console/ConsoleSession;
    //   97: invokevirtual 63	org/eclipse/osgi/framework/console/ConsoleSession:close	()V
    //   100: return
    // Line number table:
    //   Java source line #130	-> byte code offset #0
    //   Java source line #131	-> byte code offset #13
    //   Java source line #132	-> byte code offset #26
    //   Java source line #134	-> byte code offset #41
    //   Java source line #135	-> byte code offset #42
    //   Java source line #138	-> byte code offset #46
    //   Java source line #139	-> byte code offset #55
    //   Java source line #137	-> byte code offset #65
    //   Java source line #138	-> byte code offset #66
    //   Java source line #139	-> byte code offset #75
    //   Java source line #140	-> byte code offset #82
    //   Java source line #138	-> byte code offset #84
    //   Java source line #139	-> byte code offset #93
    //   Java source line #141	-> byte code offset #100
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	101	0	this	1
    //   41	2	1	e	Exception
    //   65	18	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	38	41	java/lang/Exception
    //   0	46	65	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.console.command.adapter.Activator.SessionCustomizer.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.console.command.adapter;

import java.io.PrintStream;
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
import org.eclipse.osgi.framework.console.ConsoleSession;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class Activator$SessionCustomizer
  implements ServiceTrackerCustomizer<ConsoleSession, CommandSession>
{
  private final BundleContext context;
  final CommandProcessor processor;
  
  public Activator$SessionCustomizer(BundleContext context, CommandProcessor processor)
  {
    this.context = context;
    this.processor = processor;
  }
  
  public CommandSession addingService(ServiceReference<ConsoleSession> reference)
  {
    final ConsoleSession equinoxSession = (ConsoleSession)context.getService(reference);
    if (equinoxSession == null) {
      return null;
    }
    PrintStream output = new PrintStream(equinoxSession.getOutput());
    final CommandSession gogoSession = processor.createSession(equinoxSession.getInput(), output, output);
    new Thread(new Runnable()
    {
      /* Error */
      public void run()
      {
        // Byte code:
        //   0: aload_0
        //   1: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
        //   4: ldc 1
        //   6: ldc 2
        //   8: invokeinterface 66 3 0
        //   13: aload_0
        //   14: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
        //   17: ldc 5
        //   19: ldc 4
        //   21: invokeinterface 66 3 0
        //   26: aload_0
        //   27: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
        //   30: ldc 3
        //   32: invokeinterface 65 2 0
        //   37: pop
        //   38: goto +46 -> 84
        //   41: astore_1
        //   42: aload_1
        //   43: invokevirtual 61	java/lang/Exception:printStackTrace	()V
        //   46: aload_0
        //   47: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
        //   50: invokeinterface 64 1 0
        //   55: aload_0
        //   56: getfield 60	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$equinoxSession	Lorg/eclipse/osgi/framework/console/ConsoleSession;
        //   59: invokevirtual 63	org/eclipse/osgi/framework/console/ConsoleSession:close	()V
        //   62: goto +38 -> 100
        //   65: astore_2
        //   66: aload_0
        //   67: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
        //   70: invokeinterface 64 1 0
        //   75: aload_0
        //   76: getfield 60	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$equinoxSession	Lorg/eclipse/osgi/framework/console/ConsoleSession;
        //   79: invokevirtual 63	org/eclipse/osgi/framework/console/ConsoleSession:close	()V
        //   82: aload_2
        //   83: athrow
        //   84: aload_0
        //   85: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
        //   88: invokeinterface 64 1 0
        //   93: aload_0
        //   94: getfield 60	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$equinoxSession	Lorg/eclipse/osgi/framework/console/ConsoleSession;
        //   97: invokevirtual 63	org/eclipse/osgi/framework/console/ConsoleSession:close	()V
        //   100: return
        // Line number table:
        //   Java source line #130	-> byte code offset #0
        //   Java source line #131	-> byte code offset #13
        //   Java source line #132	-> byte code offset #26
        //   Java source line #134	-> byte code offset #41
        //   Java source line #135	-> byte code offset #42
        //   Java source line #138	-> byte code offset #46
        //   Java source line #139	-> byte code offset #55
        //   Java source line #137	-> byte code offset #65
        //   Java source line #138	-> byte code offset #66
        //   Java source line #139	-> byte code offset #75
        //   Java source line #140	-> byte code offset #82
        //   Java source line #138	-> byte code offset #84
        //   Java source line #139	-> byte code offset #93
        //   Java source line #141	-> byte code offset #100
        // Local variable table:
        //   start	length	slot	name	signature
        //   0	101	0	this	1
        //   41	2	1	e	Exception
        //   65	18	2	localObject	Object
        // Exception table:
        //   from	to	target	type
        //   0	38	41	java/lang/Exception
        //   0	46	65	finally
      }
    }, "Equinox Console Session").start();
    return null;
  }
  
  public void modifiedService(ServiceReference<ConsoleSession> reference, CommandSession service) {}
  
  public void removedService(ServiceReference<ConsoleSession> reference, CommandSession session)
  {
    session.close();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.console.command.adapter.Activator.SessionCustomizer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.console.command.adapter;

import java.io.PrintStream;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
import org.eclipse.equinox.console.commands.DisconnectCommand;
import org.eclipse.equinox.console.commands.EquinoxCommandProvider;
import org.eclipse.equinox.console.commands.HelpCommand;
import org.eclipse.equinox.console.commands.ManCommand;
import org.eclipse.equinox.console.telnet.TelnetCommand;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.eclipse.osgi.framework.console.ConsoleSession;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.condpermadmin.ConditionalPermissionAdmin;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.permissionadmin.PermissionAdmin;
import org.osgi.service.startlevel.StartLevel;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class Activator
  implements BundleActivator
{
  private ServiceTracker<StartLevel, ?> startLevelManagerTracker;
  private ServiceTracker<ConditionalPermissionAdmin, ?> condPermAdminTracker;
  private ServiceTracker<PermissionAdmin, ?> permissionAdminTracker;
  private ServiceTracker<PackageAdmin, PackageAdmin> packageAdminTracker;
  private ServiceTracker<PlatformAdmin, ?> platformAdminTracker;
  private static boolean isFirstProcessor = true;
  private static TelnetCommand telnetConnection = null;
  private ServiceTracker<CommandProcessor, ServiceTracker<ConsoleSession, CommandSession>> commandProcessorTracker;
  private ServiceTracker<CommandProvider, List<ServiceRegistration<?>>> commandProviderTracker;
  private EquinoxCommandProvider equinoxCmdProvider;
  
  public static class ProcessorCustomizer
    implements ServiceTrackerCustomizer<CommandProcessor, ServiceTracker<ConsoleSession, CommandSession>>
  {
    private final BundleContext context;
    
    public ProcessorCustomizer(BundleContext context)
    {
      this.context = context;
    }
    
    public ServiceTracker<ConsoleSession, CommandSession> addingService(ServiceReference<CommandProcessor> reference)
    {
      CommandProcessor processor = (CommandProcessor)context.getService(reference);
      if (processor == null) {
        return null;
      }
      if (Activator.isFirstProcessor)
      {
        Activator.isFirstProcessor = false;
        Activator.telnetConnection = new TelnetCommand(processor, context);
        Activator.telnetConnection.startService();
      }
      else
      {
        Activator.telnetConnection.addCommandProcessor(processor);
      }
      ServiceTracker<ConsoleSession, CommandSession> tracker = new ServiceTracker(context, ConsoleSession.class, new Activator.SessionCustomizer(context, processor));
      tracker.open();
      return tracker;
    }
    
    public void modifiedService(ServiceReference<CommandProcessor> reference, ServiceTracker<ConsoleSession, CommandSession> service) {}
    
    public void removedService(ServiceReference<CommandProcessor> reference, ServiceTracker<ConsoleSession, CommandSession> tracker)
    {
      tracker.close();
      CommandProcessor processor = (CommandProcessor)context.getService(reference);
      Activator.telnetConnection.removeCommandProcessor(processor);
    }
  }
  
  public static class SessionCustomizer
    implements ServiceTrackerCustomizer<ConsoleSession, CommandSession>
  {
    private final BundleContext context;
    final CommandProcessor processor;
    
    public SessionCustomizer(BundleContext context, CommandProcessor processor)
    {
      this.context = context;
      this.processor = processor;
    }
    
    public CommandSession addingService(ServiceReference<ConsoleSession> reference)
    {
      final ConsoleSession equinoxSession = (ConsoleSession)context.getService(reference);
      if (equinoxSession == null) {
        return null;
      }
      PrintStream output = new PrintStream(equinoxSession.getOutput());
      final CommandSession gogoSession = processor.createSession(equinoxSession.getInput(), output, output);
      new Thread(new Runnable()
      {
        /* Error */
        public void run()
        {
          // Byte code:
          //   0: aload_0
          //   1: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
          //   4: ldc 1
          //   6: ldc 2
          //   8: invokeinterface 66 3 0
          //   13: aload_0
          //   14: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
          //   17: ldc 5
          //   19: ldc 4
          //   21: invokeinterface 66 3 0
          //   26: aload_0
          //   27: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
          //   30: ldc 3
          //   32: invokeinterface 65 2 0
          //   37: pop
          //   38: goto +46 -> 84
          //   41: astore_1
          //   42: aload_1
          //   43: invokevirtual 61	java/lang/Exception:printStackTrace	()V
          //   46: aload_0
          //   47: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
          //   50: invokeinterface 64 1 0
          //   55: aload_0
          //   56: getfield 60	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$equinoxSession	Lorg/eclipse/osgi/framework/console/ConsoleSession;
          //   59: invokevirtual 63	org/eclipse/osgi/framework/console/ConsoleSession:close	()V
          //   62: goto +38 -> 100
          //   65: astore_2
          //   66: aload_0
          //   67: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
          //   70: invokeinterface 64 1 0
          //   75: aload_0
          //   76: getfield 60	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$equinoxSession	Lorg/eclipse/osgi/framework/console/ConsoleSession;
          //   79: invokevirtual 63	org/eclipse/osgi/framework/console/ConsoleSession:close	()V
          //   82: aload_2
          //   83: athrow
          //   84: aload_0
          //   85: getfield 58	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$gogoSession	Lorg/apache/felix/service/command/CommandSession;
          //   88: invokeinterface 64 1 0
          //   93: aload_0
          //   94: getfield 60	org/eclipse/equinox/console/command/adapter/Activator$SessionCustomizer$1:val$equinoxSession	Lorg/eclipse/osgi/framework/console/ConsoleSession;
          //   97: invokevirtual 63	org/eclipse/osgi/framework/console/ConsoleSession:close	()V
          //   100: return
          // Line number table:
          //   Java source line #130	-> byte code offset #0
          //   Java source line #131	-> byte code offset #13
          //   Java source line #132	-> byte code offset #26
          //   Java source line #134	-> byte code offset #41
          //   Java source line #135	-> byte code offset #42
          //   Java source line #138	-> byte code offset #46
          //   Java source line #139	-> byte code offset #55
          //   Java source line #137	-> byte code offset #65
          //   Java source line #138	-> byte code offset #66
          //   Java source line #139	-> byte code offset #75
          //   Java source line #140	-> byte code offset #82
          //   Java source line #138	-> byte code offset #84
          //   Java source line #139	-> byte code offset #93
          //   Java source line #141	-> byte code offset #100
          // Local variable table:
          //   start	length	slot	name	signature
          //   0	101	0	this	1
          //   41	2	1	e	Exception
          //   65	18	2	localObject	Object
          // Exception table:
          //   from	to	target	type
          //   0	38	41	java/lang/Exception
          //   0	46	65	finally
        }
      }, "Equinox Console Session").start();
      return null;
    }
    
    public void modifiedService(ServiceReference<ConsoleSession> reference, CommandSession service) {}
    
    public void removedService(ServiceReference<ConsoleSession> reference, CommandSession session)
    {
      session.close();
    }
  }
  
  public class CommandCustomizer
    implements ServiceTrackerCustomizer<CommandProvider, List<ServiceRegistration<?>>>
  {
    private BundleContext context;
    
    public CommandCustomizer(BundleContext context)
    {
      this.context = context;
    }
    
    public List<ServiceRegistration<?>> addingService(ServiceReference<CommandProvider> reference)
    {
      if (reference.getProperty("osgi.command.function") != null) {
        return null;
      }
      CommandProvider command = (CommandProvider)context.getService(reference);
      try
      {
        Method[] commandMethods = getCommandMethods(command);
        if (commandMethods.length > 0)
        {
          List<ServiceRegistration<?>> registrations = new ArrayList();
          registrations.add(context.registerService(Object.class, new CommandProviderAdapter(command, commandMethods), getAttributes(commandMethods)));
          return registrations;
        }
        context.ungetService(reference);
        return null;
      }
      catch (Exception localException)
      {
        context.ungetService(reference);
      }
      return null;
    }
    
    public void modifiedService(ServiceReference<CommandProvider> reference, List<ServiceRegistration<?>> service) {}
    
    public void removedService(ServiceReference<CommandProvider> reference, List<ServiceRegistration<?>> registrations)
    {
      for (ServiceRegistration<?> serviceRegistration : registrations) {
        serviceRegistration.unregister();
      }
    }
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    commandProviderTracker = new ServiceTracker(context, CommandProvider.class.getName(), new CommandCustomizer(context));
    commandProviderTracker.open();
    commandProcessorTracker = new ServiceTracker(context, CommandProcessor.class, new ProcessorCustomizer(context));
    commandProcessorTracker.open();
    
    condPermAdminTracker = new ServiceTracker(context, ConditionalPermissionAdmin.class.getName(), null);
    condPermAdminTracker.open();
    
    permissionAdminTracker = new ServiceTracker(context, PermissionAdmin.class.getName(), null);
    permissionAdminTracker.open();
    
    startLevelManagerTracker = new ServiceTracker(context, StartLevel.class.getName(), null);
    startLevelManagerTracker.open();
    
    packageAdminTracker = new ServiceTracker(context, PackageAdmin.class, null);
    packageAdminTracker.open();
    
    platformAdminTracker = new ServiceTracker(context, PlatformAdmin.class.getName(), null);
    platformAdminTracker.open();
    
    equinoxCmdProvider = new EquinoxCommandProvider(context, this);
    equinoxCmdProvider.startService();
    
    HelpCommand helpCommand = new HelpCommand(context);
    helpCommand.startService();
    
    ManCommand manCommand = new ManCommand(context);
    manCommand.startService();
    
    DisconnectCommand disconnectCommand = new DisconnectCommand(context);
    disconnectCommand.startService();
    
    startBundle("org.apache.felix.gogo.runtime", true);
    startBundle("org.apache.felix.gogo.shell", true);
    startBundle("org.apache.felix.gogo.command", false);
  }
  
  private void startBundle(String bsn, boolean required)
    throws BundleException
  {
    PackageAdmin pa = (PackageAdmin)packageAdminTracker.getService();
    if (pa != null)
    {
      Bundle[] shells = pa.getBundles(bsn, null);
      if ((shells != null) && (shells.length > 0)) {
        shells[0].start(1);
      } else if (required) {
        throw new BundleException("Missing required bundle: " + bsn);
      }
    }
  }
  
  public StartLevel getStartLevel()
  {
    return (StartLevel)getServiceFromTracker(startLevelManagerTracker, StartLevel.class.getName());
  }
  
  public PermissionAdmin getPermissionAdmin()
  {
    return (PermissionAdmin)getServiceFromTracker(permissionAdminTracker, PermissionAdmin.class.getName());
  }
  
  public ConditionalPermissionAdmin getConditionalPermissionAdmin()
  {
    return (ConditionalPermissionAdmin)getServiceFromTracker(condPermAdminTracker, ConditionalPermissionAdmin.class.getName());
  }
  
  public PackageAdmin getPackageAdmin()
  {
    return (PackageAdmin)getServiceFromTracker(packageAdminTracker, PackageAdmin.class.getName());
  }
  
  public PlatformAdmin getPlatformAdmin()
  {
    return (PlatformAdmin)getServiceFromTracker(platformAdminTracker, PlatformAdmin.class.getName());
  }
  
  private static Object getServiceFromTracker(ServiceTracker<?, ?> tracker, String serviceClass)
  {
    if (tracker == null) {
      throw new IllegalStateException("Missing service: " + serviceClass);
    }
    Object result = tracker.getService();
    if (result == null) {
      throw new IllegalStateException("Missing service: " + serviceClass);
    }
    return result;
  }
  
  Method[] getCommandMethods(Object command)
  {
    ArrayList<Method> names = new ArrayList();
    Class<?> c = command.getClass();
    Method[] methods = c.getDeclaredMethods();
    Method[] arrayOfMethod1;
    int j = (arrayOfMethod1 = methods).length;
    for (int i = 0; i < j; i++)
    {
      Method method = arrayOfMethod1[i];
      if ((method.getName().startsWith("_")) && 
        (method.getModifiers() == 1) && (!method.getName().equals("_help")))
      {
        Type[] types = method.getGenericParameterTypes();
        if ((types.length == 1) && 
          (types[0].equals(CommandInterpreter.class))) {
          names.add(method);
        }
      }
    }
    return (Method[])names.toArray(new Method[names.size()]);
  }
  
  Dictionary<String, Object> getAttributes(Method[] commandMethods)
  {
    Dictionary<String, Object> dict = new Hashtable();
    dict.put("osgi.command.scope", "equinox");
    String[] methodNames = new String[commandMethods.length];
    for (int i = 0; i < commandMethods.length; i++)
    {
      String methodName = commandMethods[i].getName().substring(1);
      methodNames[i] = methodName;
    }
    dict.put("osgi.command.function", methodNames);
    return dict;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    commandProviderTracker.close();
    commandProcessorTracker.close();
    if (equinoxCmdProvider != null) {
      equinoxCmdProvider.stopService();
    }
    try
    {
      telnetConnection.telnet(new String[] { "stop" });
    }
    catch (Exception localException) {}
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.console.command.adapter.Activator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.console.command.adapter;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.eclipse.osgi.framework.console.CommandProvider;

public class CommandProviderAdapter
{
  private final CommandProvider commandProvider;
  private final Method[] commands;
  
  public CommandProviderAdapter(CommandProvider commandProvider, Method[] commands)
  {
    this.commandProvider = commandProvider;
    this.commands = commands;
  }
  
  public Object main(Object[] args)
    throws Exception
  {
    try
    {
      Method command = findCommand("_" + args[0]);
      ArrayList<Object> argList = new ArrayList();
      for (int i = 1; i < args.length; i++) {
        argList.add(args[i]);
      }
      return command.invoke(commandProvider, new Object[] { new CustomCommandInterpreter(argList) });
    }
    catch (InvocationTargetException e)
    {
      if ((e.getTargetException() instanceof Exception)) {
        throw ((Exception)e.getTargetException());
      }
      throw ((Error)e.getTargetException());
    }
  }
  
  private Method findCommand(Object commandName)
  {
    Method[] arrayOfMethod;
    int j = (arrayOfMethod = commands).length;
    for (int i = 0; i < j; i++)
    {
      Method command = arrayOfMethod[i];
      if (command.getName().equalsIgnoreCase(commandName.toString())) {
        return command;
      }
    }
    throw new IllegalArgumentException("Cannot find the command method for: " + commandName);
  }
  
  public Object _main(Object[] args)
    throws Exception
  {
    return main(args);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.console.command.adapter.CommandProviderAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.console.command.adapter;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import org.eclipse.osgi.framework.console.CommandInterpreter;

public class CustomCommandInterpreter
  implements CommandInterpreter
{
  private PrintStream out = System.out;
  private String tab = "\t";
  private String newline = "\r\n";
  private final Iterator<Object> arguments;
  protected static int maxLineCount;
  protected int currentLineCount;
  
  public CustomCommandInterpreter(List<Object> args)
  {
    arguments = args.iterator();
  }
  
  public Object execute(String cmd)
  {
    return null;
  }
  
  public String nextArgument()
  {
    if (arguments.hasNext())
    {
      Object next = arguments.next();
      return next == null ? null : next.toString();
    }
    return null;
  }
  
  public void print(Object o)
  {
    check4More();
    out.print(o);
    out.flush();
  }
  
  public void println()
  {
    println("");
  }
  
  public void printStackTrace(Throwable t)
  {
    t.printStackTrace(out);
    
    Method[] methods = t.getClass().getMethods();
    
    int size = methods.length;
    Class<Throwable> throwable = Throwable.class;
    for (int i = 0; i < size; i++)
    {
      Method method = methods[i];
      if ((Modifier.isPublic(method.getModifiers())) && (method.getName().startsWith("get")) && (throwable.isAssignableFrom(method.getReturnType())) && (method.getParameterTypes().length == 0)) {
        try
        {
          Throwable nested = (Throwable)method.invoke(t, new Object[] { null });
          if ((nested != null) && (nested != t))
          {
            out.println("Nested Exception");
            printStackTrace(nested);
          }
        }
        catch (IllegalAccessException localIllegalAccessException) {}catch (InvocationTargetException localInvocationTargetException) {}
      }
    }
  }
  
  public void println(Object o)
  {
    if (o == null) {
      return;
    }
    synchronized (out)
    {
      check4More();
      printline(o);
      currentLineCount += 1;
      currentLineCount += o.toString().length() / 80;
    }
  }
  
  private void printline(Object o)
  {
    print(o + newline);
  }
  
  public void printDictionary(Dictionary<?, ?> dic, String title)
  {
    if (dic == null) {
      return;
    }
    int count = dic.size();
    String[] keys = new String[count];
    Enumeration<?> keysEnum = dic.keys();
    int i = 0;
    while (keysEnum.hasMoreElements()) {
      keys[(i++)] = ((String)keysEnum.nextElement());
    }
    Arrays.sort(keys);
    if (title != null) {
      println(title);
    }
    for (i = 0; i < count; i++) {
      println(" " + keys[i] + " = " + dic.get(keys[i]));
    }
    println();
  }
  
  /* Error */
  public void printBundleResource(org.osgi.framework.Bundle bundle, String resource)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_3
    //   2: aload_1
    //   3: aload_2
    //   4: invokeinterface 320 2 0
    //   9: astore_3
    //   10: aload_3
    //   11: ifnull +109 -> 120
    //   14: aload_0
    //   15: aload_2
    //   16: invokevirtual 313	org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter:println	(Ljava/lang/Object;)V
    //   19: aload_3
    //   20: invokevirtual 302	java/net/URL:openStream	()Ljava/io/InputStream;
    //   23: astore 4
    //   25: sipush 1024
    //   28: newarray <illegal type>
    //   30: astore 5
    //   32: iconst_0
    //   33: istore 6
    //   35: goto +19 -> 54
    //   38: aload_0
    //   39: new 142	java/lang/String
    //   42: dup
    //   43: aload 5
    //   45: iconst_0
    //   46: iload 6
    //   48: invokespecial 285	java/lang/String:<init>	([BII)V
    //   51: invokevirtual 311	org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter:print	(Ljava/lang/Object;)V
    //   54: aload 4
    //   56: aload 5
    //   58: invokevirtual 273	java/io/InputStream:read	([B)I
    //   61: dup
    //   62: istore 6
    //   64: iconst_m1
    //   65: if_icmpne -27 -> 38
    //   68: goto +22 -> 90
    //   71: astore 7
    //   73: aload 4
    //   75: ifnull +12 -> 87
    //   78: aload 4
    //   80: invokevirtual 272	java/io/InputStream:close	()V
    //   83: goto +4 -> 87
    //   86: pop
    //   87: aload 7
    //   89: athrow
    //   90: aload 4
    //   92: ifnull +62 -> 154
    //   95: aload 4
    //   97: invokevirtual 272	java/io/InputStream:close	()V
    //   100: goto +54 -> 154
    //   103: pop
    //   104: goto +50 -> 154
    //   107: astore 4
    //   109: getstatic 262	java/lang/System:err	Ljava/io/PrintStream;
    //   112: aload 4
    //   114: invokevirtual 276	java/io/PrintStream:println	(Ljava/lang/Object;)V
    //   117: goto +37 -> 154
    //   120: aload_0
    //   121: new 144	java/lang/StringBuilder
    //   124: dup
    //   125: ldc_w 129
    //   128: invokespecial 292	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   131: aload_2
    //   132: invokevirtual 294	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   135: ldc_w 131
    //   138: invokevirtual 294	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   141: aload_1
    //   142: invokevirtual 283	java/lang/Object:toString	()Ljava/lang/String;
    //   145: invokevirtual 294	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   148: invokevirtual 291	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   151: invokevirtual 313	org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter:println	(Ljava/lang/Object;)V
    //   154: return
    // Line number table:
    //   Java source line #174	-> byte code offset #0
    //   Java source line #175	-> byte code offset #2
    //   Java source line #176	-> byte code offset #10
    //   Java source line #178	-> byte code offset #14
    //   Java source line #179	-> byte code offset #19
    //   Java source line #180	-> byte code offset #25
    //   Java source line #181	-> byte code offset #32
    //   Java source line #183	-> byte code offset #35
    //   Java source line #184	-> byte code offset #38
    //   Java source line #183	-> byte code offset #54
    //   Java source line #185	-> byte code offset #71
    //   Java source line #186	-> byte code offset #73
    //   Java source line #188	-> byte code offset #78
    //   Java source line #189	-> byte code offset #86
    //   Java source line #192	-> byte code offset #87
    //   Java source line #186	-> byte code offset #90
    //   Java source line #188	-> byte code offset #95
    //   Java source line #189	-> byte code offset #103
    //   Java source line #193	-> byte code offset #107
    //   Java source line #194	-> byte code offset #109
    //   Java source line #197	-> byte code offset #120
    //   Java source line #199	-> byte code offset #154
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	155	0	this	CustomCommandInterpreter
    //   0	155	1	bundle	org.osgi.framework.Bundle
    //   0	155	2	resource	String
    //   1	19	3	entry	java.net.URL
    //   23	73	4	in	InputStream
    //   107	6	4	e	Exception
    //   30	27	5	buffer	byte[]
    //   33	30	6	read	int
    //   71	17	7	localObject	Object
    //   86	1	9	localIOException1	IOException
    //   103	1	10	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   35	71	71	finally
    //   78	83	86	java/io/IOException
    //   95	100	103	java/io/IOException
    //   14	104	107	java/lang/Exception
  }
  
  private int getMaximumLinesToScroll()
  {
    return maxLineCount;
  }
  
  private void check4More()
  {
    int max = getMaximumLinesToScroll();
    if ((max > 0) && 
      (currentLineCount >= max))
    {
      out.print("-- More...Press Enter to Continue...");
      out.flush();
      try
      {
        System.in.read();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
      resetLineCount();
    }
  }
  
  private void resetLineCount()
  {
    currentLineCount = 0;
  }
  
  public String getHelp()
  {
    StringBuffer help = new StringBuffer(256);
    help.append("---Controlling the Console---");
    help.
1 2 3 4 5 6

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