removed legacy felix command adaptor. (FELIX-2342)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@944229 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/commands/pom.xml b/gogo/commands/pom.xml
index de58430..d465ff3 100644
--- a/gogo/commands/pom.xml
+++ b/gogo/commands/pom.xml
@@ -24,7 +24,7 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <packaging>bundle</packaging>
-    <name>Apache Felix Gogo Commands</name>
+    <name>Apache Felix Gogo Command Framework</name>
     <artifactId>org.apache.felix.gogo.commands</artifactId>
     <version>0.5.0-SNAPSHOT</version>
     <dependencies>
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java
index b3e6370..8b8c0ca 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java
@@ -19,9 +19,7 @@
 package org.apache.felix.gogo.runtime;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.felix.gogo.runtime.shell.CommandProcessorImpl;
 import org.apache.felix.gogo.runtime.shell.CommandProxy;
@@ -44,10 +42,8 @@
     private ThreadIOImpl threadio;
     private ServiceTracker commandTracker;
     private ServiceTracker converterTracker;
-    private ServiceTracker felixTracker;
     private ServiceRegistration processorRegistration;
     private ServiceRegistration threadioRegistration;
-    private Map<ServiceReference, ServiceRegistration> felixRegistrations;
     
     protected CommandProcessorImpl newProcessor(ThreadIO tio, BundleContext context)
     {
@@ -68,10 +64,6 @@
         commandTracker = trackOSGiCommands(context);
         commandTracker.open();
 
-        felixRegistrations = new HashMap<ServiceReference, ServiceRegistration>();
-        felixTracker = trackFelixCommands(context);
-        felixTracker.open();
-
         converterTracker = new ServiceTracker(context, Converter.class.getName(), null)
         {
             @Override
@@ -96,11 +88,8 @@
     {
         processorRegistration.unregister();
         threadioRegistration.unregister();
-        
         commandTracker.close();
         converterTracker.close();
-        felixTracker.close();
-
         threadio.stop();
     }
 
@@ -169,39 +158,4 @@
         };
     }
 
-    private ServiceTracker trackFelixCommands(final BundleContext context)
-    {
-        return new ServiceTracker(context, FelixCommandAdaptor.FELIX_COMMAND, null)
-        {
-            @Override
-            public Object addingService(ServiceReference ref)
-            {
-                Object felixCommand = super.addingService(ref);
-                try
-                {
-                    FelixCommandAdaptor adaptor = new FelixCommandAdaptor(felixCommand);
-                    felixRegistrations.put(ref, context.registerService(
-                        FelixCommandAdaptor.class.getName(), adaptor,
-                        adaptor.getAttributes()));
-                    return felixCommand;
-                }
-                catch (Exception e)
-                {
-                    System.err.println("felixcmd: " + e);
-                    return null;
-                }
-            }
-
-            @Override
-            public void removedService(ServiceReference reference, Object service)
-            {
-                ServiceRegistration reg = felixRegistrations.remove(reference);
-                if (reg != null)
-                {
-                    reg.unregister();
-                }
-                super.removedService(reference, service);
-            }
-        };
-    }
 }
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/FelixCommandAdaptor.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/FelixCommandAdaptor.java
deleted file mode 100644
index 1aeefc3..0000000
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/FelixCommandAdaptor.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.apache.felix.gogo.runtime;
-
-import java.io.PrintStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.osgi.service.command.CommandProcessor;
-
-public class FelixCommandAdaptor
-{
-    public static final String FELIX_COMMAND = "org.apache.felix.shell.Command";
-    private final Object felixCommand;
-    private Method execute;
-    private String help;
-    private String name;
-    private String usage;
-
-    public FelixCommandAdaptor(Object felixCommand) throws Exception
-    {
-        this.felixCommand = felixCommand;
-        Class<?> c = felixCommand.getClass();
-        Class<?>[] parms = { String.class, PrintStream.class, PrintStream.class };
-        execute = c.getMethod("execute", parms);
-
-        Method m;
-        m = c.getMethod("getName", (Class[]) null);
-        name = (String) m.invoke(felixCommand, (Object[]) null);
-
-        m = c.getMethod("getShortDescription", (Class[]) null);
-        help = (String) m.invoke(felixCommand, (Object[]) null);
-
-        m = c.getMethod("getUsage", (Class[]) null);
-        usage = (String) m.invoke(felixCommand, (Object[]) null);
-    }
-
-    public void _main(String[] argv) throws Exception
-    {
-        StringBuilder buf = new StringBuilder();
-        for (String arg : argv)
-        {
-            if (buf.length() > 0)
-                buf.append(' ');
-            buf.append(arg);
-        }
-
-        try
-        {
-            Object[] args = { buf.toString(), System.out, System.err };
-            execute.invoke(felixCommand, args);
-        }
-        catch (InvocationTargetException e)
-        {
-            Throwable cause = e.getCause();
-            if (cause instanceof Exception)
-                throw (Exception) cause;
-            throw e;
-        }
-    }
-
-    public Dictionary<String, Object> getAttributes()
-    {
-        Dictionary<String, Object> dict = new Hashtable<String, Object>();
-        dict.put(CommandProcessor.COMMAND_SCOPE, "felix");
-        dict.put(CommandProcessor.COMMAND_FUNCTION, name);
-        return dict;
-    }
-
-}