clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1135967 - in /incubator/clerezza/trunk/parent: platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/ shell/src/main/scala/org/apache/clerezza/shell/
Date Wed, 15 Jun 2011 09:08:00 GMT
Author: reto
Date: Wed Jun 15 09:08:00 2011
New Revision: 1135967

URL: http://svn.apache.org/viewvc?rev=1135967&view=rev
Log:
CLEREZZA-565: prevent jline from accessing the dimensions of the terminal window. Added commend-line
argument to start without console shell

Modified:
    incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/ClerezzaApp.java
    incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/LauncherArguments.java
    incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala

Modified: incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/ClerezzaApp.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/ClerezzaApp.java?rev=1135967&r1=1135966&r2=1135967&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/ClerezzaApp.java
(original)
+++ incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/ClerezzaApp.java
Wed Jun 15 09:08:00 2011
@@ -53,7 +53,7 @@ import org.wymiwyg.commons.util.dirbrows
  * Clerezza Launcher Application.
  *
  *
- * @author daniel
+ * @author daniel, reto
  */
 public class ClerezzaApp {
 
@@ -164,9 +164,11 @@ public class ClerezzaApp {
 			showUsage();
 			return;
 		}
+		start(arguments);
+	}
 
+	private void start(LauncherArguments arguments) throws Throwable {
 		Properties configProps = getConfigProps(arguments);
-
 		Policy.setPolicy(new Policy() {
 
 			@Override
@@ -364,7 +366,10 @@ public class ClerezzaApp {
 		return artsToBeInstalled;
 	}
 
-	private void showUsage() {
+	/**
+	 * Prints usage instructions to stdout
+	 */
+	public static void showUsage() {
 		System.out.print("Usage: LaunchBundle ");
 		System.out.println(AnnotatedInterfaceArguments.getArgumentsSyntax(LauncherArguments.class));
 		PrintWriter out = new PrintWriter(System.out, true);
@@ -372,12 +377,20 @@ public class ClerezzaApp {
 				LauncherArguments.class, out);
 		out.flush();
 	}
+	
 
 	private Properties getConfigProps(LauncherArguments arguments) {
 
 		Properties configProps = new Properties();
 		configProps.putAll(System.getProperties());
 		{
+			if (arguments.getNotConsoleShell()) {
+				configProps.put("clerezza.shell.disable",
+					"true");
+			}
+		}
+
+		{
 			String argLogLevel = arguments.getLogLevel();
 			if (argLogLevel == null) {
 				argLogLevel = "INFO";

Modified: incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/LauncherArguments.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/LauncherArguments.java?rev=1135967&r1=1135966&r2=1135967&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/LauncherArguments.java
(original)
+++ incubator/clerezza/trunk/parent/platform.launcher.storageless.parent/platform.launcher.storageless/src/main/java/org/apache/clerezza/platform/launcher/LauncherArguments.java
Wed Jun 15 09:08:00 2011
@@ -62,6 +62,9 @@ public interface LauncherArguments {
 	@CommandLine(longName = "https_keystore_clientauth", shortName = {}, required = false,
 	description = "Client Auth request, one of \"none\", \"want\" or \"need\"")
 	public String getClientAuth();
-	
-	
+
+	@CommandLine(longName = "noConsoleShell", shortName = {"NCS"}, required = false,
+	isSwitch = true, description = "Disable the console shell")
+	public boolean getNotConsoleShell();
+
 }

Modified: incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala?rev=1135967&r1=1135966&r2=1135967&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala
(original)
+++ incubator/clerezza/trunk/parent/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala
Wed Jun 15 09:08:00 2011
@@ -32,11 +32,15 @@ import java.net._
 import java.security.PrivilegedActionException
 import java.security.AccessController
 import java.security.PrivilegedAction
-import java.util.{ArrayList, Arrays};
+
 import javax.script.ScriptContext
 import javax.script.{ScriptEngineFactory => JavaxEngineFactory, Compilable,
 					 CompiledScript, ScriptEngine, AbstractScriptEngine, Bindings,
 					 SimpleBindings, ScriptException}
+import jline.CandidateListCompletionHandler
+import jline.{CompletionHandler, Completor, Terminal, ConsoleReader, ArgumentCompletor, History
=> JHistory}
+import java.util.{ArrayList, Arrays}
+
 //import scala.collection.immutable.Map
 import scala.actors.DaemonActor
 import scala.collection.immutable
@@ -53,9 +57,10 @@ import scala.actors.Actor
 import scala.actors.Actor._
 import org.apache.clerezza.scala.scripting._
 import java.io.File
-import jline.{ ConsoleReader, ArgumentCompletor, History => JHistory }
+import org.slf4j.scala.Logging
 
-class Shell(factory: InterpreterFactory, val inStream: InputStream, out: OutputStream, shellCommands:
immutable.Set[ShellCommand])  {
+class Shell(factory: InterpreterFactory, val inStream: InputStream, 
+			out: OutputStream, shellCommands: immutable.Set[ShellCommand]) extends Logging {
 
 
 	private var bundleContext: BundleContext = null
@@ -130,20 +135,73 @@ class Shell(factory: InterpreterFactory,
 				override lazy val completion = Option(interpreter) map (x => new Completion(x))
 
 				val consoleReader = {
-					val r = new jline.ConsoleReader(inStream, out)
+					val terminal = new jline.UnixTerminal
+					/*val terminal = new jline.Terminal {
+						override def initializeTerminal() {logger.warn("JLINE: initializing echo")}
+
+						override def isEchoEnabled =  { logger.warn("JLINE: is enabled echo")
+						true}
+
+						override def isSupported = { logger.warn("JLINE: is supported echo")
+						true}
+
+						override def enableEcho() { logger.warn("JLINE: enabling echo")}
+
+						override def disableEcho() {logger.warn("JLINE: disabling echo") }
+
+						override def getTerminalHeight = 24
+
+						override def getTerminalWidth = 80
+
+						override def getEcho = false
+					}*/
+					val r = new jline.ConsoleReader(inStream, out, null, terminal)
 					r setHistory (History().jhistory)
 					r setBellEnabled false
 					completion foreach { c =>
+						logger.warn("JLINE: adding completor : "+c.jline)
 						r addCompletor c.jline
 						r setAutoprintThreshhold 250
 					}
+					import java.util.List
+					r setCompletionHandler new CompletionHandler {
+						def complete(reader: ConsoleReader, candidates: List[_], pos: Int) = {
+							val buffer = reader.getCursorBuffer()
+							if (candidates.size == 1) {
+								CandidateListCompletionHandler.setBuffer(reader, candidates.get(0).toString, pos)
+							} else {
+								import collection.JavaConversions._
+								out.println()
+								out.println(candidates.mkString("\t"))
+								out.print(prompt)
+								out.print(reader.getCursorBuffer())
+							}
+							true
+						}
+					}
+				  
+				  r addCompletor new Completor {
+						def complete(p1: String, p2: Int, candidates: java.util.List[_]) = {
+							logger.warn("JLINE: candidates : "+candidates)
+							val canStrings = candidates.asInstanceOf[List[String]]
+							canStrings.add("Clerezza")
+							canStrings.add("Apache")
+							try {
+								throw new RuntimeException
+							} catch {
+								case e => logger.warn("stack ", e)
+							}
+							0
+						}
+					}
 
 					r
 				}
 
 				def readOneLine(prompt: String) = consoleReader readLine prompt
-				val interactive = true
+				val interactive = false
 			}
+		   //in = new SimpleReader(inStream, out, true)
 
 			loadFiles(settings)
 			try {



Mime
View raw message