felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From db...@apache.org
Subject svn commit: r944181 - in /felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell: Activator.java Shell.java Telnet.java
Date Fri, 14 May 2010 09:57:01 GMT
Author: dbaum
Date: Fri May 14 09:57:00 2010
New Revision: 944181

URL: http://svn.apache.org/viewvc?rev=944181&view=rev
Log:
register telnetd command directly, rather than via Shell.

Modified:
    felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java
    felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Shell.java
    felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java

Modified: felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java?rev=944181&r1=944180&r2=944181&view=diff
==============================================================================
--- felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java (original)
+++ felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java Fri May
14 09:57:00 2010
@@ -43,8 +43,6 @@ public class Activator implements Bundle
 
     public void start(final BundleContext context) throws Exception
     {
-        shell = new Shell(context);
-        registerCommands(context);
         commandProcessorTracker = processorTracker(context);
     }
 
@@ -91,25 +89,16 @@ public class Activator implements Bundle
         }
     }
 
-    private void startShell(CommandProcessor processor)
+    private void startShell(BundleContext context, CommandProcessor processor)
     {
-        session = processor.createSession(System.in, System.out, System.err);
-        shell.setProcessor(processor);
-        thread = new Thread(this, "Gogo shell");
-        thread.start();
-    }
-
-    private void registerCommands(BundleContext context)
-    {
-        // default converters
-        regs.add(context.registerService(Converter.class.getName(), new Converters(context),
null));
-        
         Dictionary<String, Object> dict = new Hashtable<String, Object>();
         dict.put(CommandProcessor.COMMAND_SCOPE, "gogo");
 
-        dict.put(CommandProcessor.COMMAND_FUNCTION, Shell.functions);
-        regs.add(context.registerService(Shell.class.getName(), shell, dict));
-
+        // register converters
+        regs.add(context.registerService(Converter.class.getName(), new Converters(context),
null));
+        
+        // register commands
+        
         dict.put(CommandProcessor.COMMAND_FUNCTION, Builtin.functions);
         regs.add(context.registerService(Builtin.class.getName(), new Builtin(), dict));
 
@@ -118,6 +107,18 @@ public class Activator implements Bundle
 
         dict.put(CommandProcessor.COMMAND_FUNCTION, Posix.functions);
         regs.add(context.registerService(Posix.class.getName(), new Posix(), dict));
+
+        dict.put(CommandProcessor.COMMAND_FUNCTION, Telnet.functions);
+        regs.add(context.registerService(Telnet.class.getName(), new Telnet(processor), dict));
+        
+        shell = new Shell(context, processor);
+        dict.put(CommandProcessor.COMMAND_FUNCTION, Shell.functions);
+        regs.add(context.registerService(Shell.class.getName(), shell, dict));
+        
+        // start shell
+        session = processor.createSession(System.in, System.out, System.err);
+        thread = new Thread(this, "Gogo shell");
+        thread.start();
     }
 
     private ServiceTracker processorTracker(BundleContext context)
@@ -129,7 +130,7 @@ public class Activator implements Bundle
             public Object addingService(ServiceReference reference)
             {
                 CommandProcessor processor = (CommandProcessor) super.addingService(reference);
-                startShell(processor);
+                startShell(context, processor);
                 return processor;
             }
 

Modified: felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Shell.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Shell.java?rev=944181&r1=944180&r2=944181&view=diff
==============================================================================
--- felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Shell.java (original)
+++ felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Shell.java Fri May 14
09:57:00 2010
@@ -19,7 +19,6 @@
 package org.apache.felix.gogo.shell;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
@@ -38,28 +37,22 @@ import org.osgi.service.command.CommandS
 
 public class Shell
 {
-    static final String[] functions = { "gosh", "sh", "source", "telnetd" };
+    static final String[] functions = { "gosh", "sh", "source" };
 
     private final static URI CWD = new File(".").toURI();
 
     private final URI baseURI;
     private final BundleContext context;
+    private final CommandProcessor processor;
 
-    private CommandProcessor processor;
-    private Telnet telnet;
-
-    public Shell(BundleContext context)
+    public Shell(BundleContext context, CommandProcessor processor)
     {
         this.context = context;
+        this.processor = processor;
         String baseDir = System.getProperty("gosh.home", System.getProperty("user.dir"));
         baseURI = new File(baseDir).toURI();
     }
 
-    public void setProcessor(CommandProcessor processor)
-    {
-        this.processor = processor;
-    }
-
     public Object gosh(final CommandSession session, String[] argv) throws Exception
     {
         final String[] usage = {
@@ -198,15 +191,6 @@ public class Shell
         }
     }
 
-    public void telnetd(String[] argv) throws IOException
-    {
-        if (telnet == null)
-        {
-            telnet = new Telnet(processor);
-        }
-        telnet.telnetd(argv);
-    }
-
     private Object console(CommandSession session)
     {
         Console console = new Console(session);

Modified: felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java?rev=944181&r1=944180&r2=944181&view=diff
==============================================================================
--- felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java (original)
+++ felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java Fri May 14
09:57:00 2010
@@ -35,6 +35,8 @@ import org.osgi.service.command.CommandS
  */
 public class Telnet implements Runnable
 {
+    static final String[] functions = { "telnetd" };
+    
     private static final int defaultPort = 2019;
     private final CommandProcessor processor;
     private ServerSocket server;



Mime
View raw message