You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2006/05/16 04:37:27 UTC
svn commit: r406803 - in /geronimo/sandbox/gshell/trunk:
gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/
gshell-core/src/main/java/org/apache/geronimo/gshell/console/
gshell-core/src/main/java/org/apache/geronimo/gshell/util/
Author: jdillon
Date: Mon May 15 19:37:26 2006
New Revision: 406803
URL: http://svn.apache.org/viewcvs?rev=406803&view=rev
Log:
Added Console abstraction to allow future pluggablility for enhanced readline-like support
Added:
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java
Modified:
geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Arguments.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Banner.java
Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=406803&r1=406802&r2=406803&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java Mon May 15 19:37:26 2006
@@ -28,6 +28,7 @@
import org.apache.geronimo.gshell.GShell;
import org.apache.geronimo.gshell.console.IO;
import org.apache.geronimo.gshell.console.InteractiveConsole;
+import org.apache.geronimo.gshell.console.SimpleConsole;
import org.apache.geronimo.gshell.util.Version;
import org.apache.geronimo.gshell.util.Banner;
@@ -186,7 +187,7 @@
}
if (interactive) {
- InteractiveConsole console = new InteractiveConsole(io, gshell);
+ InteractiveConsole console = new InteractiveConsole(new SimpleConsole(io), gshell);
// Check if there are args, and run them and then enter interactive
if (_args.length != 0) {
Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java?rev=406803&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java Mon May 15 19:37:26 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.gshell.console;
+
+import java.io.IOException;
+
+/**
+ * Abstraction of a console.
+ *
+ * <p>Allows pluggable implemenations (like to enable readline, etc.)
+ *
+ * @version $Id: IO.java 399599 2006-05-04 08:13:57Z jdillon $
+ */
+public interface Console
+{
+ String readLine(final String prompt) throws IOException;
+}
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java?rev=406803&r1=406802&r2=406803&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java Mon May 15 19:37:26 2006
@@ -23,12 +23,16 @@
import java.io.PrintWriter;
/**
- * ???
+ * Container for input/output handles.
*
* @version $Id$
*/
public class IO
{
+ //
+ // TODO: Expose the binary versions, wrap for text readers/writers
+ //
+
public final Reader in;
public final PrintWriter out;
public final PrintWriter err;
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java?rev=406803&r1=406802&r2=406803&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java Mon May 15 19:37:26 2006
@@ -20,9 +20,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.io.BufferedReader;
-import java.io.IOException;
-
/**
* ???
*
@@ -34,17 +31,14 @@
private static final Log log = LogFactory.getLog(InteractiveConsole.class);
private GShell gshell;
- private IO io;
- private BufferedReader reader;
+ private Console console;
- public InteractiveConsole(final IO io, final GShell gshell) {
- assert io != null;
+ public InteractiveConsole(final Console console, final GShell gshell) {
+ assert console != null;
assert gshell != null;
- this.io = io;
+ this.console = console;
this.gshell = gshell;
-
- reader = new BufferedReader(io.in);
}
public void run() {
@@ -52,9 +46,10 @@
while (true) {
try {
+ String prompt = "> ";
String line;
- while ((line = readLine("> ")) != null) {
+ while ((line = console.readLine(prompt)) != null) {
log.debug("Read line: " + line);
// Just ignore blank lines
@@ -72,14 +67,5 @@
log.error("Unhandled failure", e);
}
}
- }
-
- private String readLine(final String prompt) throws IOException {
- assert prompt != null;
-
- io.out.print(prompt);
- io.out.flush();
-
- return reader.readLine();
}
}
Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java?rev=406803&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java Mon May 15 19:37:26 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.gshell.console;
+
+import org.apache.geronimo.gshell.GShell;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+
+/**
+ * ???
+ *
+ * @version $Id: IO.java 399599 2006-05-04 08:13:57Z jdillon $
+ */
+public class SimpleConsole
+ implements Console
+{
+ private static final Log log = LogFactory.getLog(SimpleConsole.class);
+
+ private IO io;
+ private BufferedReader reader;
+
+ public SimpleConsole(final IO io) {
+ assert io != null;
+
+ this.io = io;
+ this.reader = new BufferedReader(io.in);
+ }
+
+ public String readLine(final String prompt) throws IOException {
+ assert prompt != null;
+
+ io.out.print(prompt);
+ io.out.flush();
+
+ return reader.readLine();
+ }
+}
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Arguments.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Arguments.java?rev=406803&r1=406802&r2=406803&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Arguments.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Arguments.java Mon May 15 19:37:26 2006
@@ -17,7 +17,7 @@
package org.apache.geronimo.gshell.util;
/**
- * ???
+ * Utils for command-line arguments.
*
* @version $Id: GShellImpl.java 405303 2006-05-09 04:55:39Z jdillon $
*/
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Banner.java
URL: http://svn.apache.org/viewcvs/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Banner.java?rev=406803&r1=406802&r2=406803&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Banner.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/util/Banner.java Mon May 15 19:37:26 2006
@@ -20,7 +20,7 @@
import java.io.PrintWriter;
/**
- * ???
+ * Display helper for the sexy GShell banner.
*
* @version $Id$
*/