You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ge...@apache.org on 2009/12/30 08:47:07 UTC
svn commit: r894555 -
/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java
Author: genspring
Date: Wed Dec 30 07:47:07 2009
New Revision: 894555
URL: http://svn.apache.org/viewvc?rev=894555&view=rev
Log:
GERONIMO-4948 To migrate existing geronimo gshell commands to karaf based shell. --- Fix the console prompt message display problem by changing the printwriter to auto flush.
Modified:
geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java
Modified: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java?rev=894555&r1=894554&r2=894555&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java Wed Dec 30 07:47:07 2009
@@ -23,11 +23,10 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
+import java.io.PrintWriter;
import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
import org.apache.geronimo.deployment.cli.ConsoleReader;
-import org.apache.geronimo.kernel.Kernel;
-import org.osgi.framework.ServiceReference;
/**
* @version $Rev$ $Date$
@@ -35,14 +34,33 @@
public abstract class BaseCommandSupport extends OsgiCommandSupport implements ConsoleReader {
-
- /**
+ private PrintWriter printWriter = null;
+ private BufferedReader lineReader = null;
+
+
+ /**
+ * Create printWriter and lineReader for the session
+ *
+ */
+ private void init(){
+
+ if (printWriter == null)
+ printWriter = new PrintWriter(session.getConsole(), true);
+
+ if (lineReader == null)
+ lineReader = new BufferedReader(new InputStreamReader(session.getKeyboard()));
+ }
+
+
+
+ /**
* Print an end-of-line marker.
*
* @exception IOException
*/
public void printNewline() throws IOException {
- session.getConsole().println();
+ init();
+ printWriter.println();
}
@@ -52,7 +70,8 @@
* @param data The line to write.
*/
public void println(String data) {
- session.getConsole().println(data);
+ init();
+ printWriter.println(data);
}
@@ -62,7 +81,8 @@
* @param data The line to write.
*/
public void printString(String data) {
- session.getConsole().print(data);
+ init();
+ printWriter.print(data);
}
@@ -73,7 +93,8 @@
* @exception IOException
*/
public String readLine() throws IOException {
- return new BufferedReader(new InputStreamReader(session.getKeyboard())).readLine();
+ init();
+ return lineReader.readLine();
}
@@ -96,6 +117,7 @@
* @exception IOException
*/
public void flushConsole() throws IOException {
- session.getConsole().flush();
+ init();
+ printWriter.flush();
}
}