Revision: 5325
          http://jnode.svn.sourceforge.net/jnode/?rev=5325&view=rev
Author:   crawley
Date:     2009-04-20 15:21:03 +0000 (Mon, 20 Apr 2009)

Log Message:
-----------
Once more ... with feeling.

Modified Paths:
--------------
    trunk/distr/src/emu/org/jnode/emu/ShellEmu.java
    trunk/shell/src/shell/org/jnode/shell/CommandShell.java
    trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java

Modified: trunk/distr/src/emu/org/jnode/emu/ShellEmu.java
===================================================================
--- trunk/distr/src/emu/org/jnode/emu/ShellEmu.java     2009-04-20 14:53:47 UTC 
(rev 5324)
+++ trunk/distr/src/emu/org/jnode/emu/ShellEmu.java     2009-04-20 15:21:03 UTC 
(rev 5325)
@@ -24,11 +24,13 @@
 
 import org.jnode.driver.console.ConsoleManager;
 import org.jnode.driver.console.swing.SwingTextScreenConsoleManager;
+import org.jnode.driver.console.textscreen.TextScreenConsole;
 import org.jnode.driver.console.textscreen.TextScreenConsoleManager;
 import org.jnode.shell.CommandShell;
 
 /**
  * @author Levente S\u00e1ntha
+ * @author craw...@jnode.org
  */
 public class ShellEmu extends Emu {
     
@@ -46,9 +48,9 @@
 
     private void run() throws Exception {
         TextScreenConsoleManager cm = new SwingTextScreenConsoleManager();
-        new Thread(new CommandShell(cm.createConsole(
-            "Console 1",
-            (ConsoleManager.CreateOptions.TEXT |
-                ConsoleManager.CreateOptions.SCROLLABLE)))).start();
+        TextScreenConsole console = cm.createConsole(
+                "Console 1",
+                (ConsoleManager.CreateOptions.TEXT | 
ConsoleManager.CreateOptions.SCROLLABLE));
+        new Thread(new CommandShell(console, true)).start();
     }
 }

Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShell.java     2009-04-20 
14:53:47 UTC (rev 5324)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java     2009-04-20 
15:21:03 UTC (rev 5325)
@@ -104,6 +104,9 @@
     public static final String DIRECTORY_PROPERTY_NAME = "user.dir";
 
     public static final String INITIAL_INVOKER = "proclet";
+    // The Emu-mode invoker must be something that runs on the dev't platform;
+    // e.g. not 'isolate' or 'proclet'.
+    private static final String EMU_INVOKER = "thread";
     public static final String INITIAL_INTERPRETER = "redirecting";
     public static final String FALLBACK_INVOKER = "default";
     public static final String FALLBACK_INTERPRETER = "default";
@@ -199,6 +202,10 @@
     }
 
     public CommandShell(TextConsole cons) throws ShellException {
+        this(cons, false);
+    }
+    
+    public CommandShell(TextConsole cons, boolean emu) throws ShellException {
         debugEnabled = true;
         try {
             console = cons;
@@ -216,7 +223,7 @@
             console.addConsoleListener(this);
             aliasMgr = ShellUtils.getAliasManager().createAliasManager();
             syntaxMgr = ShellUtils.getSyntaxManager().createSyntaxManager();
-            propertyMap = initShellProperties();
+            propertyMap = initShellProperties(emu);
         } catch (NameNotFoundException ex) {
             throw new ShellException("Cannot find required resource", ex);
         } catch (Exception ex) {
@@ -225,11 +232,12 @@
     }
     
     /**
-     * Create a CommandShell that doesn't use a TextConsole or the 
ConsoleManager.
+     * Create a CommandShell that doesn't use a TextConsole or the 
ConsoleManager
+     * for use in the TestHarness.
      * 
      * @throws ShellException
      */
-    public CommandShell() throws ShellException {
+    protected CommandShell() throws ShellException {
         debugEnabled = true;
         try {
             setupStreams(new InputStreamReader(System.in), 
@@ -237,7 +245,7 @@
                     new OutputStreamWriter(System.err));
             aliasMgr = ShellUtils.getAliasManager().createAliasManager();
             syntaxMgr = ShellUtils.getSyntaxManager().createSyntaxManager();
-            propertyMap = initShellProperties();
+            propertyMap = initShellProperties(true);
         } catch (NameNotFoundException ex) {
             throw new ShellException("Cannot find required resource", ex);
         } catch (Exception ex) {
@@ -245,12 +253,31 @@
         }
     }
     
-    private HashMap<String, String> initShellProperties() {
+    /**
+     * This constructor builds a partial command shell for test purposes only.
+     * 
+     * @param aliasMgr test framework supplies an alias manager
+     * @param syntaxMgr test framework supplies a syntax manager
+     */
+    protected CommandShell(AliasManager aliasMgr, SyntaxManager syntaxMgr) {
+        this.debugEnabled = true;
+        this.aliasMgr = aliasMgr;
+        this.syntaxMgr = syntaxMgr;
+        propertyMap = initShellProperties(true);
+        setupStreams(
+                new InputStreamReader(System.in), 
+                new OutputStreamWriter(System.out), 
+                new OutputStreamWriter(System.err));
+        this.readingCommand = true;
+    }
+
+    
+    private HashMap<String, String> initShellProperties(boolean emu) {
         HashMap<String, String> map = new HashMap<String, String>();
         map.put(PROMPT_PROPERTY_NAME, DEFAULT_PROMPT);
         map.put(DEBUG_PROPERTY_NAME, DEBUG_DEFAULT);
         map.put(HISTORY_PROPERTY_NAME, HISTORY_DEFAULT);
-        map.put(INVOKER_PROPERTY_NAME, INITIAL_INVOKER);
+        map.put(INVOKER_PROPERTY_NAME, emu ? EMU_INVOKER : INITIAL_INVOKER);
         map.put(INTERPRETER_PROPERTY_NAME, INITIAL_INTERPRETER);
         return map;
     }
@@ -263,27 +290,8 @@
         this.outPW = cout.getPrintWriter();
         this.errPW = cerr.getPrintWriter();
     }
-
     
     /**
-     * This constructor builds a partial command shell for test purposes only.
-     * 
-     * @param aliasMgr test framework supplies an alias manager
-     * @param syntaxMgr test framework supplies a syntax manager
-     */
-    protected CommandShell(AliasManager aliasMgr, SyntaxManager syntaxMgr) {
-        this.debugEnabled = true;
-        this.aliasMgr = aliasMgr;
-        this.syntaxMgr = syntaxMgr;
-        propertyMap = initShellProperties();
-        setupStreams(
-                new InputStreamReader(System.in), 
-                new OutputStreamWriter(System.out), 
-                new OutputStreamWriter(System.err));
-        this.readingCommand = true;
-    }
-
-    /**
      * Run this shell until exit.
      * 
      * @see java.lang.Runnable#run()
@@ -499,11 +507,6 @@
         ownThread = Thread.currentThread();
     }
     
-    public void configureEmuShell() throws ShellException {
-        propertyMap.put(INVOKER_PROPERTY_NAME, "thread");
-        configureShell();
-    }
-    
     @Override
     public String getProperty(String propName) {
         return propertyMap.get(propName);

Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java       
2009-04-20 14:53:47 UTC (rev 5324)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java       
2009-04-20 15:21:03 UTC (rev 5325)
@@ -92,7 +92,7 @@
 
     public CommandShell getShell() throws ShellException {
         CommandShell shell = new TestCommandShell(System.in, System.out, 
System.err);
-        shell.configureEmuShell();
+        shell.configureShell();
         return shell;
     }
     


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Jnode-svn-commits mailing list
Jnode-svn-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits

Reply via email to