You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gn...@apache.org on 2008/03/19 14:30:56 UTC
svn commit: r638824 - in /geronimo/gshell/trunk:
gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/
gshell-core/src/main/java/org/apache/geronimo/gshell/
gshell-parser/src/main/grammar/
gshell-parser/src/test/java/org/apache/geronimo/...
Author: gnodet
Date: Wed Mar 19 06:30:40 2008
New Revision: 638824
URL: http://svn.apache.org/viewvc?rev=638824&view=rev
Log:
GSHELL-23: command pipelines
Modified:
geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java
geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java
geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java
geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java
geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/LoggingVisitor.java
geronimo/gshell/trunk/gshell-parser/src/main/grammar/CommandLineParser.jjt
geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java
geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserVisitorTest.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java
Modified: geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java (original)
+++ geronimo/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java Wed Mar 19 06:30:40 2008
@@ -31,4 +31,6 @@
Object execute(String command, final Object[] args) throws Exception;
Object execute(Object... args) throws Exception;
+
+ Object execute(Object[][] commands) throws Exception;
}
Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java (original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java Wed Mar 19 06:30:40 2008
@@ -19,12 +19,20 @@
package org.apache.geronimo.gshell;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.CommandExecutor;
+import org.apache.geronimo.gshell.command.CommandInfo;
import org.apache.geronimo.gshell.command.IO;
import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.command.CommandInfo;
import org.apache.geronimo.gshell.common.Arguments;
import org.apache.geronimo.gshell.common.StopWatch;
import org.apache.geronimo.gshell.layout.LayoutManager;
@@ -37,6 +45,7 @@
import org.apache.geronimo.gshell.shell.Environment;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.util.IOUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -108,34 +117,81 @@
log.info("Executing (Object...): [{}]", Arguments.asString(args));
- return execute(String.valueOf(args[0]), Arguments.shift(args));
+ return execute(String.valueOf(args[0]), Arguments.shift(args), env.getIO());
}
- private String findCommandId(final Node node) throws NotFoundException {
- assert node != null;
+ public Object execute(final String path, final Object[] args) throws Exception {
+ assert path != null;
+ assert args != null;
- if (node instanceof AliasNode) {
- AliasNode aliasNode = (AliasNode) node;
- String targetPath = aliasNode.getCommand();
- Node target = layoutManager.findNode(layoutManager.getLayout(), targetPath);
+ log.info("Executing ({}): [{}]", path, Arguments.asString(args));
- return findCommandId(target);
- }
- else if (node instanceof CommandNode) {
- CommandNode commandNode = (CommandNode) node;
+ return execute(path, args, env.getIO());
+ }
- return commandNode.getId();
+ public Object execute(final Object[][] commands) throws Exception {
+ // Prepare IOs
+ final IO[] ios = new IO[commands.length];
+ PipedOutputStream pos = null;
+ for (int i = 0; i < ios.length; i++) {
+ InputStream is = (i == 0) ? env.getIO().inputStream : new PipedInputStream(pos);
+ OutputStream os;
+ if (i == ios.length - 1) {
+ os = env.getIO().outputStream;
+ } else {
+ os = pos = new PipedOutputStream();
+ }
+ ios[i] = new IO(is, os, env.getIO().errorStream);
}
-
- throw new NotFoundException("Unable to get command id for: " + node);
+ Thread[] threads = new Thread[commands.length];
+ final List<Throwable> errors = new CopyOnWriteArrayList<Throwable>();
+ final AtomicReference ref = new AtomicReference();
+ for (int i = 0; i < commands.length; i++) {
+ final int idx = i;
+ threads[i] = createThread(new Runnable() {
+ public void run() {
+ try {
+ Object o = execute(String.valueOf(commands[idx][0]), Arguments.shift(commands[idx]), ios[idx]);
+ if (idx == commands.length - 1) {
+ ref.set(o);
+ }
+ } catch (Throwable t) {
+ errors.add(t);
+ } finally {
+ if (idx > 0) {
+ IOUtil.close(ios[idx].inputStream);
+ }
+ if (idx < commands.length - 1) {
+ IOUtil.close(ios[idx].outputStream);
+ }
+ }
+ }
+ });
+ threads[i].start();
+ }
+ for (int i = 0; i < commands.length; i++) {
+ threads[i].join();
+ }
+ if (!errors.isEmpty()) {
+ Throwable t = errors.get(0);
+ if (t instanceof Exception) {
+ throw (Exception) t;
+ } else if (t instanceof RuntimeException) {
+ throw (RuntimeException) t;
+ } else if (t instanceof Error) {
+ throw (Error) t;
+ } else {
+ throw new RuntimeException(t);
+ }
+ }
+ return ref.get();
}
- public Object execute(final String path, final Object[] args) throws Exception {
- assert path != null;
- assert args != null;
+ protected Thread createThread(Runnable run) {
+ return new Thread(run);
+ }
- log.info("Executing ({}): [{}]", path, Arguments.asString(args));
-
+ protected Object execute(final String path, final Object[] args, final IO io) throws Exception {
final String searchPath = (String) env.getVariables().get(LayoutManager.COMMAND_PATH);
final Node node = layoutManager.findNode(path, searchPath);
@@ -158,7 +214,7 @@
CommandInfo info;
public IO getIO() {
- return env.getIO();
+ return io;
}
public Variables getVariables() {
@@ -222,4 +278,24 @@
return result;
}
+
+ protected String findCommandId(final Node node) throws NotFoundException {
+ assert node != null;
+
+ if (node instanceof AliasNode) {
+ AliasNode aliasNode = (AliasNode) node;
+ String targetPath = aliasNode.getCommand();
+ Node target = layoutManager.findNode(layoutManager.getLayout(), targetPath);
+
+ return findCommandId(target);
+ }
+ else if (node instanceof CommandNode) {
+ CommandNode commandNode = (CommandNode) node;
+
+ return commandNode.getId();
+ }
+
+ throw new NotFoundException("Unable to get command id for: " + node);
+ }
+
}
Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java (original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java Wed Mar 19 06:30:40 2008
@@ -31,6 +31,7 @@
import org.apache.geronimo.gshell.command.CommandExecutor;
import org.apache.geronimo.gshell.command.IO;
import org.apache.geronimo.gshell.console.Console;
+import org.apache.geronimo.gshell.console.Console.ErrorHandler;
import org.apache.geronimo.gshell.console.JLineConsole;
import org.apache.geronimo.gshell.console.TerminalInfo;
import org.apache.geronimo.gshell.console.Console.Prompter;
@@ -80,6 +81,8 @@
private Prompter prompter;
+ private ErrorHandler errorHandler;
+
public DefaultShell() {}
public DefaultShell(final ShellInfo shellInfo, final Branding branding, final CommandExecutor executor, final Terminal terminal, final Environment env, final IO io) {
@@ -131,6 +134,10 @@
return executor.execute(path, args);
}
+ public Object execute(Object[][] commands) throws Exception {
+ return executor.execute(commands);
+ }
+
//
// Interactive Shell
//
@@ -173,15 +180,7 @@
console.setPrompter(getPrompter());
// Delegate errors for display and then continue
- console.setErrorHandler(new Console.ErrorHandler() {
- public Result handleError(final Throwable error) {
- assert error != null;
-
- displayError(error);
-
- return Result.CONTINUE;
- }
- });
+ console.setErrorHandler(getErrorHandler());
// Hook up a nice history file (we gotta hold on to the history object at some point so the 'history' command can get to it)
History history = new History();
@@ -235,6 +234,29 @@
String path = "/";
return renderer.render("@|bold " + userName + "|@" + hostName + ":@|bold " + path + "|> ");
+ }
+ };
+ }
+
+ public ErrorHandler getErrorHandler() {
+ if (errorHandler == null) {
+ errorHandler = createErrorHandler();
+ }
+ return errorHandler;
+ }
+
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ public ErrorHandler createErrorHandler() {
+ return new ErrorHandler() {
+ public Result handleError(final Throwable error) {
+ assert error != null;
+
+ displayError(error);
+
+ return Result.CONTINUE;
}
};
}
Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java (original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java Wed Mar 19 06:30:40 2008
@@ -30,8 +30,10 @@
import org.apache.geronimo.gshell.parser.ASTExpression;
import org.apache.geronimo.gshell.parser.ASTOpaqueString;
import org.apache.geronimo.gshell.parser.ASTPlainString;
+import org.apache.geronimo.gshell.parser.ASTProcess;
import org.apache.geronimo.gshell.parser.ASTQuotedString;
import org.apache.geronimo.gshell.parser.CommandLineParserVisitor;
+import org.apache.geronimo.gshell.parser.Node;
import org.apache.geronimo.gshell.parser.SimpleNode;
import org.apache.geronimo.gshell.shell.Environment;
import org.slf4j.Logger;
@@ -82,22 +84,28 @@
public Object visit(final ASTExpression node, final Object data) {
assert node != null;
- // Create the argument list (cmd name + args)
- List<Object> list = new ArrayList<Object>(node.jjtGetNumChildren());
- node.childrenAccept(this, list);
-
- Object[] args = list.toArray(new Object[list.size()]);
- assert list.size() >= 1;
-
- String path = String.valueOf(args[0]);
- args = Arguments.shift(args);
-
+ Object[][] commands = new Object[node.jjtGetNumChildren()][];
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ ASTProcess proc = (ASTProcess) node.jjtGetChild(i);
+ List<Object> list = new ArrayList<Object>(proc.jjtGetNumChildren());
+ proc.childrenAccept(this, list);
+ commands[i] = list.toArray(new Object[list.size()]);
+ assert list.size() >= 1;
+ }
try {
- return executor.execute(path, args);
+ return executor.execute(commands);
}
catch (Exception e) {
- throw new ErrorNotification("Shell execution failed; path=" + path + "; args=" + Arguments.asString(args), e);
+ String s = Arguments.asString(commands[0]);
+ for (int i = 1; i < commands.length; i++) {
+ s += " | " + Arguments.asString(commands[i]);
+ }
+ throw new ErrorNotification("Shell execution failed; commands=" + s, e);
}
+ }
+
+ public Object visit(ASTProcess node, Object data) {
+ return null;
}
private Object appendString(final String value, final Object data) {
Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java (original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java Wed Mar 19 06:30:40 2008
@@ -147,7 +147,19 @@
System.setSecurityManager(psm);
}
}
-
+
+ public Object execute(Object[][] commands) throws Exception {
+ SecurityManager psm = System.getSecurityManager();
+ System.setSecurityManager(sm);
+
+ try {
+ return shell.execute(commands);
+ }
+ finally {
+ System.setSecurityManager(psm);
+ }
+ }
+
public void run(final Object... args) throws Exception {
SecurityManager psm = System.getSecurityManager();
System.setSecurityManager(sm);
Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/LoggingVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/LoggingVisitor.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/LoggingVisitor.java (original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/LoggingVisitor.java Wed Mar 19 06:30:40 2008
@@ -26,6 +26,7 @@
import org.apache.geronimo.gshell.parser.ASTQuotedString;
import org.apache.geronimo.gshell.parser.CommandLineParserVisitor;
import org.apache.geronimo.gshell.parser.SimpleNode;
+import org.apache.geronimo.gshell.parser.ASTProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -118,6 +119,10 @@
public Object visit(final ASTExpression node, Object data) {
return log(ASTExpression.class, node, data);
+ }
+
+ public Object visit(ASTProcess node, Object data) {
+ return log(ASTProcess.class, node, data);
}
public Object visit(final ASTQuotedString node, Object data) {
Modified: geronimo/gshell/trunk/gshell-parser/src/main/grammar/CommandLineParser.jjt
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-parser/src/main/grammar/CommandLineParser.jjt?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-parser/src/main/grammar/CommandLineParser.jjt (original)
+++ geronimo/gshell/trunk/gshell-parser/src/main/grammar/CommandLineParser.jjt Wed Mar 19 06:30:40 2008
@@ -104,7 +104,7 @@
<DEFAULT> TOKEN :
{
< STRING:
- ( (~["\"","\\"," ","\t","\n","\r","\f",";","\"","'"])
+ ( (~["\"","\\"," ","\t","\n","\r","\f",";","|","\"","'"])
| ("\\"
( ["n","t","b","r","f","\\","'","\"",";"]
| ["0"-"7"] ( ["0"-"7"] )?
@@ -159,6 +159,11 @@
< SEMICOLON: ";" >
}
+<DEFAULT> TOKEN :
+{
+ < PIPE: "|" >
+}
+
///////////////////////////////////////////////////////////////////////////////
@@ -173,6 +178,13 @@
}
void expression() #Expression: {}
+{
+ (
+ process() ( "|" [ process() ] )*
+ )
+}
+
+void process() #Process: {}
{
( argument() )+
}
Modified: geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java (original)
+++ geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java Wed Mar 19 06:30:40 2008
@@ -84,8 +84,12 @@
// One expression
assertEquals(1, cl.jjtGetNumChildren());
- // 3 plain strings
+ // One process
Node child = cl.jjtGetChild(0);
+ assertEquals(1, child.jjtGetNumChildren());
+
+ // 3 plain strings
+ child = child.jjtGetChild(0);
assertEquals(3, child.jjtGetNumChildren());
for (int i=0; i<3; i++ ) {
@@ -106,8 +110,12 @@
// One expression
assertEquals(1, cl.jjtGetNumChildren());
- // 4 plain strings
+ // One process
Node child = cl.jjtGetChild(0);
+ assertEquals(1, child.jjtGetNumChildren());
+
+ // 4 plain strings
+ child = child.jjtGetChild(0);
assertEquals(4, child.jjtGetNumChildren());
for (int i=0; i<4; i++ ) {
@@ -129,7 +137,11 @@
// One expression
assertEquals(1, cl.jjtGetNumChildren());
+ // One process
Node child = cl.jjtGetChild(0);
+ assertEquals(1, child.jjtGetNumChildren());
+
+ child = child.jjtGetChild(0);
assertEquals(3, child.jjtGetNumChildren());
// Verify 2 plain strings + 1 quoted
@@ -157,7 +169,11 @@
// One expression
assertEquals(1, cl.jjtGetNumChildren());
+ // One process
Node child = cl.jjtGetChild(0);
+ assertEquals(1, child.jjtGetNumChildren());
+
+ child = child.jjtGetChild(0);
assertEquals(3, child.jjtGetNumChildren());
// Verify 2 plain strings + 1 opaque
@@ -184,7 +200,11 @@
// One expression
assertEquals(1, cl.jjtGetNumChildren());
+ // One process
Node child = cl.jjtGetChild(0);
+ assertEquals(1, child.jjtGetNumChildren());
+
+ child = child.jjtGetChild(0);
assertEquals(4, child.jjtGetNumChildren());
Node node;
@@ -215,7 +235,11 @@
// One expression
assertEquals(1, cl.jjtGetNumChildren());
+ // One process
Node child = cl.jjtGetChild(0);
+ assertEquals(1, child.jjtGetNumChildren());
+
+ child = child.jjtGetChild(0);
assertEquals(4, child.jjtGetNumChildren());
Node node;
@@ -300,5 +324,16 @@
//
// TODO: Verify 1 expression
//
+ }
+
+ public void testProcesses1() throws Exception {
+ String input = "a b c | d e f";
+
+ ASTCommandLine cl = parse(input);
+
+ assertEquals(1, cl.jjtGetNumChildren());
+
+ Node child = cl.jjtGetChild(0);
+ assertEquals(2, child.jjtGetNumChildren());
}
}
Modified: geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserVisitorTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserVisitorTest.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserVisitorTest.java (original)
+++ geronimo/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserVisitorTest.java Wed Mar 19 06:30:40 2008
@@ -67,6 +67,7 @@
private SimpleNode simpleNode;
private ASTCommandLine commandLine;
private ASTExpression expression;
+ private ASTProcess process;
private ASTQuotedString quotedString;
private ASTOpaqueString opaqueString;
private ASTPlainString plainString;
@@ -89,6 +90,12 @@
return node.childrenAccept(this, data);
}
+ public Object visit(ASTProcess node, Object data) {
+ this.process = node;
+
+ return node.childrenAccept(this, data);
+ }
+
public Object visit(ASTQuotedString node, Object data) {
this.quotedString = node;
@@ -106,5 +113,6 @@
return node.childrenAccept(this, data);
}
+
}
}
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java Wed Mar 19 06:30:40 2008
@@ -233,6 +233,12 @@
return doExecute(new ExecuteMessage(path, args));
}
+ public Object execute(final Object[][] cmds) throws Exception {
+ assert cmds != null;
+
+ return doExecute(new ExecuteMessage(cmds));
+ }
+
//
// IO Handler
//
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java Wed Mar 19 06:30:40 2008
@@ -151,6 +151,12 @@
return client.execute(path, args);
}
+ public Object execute(Object[][] commands) throws Exception {
+ ensureOpened();
+
+ return client.execute(commands);
+ }
+
//
// Interactive Shell
//
@@ -200,7 +206,7 @@
public String prompt() {
//
- // TODO: Get the real details and ue them...
+ // TODO: Get the real details and use them...
//
String userName = "user"; // shellInfo.getUserName();
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java Wed Mar 19 06:30:40 2008
@@ -35,26 +35,33 @@
private final Object[] args;
- private ExecuteMessage(final Flavor flavor, final String path, final Object[] args) {
+ private final Object[][] cmds;
+
+ private ExecuteMessage(final Flavor flavor, final String path, final Object[] args, final Object[][] cmds) {
this.flavor = flavor;
this.path = path;
this.args = args;
+ this.cmds = cmds;
}
public ExecuteMessage(final String commandLine) {
- this(Flavor.STRING, null, new Object[] { commandLine });
+ this(Flavor.STRING, null, new Object[] { commandLine }, null);
}
public ExecuteMessage(final Object[] args) {
- this(Flavor.OBJECTS, null, args);
+ this(Flavor.OBJECTS, null, args, null);
}
public ExecuteMessage(final String path, final Object[] args) {
- this(Flavor.STRING_OBJECTS, path, args);
+ this(Flavor.STRING_OBJECTS, path, args, null);
+ }
+
+ public ExecuteMessage(final Object[][] cmds) {
+ this(Flavor.COMMANDS, null, null, cmds);
}
public ExecuteMessage() {
- this(null, null, null);
+ this(null, null, null, null);
}
public Object execute(final CommandExecutor executor) throws Exception {
@@ -71,7 +78,8 @@
{
STRING, // execute(String)
OBJECTS, // execute(Object[])
- STRING_OBJECTS // execute(String, Object[])
+ STRING_OBJECTS, // execute(String, Object[])
+ COMMANDS, // execute(Object[][])
;
public Object execute(final ExecuteMessage msg, final CommandExecutor executor) throws Exception {
@@ -87,6 +95,9 @@
case STRING_OBJECTS:
return executor.execute(msg.path, msg.args);
+
+ case COMMANDS:
+ return executor.execute(msg.cmds);
}
// This should never happen
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java?rev=638824&r1=638823&r2=638824&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java Wed Mar 19 06:30:40 2008
@@ -109,6 +109,12 @@
return executor.execute(path, args);
}
+ public Object execute(Object[][] commands) throws Exception {
+ ensureOpened();
+
+ return executor.execute(commands);
+ }
+
//
// TODO: Hookup profile script processing bits
//