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/18 19:10:36 UTC
svn commit: r1232980 -
/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
Author: rmannibucau
Date: Wed Jan 18 18:10:36 2012
New Revision: 1232980
URL: http://svn.apache.org/viewvc?rev=1232980&view=rev
Log:
managing groovy files
Modified:
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.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=1232980&r1=1232979&r2=1232980&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 Wed Jan 18 18:10:36 2012
@@ -9,6 +9,7 @@ import org.apache.openejb.loader.SystemI
import org.apache.openejb.server.groovy.OpenEJBGroovyShell;
import org.apache.openejb.util.helper.CommandHelper;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -18,7 +19,8 @@ import java.util.Collection;
public class CliRunnable implements Runnable {
public static final String EXIT_COMMAND = "exit";
- private static final String GROOVY_PREFIX = "G ";
+ private static final String GROOVY_PREFIX = "groovy ";
+ private static final String GROOVY_FILE_PREFIX = "groovy_file ";
private static final String LIST_CMD = "list";
private static final String PROPERTIES_CMD = "properties";
private static final String WELCOME = "Welcome on your $bind:$port $name server";
@@ -113,9 +115,15 @@ public class CliRunnable implements Runn
if (line.startsWith(GROOVY_PREFIX)) {
try {
- write(sout, result(line.substring(GROOVY_PREFIX.length())));
- } catch (CliRuntimeException sshEx) {
- write((Exception) sshEx.getCause());
+ write(sout, asString(shell.evaluate(line.substring(GROOVY_PREFIX.length()))));
+ } catch (Exception e) {
+ write(e);
+ }
+ } else if (GROOVY_FILE_PREFIX.equals(line)) {
+ try {
+ write(sout, asString(shell.evaluate(new File(line.substring(GROOVY_PREFIX.length())))));
+ } catch (Exception e) {
+ write(e);
}
} else if (LIST_CMD.equals(line)) {
list();
@@ -167,14 +175,7 @@ public class CliRunnable implements Runn
}
}
- private String result(final String value) {
- Object out;
- try {
- out = shell.evaluate(value);
- } catch (Exception e) {
- throw new CliRuntimeException(e);
- }
-
+ private String asString(Object out) {
if (out == null) {
return "null";
}