You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/01/19 20:05:07 UTC
svn commit: r1233535 - in /openejb/trunk/openejb/server:
openejb-common-cli/src/main/java/org/apache/openejb/server/cli/
openejb-common-cli/src/main/resources/
openejb-ssh/src/test/java/org/apache/openejb/server/ssh/
Author: rmannibucau
Date: Thu Jan 19 19:05:06 2012
New Revision: 1233535
URL: http://svn.apache.org/viewvc?rev=1233535&view=rev
Log:
some logo in the cli
Added:
openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/
openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/branding.properties
Modified:
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/OpenEJBScripter.java
openejb/trunk/openejb/server/openejb-ssh/src/test/java/org/apache/openejb/server/ssh/SSHServerTest.java
Modified: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java?rev=1233535&r1=1233534&r2=1233535&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java (original)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java Thu Jan 19 19:05:06 2012
@@ -18,6 +18,7 @@ package org.apache.openejb.server.cli;
import jline.ConsoleReader;
import jline.FileNameCompletor;
+import jline.SimpleCompletor;
import org.apache.openejb.server.cli.command.AbstractCommand;
import org.apache.openejb.server.cli.command.Deploy;
import org.apache.openejb.server.cli.command.ExitCommand;
@@ -27,6 +28,8 @@ import org.apache.openejb.server.cli.com
import org.apache.openejb.server.cli.command.ScriptCommand;
import org.apache.openejb.server.cli.command.ScriptFileCommand;
import org.apache.openejb.server.cli.command.Undeploy;
+import org.apache.openejb.util.OpenEjbVersion;
+import org.apache.openejb.util.SuperProperties;
import org.apache.xbean.recipe.ObjectRecipe;
import org.apache.xbean.recipe.Option;
@@ -37,10 +40,20 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
public class CliRunnable implements Runnable {
+ private static final String BRANDING_FILE = "branding.properties";
+ private static final String WELCOME_KEY_PREFIX = "welcome_";
+ private static final String WELCOME_COMMON_KEY = WELCOME_KEY_PREFIX + "common";
+ private static final String WELCOME_OPENEJB_KEY = WELCOME_KEY_PREFIX + "openejb";
+ private static final String WELCOME_TOMEE_KEY = WELCOME_KEY_PREFIX + "tomee";
+
+ public static final String TOMEE_NAME = "TomEE";
+ public static final String OPENEJB_NAME = "OpenEJB";
+
public static final String EXIT_COMMAND = "exit";
- private static final String WELCOME = "Welcome on your $bind:$port $name server";
+ private static final String DEFAULT_WELCOME = "Welcome on your $bind:$port $name server";
private static final String OS_LINE_SEP = System.getProperty("line.separator");
private static final String NAME;
private static final String PROMPT;
@@ -51,16 +64,26 @@ public class CliRunnable implements Runn
Deploy.class, Undeploy.class,
HelpCommand.class, ExitCommand.class);
+ private static final Properties PROPERTIES = new Properties();
+ private static final boolean tomee;
+
static {
- String name = "OpenEJB";
+ String name = OPENEJB_NAME;
try {
CliRunnable.class.getClassLoader().loadClass("org.apache.tomee.loader.TomcatHook");
- name = "TomEE";
+ name = TOMEE_NAME;
} catch (ClassNotFoundException cnfe) {
// ignored, we are using a simple OpenEJB server
}
+ tomee = TOMEE_NAME.equals(name);
NAME = name;
PROMPT = NAME.toLowerCase() + PROMPT_SUFFIX;
+
+ try {
+ PROPERTIES.load(CliRunnable.class.getClassLoader().getResourceAsStream(BRANDING_FILE));
+ } catch (IOException e) {
+ // no-op
+ }
}
public String lineSep;
@@ -150,13 +173,30 @@ public class CliRunnable implements Runn
final ConsoleReader reader = new ConsoleReader(sin, streamManager.getSout());
reader.addCompletor(new FileNameCompletor());
- // TODO : add completers with method names...?
+ reader.addCompletor(new SimpleCompletor(commands.keySet().toArray(new String[commands.size()])));
+ // TODO : add completers
String line;
- streamManager.writeOut(WELCOME // simple replace for now, if it is mandatory we could bring velocity to do it
+ StringBuilder builtWelcome = new StringBuilder("Apache OpenEJB ")
+ .append(OpenEjbVersion.get().getVersion())
+ .append(" build: ")
+ .append(OpenEjbVersion.get().getDate())
+ .append("-")
+ .append(OpenEjbVersion.get().getTime())
+ .append(lineSep);
+ if (tomee) {
+ builtWelcome.append(OS_LINE_SEP).append(PROPERTIES.getProperty(WELCOME_TOMEE_KEY));
+ } else {
+ builtWelcome.append(OS_LINE_SEP).append(PROPERTIES.getProperty(WELCOME_OPENEJB_KEY));
+ }
+ builtWelcome.append(lineSep).append(PROPERTIES.getProperty(WELCOME_COMMON_KEY));
+
+ streamManager.writeOut(OpenEjbVersion.get().getUrl());
+ streamManager.writeOut(builtWelcome.toString()
.replace("$bind", bind)
.replace("$port", Integer.toString(port))
- .replace("$name", NAME));
+ .replace("$name", NAME)
+ .replace(OS_LINE_SEP, lineSep));
while ((line = reader.readLine(prompt())) != null) {
// exit simply let us go out of the loop
Modified: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/OpenEJBScripter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/OpenEJBScripter.java?rev=1233535&r1=1233534&r2=1233535&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/OpenEJBScripter.java (original)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/OpenEJBScripter.java Thu Jan 19 19:05:06 2012
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.openejb.server.cli;
import org.apache.openejb.BeanContext;
Added: openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/branding.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/branding.properties?rev=1233535&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/branding.properties (added)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/resources/branding.properties Thu Jan 19 19:05:06 2012
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+welcome_common = Welcome on your $bind:$port $name server
+
+welcome_openejb = \ \ ___ ___ _ ___\r\n\
+\ / _ \\ _ __ ___ _ _ | __| | | _ )\r\n\
+| (_) | '_ \\/ -_) ' \\| _| || | _ \\ \r\n\
+\ \\___/| .__/\\___|_||_|___\\__/|___/\r\n\
+\ \ \ \ \ \ |_|
+
+welcome_tomee = \ \ _____ ___ ___\r\n\
+|_ _|__ _ __ | __| __|\r\n\
+\ \ | |/ _ \\ ' \\| _|| _|\r\n\
+\ \ |_|\\___/_|_|_|___|___|\r\n\
Modified: openejb/trunk/openejb/server/openejb-ssh/src/test/java/org/apache/openejb/server/ssh/SSHServerTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ssh/src/test/java/org/apache/openejb/server/ssh/SSHServerTest.java?rev=1233535&r1=1233534&r2=1233535&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-ssh/src/test/java/org/apache/openejb/server/ssh/SSHServerTest.java (original)
+++ openejb/trunk/openejb/server/openejb-ssh/src/test/java/org/apache/openejb/server/ssh/SSHServerTest.java Thu Jan 19 19:05:06 2012
@@ -31,6 +31,7 @@ import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.HashMap;
+import java.util.concurrent.CountDownLatch;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -54,8 +55,8 @@ public class SSHServerTest {
System.getProperties().remove("openejb.server.ssh.key");
}
- @Test(timeout = 10000L)
- public void call() throws Exception {
+ @Test(timeout = 1000000L)
+ public void call() throws Exception {new CountDownLatch(1).await();
final SshClient client = SshClient.setUpDefaultClient();
client.start();
try {