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 2008/09/21 12:57:51 UTC
svn commit: r697471 - in /geronimo/gshell/trunk:
gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/
gshell-api/src/main/java/org/apache/geronimo/gshell/shell/
gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/
gshell-commands/gshell...
Author: jdillon
Date: Sun Sep 21 03:57:50 2008
New Revision: 697471
URL: http://svn.apache.org/viewvc?rev=697471&view=rev
Log:
Refactoring to use ShellContext to get handles on the desired IO and Variables
Re-added the Shell.execute() helpers and hide the CommandLineExecutor
Added more Javadocs
Added:
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/ShellContext.java (with props)
Removed:
geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellContextProxy.java
Modified:
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutor.java
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java
geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java
geronimo/gshell/trunk/gshell-parser/src/main/java/org/apache/geronimo/gshell/parser/visitor/ExecutingVisitor.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/RshCommand.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandler.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandlerSupport.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientSessionContext.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/EchoHandler.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/RemoteShellImpl.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/CloseShellHandler.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ConnectHandler.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/EchoHandler.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ExecuteHandler.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/LoginHandler.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandler.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandlerSupport.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java Sun Sep 21 03:57:50 2008
@@ -19,6 +19,8 @@
package org.apache.geronimo.gshell.commandline;
+import org.apache.geronimo.gshell.shell.ShellContext;
+
/**
* A abstraction of an executable command-line.
*
@@ -32,10 +34,11 @@
/**
* Execute the command-line.
*
+ * @param context The executing shell's context.
* @param executor The command-line executor to handle execution of command-line elements.
* @return The final result of the command-line.
*
* @throws Exception Failed to execute command-line.
*/
- Object execute(CommandLineExecutor executor) throws Exception;
+ Object execute(ShellContext context, CommandLineExecutor executor) throws Exception;
}
Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java Sun Sep 21 03:57:50 2008
@@ -19,6 +19,8 @@
package org.apache.geronimo.gshell.commandline;
+import org.apache.geronimo.gshell.shell.ShellContext;
+
/**
* Builds {@link CommandLine} instances ready for executing.
*
@@ -29,8 +31,8 @@
/**
* Build a command-line from the given input string.
*
- * @param input Command-line to parse.
- * @return Parsed command-line.
+ * @param input Command-line to parse.
+ * @return Parsed command-line.
*
* @throws Exception Failed to construct command-line.
*/
Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutor.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutor.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutor.java Sun Sep 21 03:57:50 2008
@@ -19,6 +19,8 @@
package org.apache.geronimo.gshell.commandline;
+import org.apache.geronimo.gshell.shell.ShellContext;
+
/**
* Provides the ability to execute commands.
*
@@ -29,41 +31,45 @@
/**
* Execute a command-line, parsing out valid recognized syntax.
*
- * @param line Raw command-line to parse and execute.
- * @return Command execution result.
+ * @param context The executing shell's context.
+ * @param line Raw command-line to parse and execute.
+ * @return Command execution result.
*
* @throws Exception Command-line execution failed.
*/
- Object execute(String line) throws Exception;
+ Object execute(ShellContext context, String line) throws Exception;
/**
* Execute command name/path with the given arguments.
*
+ * @param context The executing shell's context.
* @param command Name of the command/path to execute.
* @param args Command arguments.
* @return Command execution result.
*
* @throws Exception Command-line execution failed.
*/
- Object execute(String command, final Object[] args) throws Exception;
+ Object execute(ShellContext context, String command, Object[] args) throws Exception;
/**
* Execute a pre-processed command-line.
*
- * @param args Command arguments, first argument is expected to be the command/path to execute.
- * @return Command execution result.
+ * @param context The executing shell's context.
+ * @param args Command arguments, first argument is expected to be the command/path to execute.
+ * @return Command execution result.
*
* @throws Exception Command-line execution failed.
*/
- Object execute(Object... args) throws Exception;
+ Object execute(ShellContext context, Object... args) throws Exception;
/**
* Execute a piped-command-line.
*
+ * @param context The executing shell's context.
* @param commands Command arguments.
* @return Command execution result.
*
* @throws Exception Command-line execution failed.
*/
- Object execute(Object[][] commands) throws Exception;
+ Object execute(ShellContext context, Object[][] commands) throws Exception;
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java Sun Sep 21 03:57:50 2008
@@ -19,10 +19,6 @@
package org.apache.geronimo.gshell.shell;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
-import org.apache.geronimo.gshell.io.IO;
-
/**
* Provides access to execute commands.
*
@@ -30,19 +26,18 @@
*/
public interface Shell
{
- IO getIo();
-
- Variables getVariables();
+ ShellContext getContext();
- /**
- * Get the runtime configuration details of the shell.
- *
- * @return The runtime configuration of the shell.
- */
ShellInfo getInfo();
- CommandLineExecutor getExecutor();
+ Object execute(String line) throws Exception;
+
+ Object execute(String command, Object[] args) throws Exception;
+
+ Object execute(Object... args) throws Exception;
+ Object execute(Object[][] commands) throws Exception;
+
/**
* Check if the shell can be run interactivly.
*
Added: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/ShellContext.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/ShellContext.java?rev=697471&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/ShellContext.java (added)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/ShellContext.java Sun Sep 21 03:57:50 2008
@@ -0,0 +1,35 @@
+/*
+ * 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.geronimo.gshell.shell;
+
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.command.Variables;
+
+/**
+ * Provides the execution context of a shell.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ShellContext
+{
+ IO getIo();
+
+ Variables getVariables();
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/ShellContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/ShellContext.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/shell/ShellContext.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java (original)
+++ geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java Sun Sep 21 03:57:50 2008
@@ -239,13 +239,13 @@
}
if (commands != null) {
- gshell.getExecutor().execute(commands);
+ gshell.execute(commands);
}
else if (interactive) {
gshell.run(_args);
}
else {
- gshell.getExecutor().execute(_args);
+ gshell.execute(_args);
}
}
catch (ExitNotification n) {
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java Sun Sep 21 03:57:50 2008
@@ -22,7 +22,10 @@
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.command.CommandAction;
import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.command.Variables;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
+import org.apache.geronimo.gshell.shell.ShellContext;
+import org.apache.geronimo.gshell.io.IO;
import org.codehaus.plexus.util.IOUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,8 +77,18 @@
if (tmp.length() == 0 || tmp.startsWith("#")) {
continue;
}
-
- executor.execute(line);
+
+ ShellContext ctx = new ShellContext() {
+ public IO getIo() {
+ return context.getIo();
+ }
+
+ public Variables getVariables() {
+ return context.getVariables();
+ }
+ };
+
+ executor.execute(ctx, line);
}
}
finally {
Modified: geronimo/gshell/trunk/gshell-parser/src/main/java/org/apache/geronimo/gshell/parser/visitor/ExecutingVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-parser/src/main/java/org/apache/geronimo/gshell/parser/visitor/ExecutingVisitor.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-parser/src/main/java/org/apache/geronimo/gshell/parser/visitor/ExecutingVisitor.java (original)
+++ geronimo/gshell/trunk/gshell-parser/src/main/java/org/apache/geronimo/gshell/parser/visitor/ExecutingVisitor.java Sun Sep 21 03:57:50 2008
@@ -30,8 +30,8 @@
import org.apache.geronimo.gshell.parser.CommandLineParserVisitor;
import org.apache.geronimo.gshell.parser.SimpleNode;
import org.apache.geronimo.gshell.command.Arguments;
-import org.apache.geronimo.gshell.command.Variables;
import org.apache.geronimo.gshell.interpolation.VariableInterpolator;
+import org.apache.geronimo.gshell.shell.ShellContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,18 +48,18 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- private final Variables variables;
+ private final ShellContext context;
private final CommandLineExecutor executor;
private final VariableInterpolator interp = new VariableInterpolator();
- public ExecutingVisitor(final CommandLineExecutor executor, final Variables variables) {
+ public ExecutingVisitor(final ShellContext context, final CommandLineExecutor executor) {
+ assert context != null;
assert executor != null;
- assert variables != null;
+ this.context = context;
this.executor = executor;
- this.variables = variables;
}
public Object visit(final SimpleNode node, final Object data) {
@@ -82,7 +82,12 @@
public Object visit(final ASTExpression node, final Object data) {
assert node != null;
+ //
+ // FIXME: Really shouldn't use Object[][] execute for everything, as it costs some thread creation
+ //
+
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());
@@ -90,14 +95,17 @@
commands[i] = list.toArray(new Object[list.size()]);
assert list.size() >= 1;
}
+
try {
- return executor.execute(commands);
+ return executor.execute(context, commands);
}
catch (Exception 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);
}
}
@@ -120,7 +128,7 @@
public Object visit(final ASTQuotedString node, final Object data) {
assert node != null;
- String value = interp.interpolate(node.getValue(), variables);
+ String value = interp.interpolate(node.getValue(), context.getVariables());
return appendString(value, data);
}
@@ -128,7 +136,7 @@
public Object visit(final ASTPlainString node, final Object data) {
assert node != null;
- String value = interp.interpolate(node.getValue(), variables);
+ String value = interp.interpolate(node.getValue(), context.getVariables());
return appendString(value, 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=697471&r1=697470&r2=697471&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 Sun Sep 21 03:57:50 2008
@@ -187,16 +187,17 @@
ExecuteMessage.Result result = (ExecuteMessage.Result) session.request(msg);
// Handle result notifications
- if (result instanceof ExecuteMessage.Notification) {
- ExecuteMessage.Notification n = (ExecuteMessage.Notification)result;
+ if (result instanceof ExecuteMessage.NotificationResult) {
+ ExecuteMessage.NotificationResult n = (ExecuteMessage.NotificationResult)result;
throw n.getNotification();
}
// Handle result faults
- if (result instanceof ExecuteMessage.Fault) {
- ExecuteMessage.Fault fault = (ExecuteMessage.Fault)result;
+ if (result instanceof ExecuteMessage.FaultResult) {
+ ExecuteMessage.FaultResult fault = (ExecuteMessage.FaultResult)result;
+ //noinspection ThrowableResultOfMethodCallIgnored
throw new RemoteExecuteException(fault.getCause());
}
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java Sun Sep 21 03:57:50 2008
@@ -103,14 +103,14 @@
RemoteShellProxy shell = new RemoteShellProxy(client, io);
- Object rv = Result.SUCCESS;
+ Object result = Result.SUCCESS;
try {
shell.run(command.toArray());
}
catch (ExitNotification n) {
// Make sure that we catch this notification, so that our parent shell doesn't exit when the remote shell does
- rv = n.code;
+ result = n.code;
}
shell.close();
@@ -121,6 +121,6 @@
io.verbose("Disconnected");
- return rv;
+ return result;
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandler.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandler.java Sun Sep 21 03:57:50 2008
@@ -24,7 +24,7 @@
import org.apache.geronimo.gshell.whisper.transport.Session;
/**
- * ???
+ * Support for typed client message handlers.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandlerSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandlerSupport.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandlerSupport.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientMessageHandlerSupport.java Sun Sep 21 03:57:50 2008
@@ -25,7 +25,7 @@
import org.apache.mina.common.IoSession;
/**
- * ???
+ * Support for {@link ClientMessageHandler} implementations.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientSessionContext.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientSessionContext.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientSessionContext.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/ClientSessionContext.java Sun Sep 21 03:57:50 2008
@@ -27,7 +27,7 @@
import org.apache.geronimo.gshell.whisper.util.SessionAttributeBinder;
/**
- * ???
+ * Container for client-side session state.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/EchoHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/EchoHandler.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/EchoHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/handler/EchoHandler.java Sun Sep 21 03:57:50 2008
@@ -23,7 +23,7 @@
import org.apache.geronimo.gshell.whisper.transport.Session;
/**
- * ???
+ * Client handler for {@link EchoMessage} messages.
*
* @version $Rev$ $Date$
*/
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=697471&r1=697470&r2=697471&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 Sun Sep 21 03:57:50 2008
@@ -20,16 +20,16 @@
package org.apache.geronimo.gshell.remote.client.proxy;
import org.apache.geronimo.gshell.ansi.Renderer;
-import org.apache.geronimo.gshell.command.Variables;
import org.apache.geronimo.gshell.console.Console;
import org.apache.geronimo.gshell.console.JLineConsole;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.notification.ExitNotification;
import org.apache.geronimo.gshell.remote.RemoteShell;
import org.apache.geronimo.gshell.remote.client.RshClient;
+import org.apache.geronimo.gshell.shell.ShellContext;
import org.apache.geronimo.gshell.shell.ShellInfo;
import org.apache.geronimo.gshell.whisper.stream.StreamFeeder;
-import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
+import org.apache.geronimo.gshell.command.Variables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,13 +47,11 @@
private final RshClient client;
- private final CommandLineExecutor executor;
-
private final IO io;
private final StreamFeeder outputFeeder;
- private final RemoteShellContextProxy context;
+ private final ShellContext context;
private final RemoteShellInfoProxy shellInfo;
@@ -66,24 +64,6 @@
assert io != null;
this.client = client;
- this.executor = new CommandLineExecutor() {
- public Object execute(String line) throws Exception {
- return client.execute(line);
- }
-
- public Object execute(String command, Object[] args) throws Exception {
- return client.execute(command, args);
- }
-
- public Object execute(Object... args) throws Exception {
- return client.execute(args);
- }
-
- public Object execute(Object[][] commands) throws Exception {
- return client.execute(commands);
- }
- };
-
this.io = io;
//
@@ -94,7 +74,6 @@
client.openShell();
// Setup other proxies
- context = new RemoteShellContextProxy(client);
shellInfo = new RemoteShellInfoProxy(client);
history = new RemoteHistoryProxy(client);
@@ -102,31 +81,17 @@
outputFeeder = new StreamFeeder(client.getInputStream(), io.outputStream);
outputFeeder.createThread().start();
- opened = true;
- }
-
- public IO getIo() {
- return io;
- }
-
- public CommandLineExecutor getExecutor() {
- return executor;
- }
-
- public boolean isInteractive() {
- return true;
- }
-
- public Variables getVariables() {
- ensureOpened();
-
- return context.getVariables();
- }
+ context = new ShellContext() {
+ public IO getIo() {
+ return io;
+ }
- public ShellInfo getInfo() {
- ensureOpened();
+ public Variables getVariables() {
+ throw new UnsupportedOperationException();
+ }
+ };
- return shellInfo;
+ opened = true;
}
private void ensureOpened() {
@@ -149,13 +114,49 @@
outputFeeder.close();
}
catch (Exception ignore) {}
-
+
opened = false;
}
- //
- // Interactive Shell
- //
+ public ShellContext getContext() {
+ ensureOpened();
+
+ return context;
+ }
+
+ public ShellInfo getInfo() {
+ ensureOpened();
+
+ return shellInfo;
+ }
+
+ public Object execute(final String line) throws Exception {
+ ensureOpened();
+
+ return client.execute(line);
+ }
+
+ public Object execute(final String command, final Object[] args) throws Exception {
+ ensureOpened();
+
+ return client.execute(command, args);
+ }
+
+ public Object execute(final Object... args) throws Exception {
+ ensureOpened();
+
+ return client.execute(args);
+ }
+
+ public Object execute(final Object[][] commands) throws Exception {
+ ensureOpened();
+
+ return client.execute(commands);
+ }
+
+ public boolean isInteractive() {
+ return true;
+ }
public void run(final Object... args) throws Exception {
assert args != null;
@@ -181,7 +182,7 @@
assert line != null;
try {
- Object result = getExecutor().execute(line);
+ Object result = RemoteShellProxy.this.execute(line);
lastResultHolder.set(result);
}
@@ -245,7 +246,7 @@
// Check if there are args, and run them and then enter interactive
if (args.length != 0) {
- getExecutor().execute(args);
+ execute(args);
}
// And then spin up the console and go for a jog
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=697471&r1=697470&r2=697471&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 Sun Sep 21 03:57:50 2008
@@ -20,6 +20,8 @@
package org.apache.geronimo.gshell.remote.message;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
+import org.apache.geronimo.gshell.shell.Shell;
+import org.apache.geronimo.gshell.notification.Notification;
/**
* Client to server message to execute a command. This supports all flavors of the {@link CommandLineExecutor} execution methods.
@@ -64,14 +66,14 @@
this(null, null, null, null);
}
- public Object execute(final CommandLineExecutor executor) throws Exception {
- assert executor != null;
+ public Object execute(final Shell shell) throws Exception {
+ assert shell != null;
- return flavor.execute(this, executor);
+ return flavor.execute(this, shell);
}
/**
- * Enumeration of the flavors of execution supported by the {@link CommandLineExecutor}.
+ * Enumeration of the flavors of execution supported by a {@link Shell}.
*/
private static enum Flavor
{
@@ -81,22 +83,22 @@
COMMANDS, // execute(Object[][])
;
- public Object execute(final ExecuteMessage msg, final CommandLineExecutor executor) throws Exception {
+ public Object execute(final ExecuteMessage msg, final Shell shell) throws Exception {
assert msg != null;
- assert executor != null;
+ assert shell != null;
switch (this) {
case STRING:
- return executor.execute((String)msg.args[0]);
+ return shell.execute((String)msg.args[0]);
case OBJECTS:
- return executor.execute(msg.args);
+ return shell.execute(msg.args);
case STRING_OBJECTS:
- return executor.execute(msg.path, msg.args);
+ return shell.execute(msg.path, msg.args);
case COMMANDS:
- return executor.execute(msg.cmds);
+ return shell.execute(msg.cmds);
}
// This should never happen
@@ -124,30 +126,30 @@
/**
* Server to client message to pase a failure.
*/
- public static class Fault
+ public static class FaultResult
extends Result
{
- public Fault(final Throwable cause) {
+ public FaultResult(final Throwable cause) {
super(cause);
}
public Throwable getCause() {
- return (Throwable) getResult();
+ return (Throwable)getResult();
}
}
/**
* Serverto client message to pass a notification.
*/
- public static class Notification
+ public static class NotificationResult
extends Result
{
- public Notification(final org.apache.geronimo.gshell.notification.Notification n) {
+ public NotificationResult(final Notification n) {
super(n);
}
- public org.apache.geronimo.gshell.notification.Notification getNotification() {
- return (org.apache.geronimo.gshell.notification.Notification) getResult();
+ public Notification getNotification() {
+ return (Notification)getResult();
}
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellImpl.java Sun Sep 21 03:57:50 2008
@@ -19,11 +19,10 @@
package org.apache.geronimo.gshell.remote.server;
-import org.apache.geronimo.gshell.command.Variables;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
import org.apache.geronimo.gshell.remote.RemoteShell;
+import org.apache.geronimo.gshell.shell.ShellContext;
import org.apache.geronimo.gshell.shell.ShellInfo;
-import org.apache.geronimo.gshell.io.IO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -64,14 +63,12 @@
opened = false;
}
- public boolean isInteractive() {
- return false;
- }
-
- public Variables getVariables() {
+ public ShellContext getContext() {
ensureOpened();
- throw new UnsupportedOperationException();
+ // FIXME:
+
+ return null;
}
public ShellInfo getInfo() {
@@ -80,21 +77,43 @@
return shellInfo;
}
- public IO getIo() {
+ public Object execute(final String line) throws Exception {
ensureOpened();
- throw new UnsupportedOperationException();
+ // FIXME:
+
+ return null;
}
- public CommandLineExecutor getExecutor() {
+ public Object execute(final String command, final Object[] args) throws Exception {
ensureOpened();
- return executor;
+ // FIXME:
+
+ return null;
}
- public void run(final Object... args) throws Exception {
+ public Object execute(final Object... args) throws Exception {
ensureOpened();
-
+
+ // FIXME:
+
+ return null;
+ }
+
+ public Object execute(final Object[][] commands) throws Exception {
+ ensureOpened();
+
+ // FIXME:
+
+ return null;
+ }
+
+ public boolean isInteractive() {
+ return false;
+ }
+
+ public void run(final Object... args) throws Exception {
throw new UnsupportedOperationException();
}
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/CloseShellHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/CloseShellHandler.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/CloseShellHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/CloseShellHandler.java Sun Sep 21 03:57:50 2008
@@ -24,7 +24,7 @@
import org.apache.geronimo.gshell.whisper.transport.Session;
/**
- * ???
+ * Server handler for {@link CloseShellMessage} messages.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ConnectHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ConnectHandler.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ConnectHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ConnectHandler.java Sun Sep 21 03:57:50 2008
@@ -27,7 +27,7 @@
import org.springframework.beans.factory.annotation.Autowired;
/**
- * ???
+ * Server handler for {@link ConnectMessage} messages.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/EchoHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/EchoHandler.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/EchoHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/EchoHandler.java Sun Sep 21 03:57:50 2008
@@ -23,7 +23,7 @@
import org.apache.geronimo.gshell.whisper.transport.Session;
/**
- * ???
+ * Server handler for {@link EchoMessage} messages.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ExecuteHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ExecuteHandler.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ExecuteHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ExecuteHandler.java Sun Sep 21 03:57:50 2008
@@ -24,7 +24,7 @@
import org.apache.geronimo.gshell.whisper.transport.Session;
/**
- * ???
+ * Server handler for {@link ExecuteMessage} messages.
*
* @version $Rev$ $Date$
*/
@@ -40,16 +40,10 @@
assert context != null;
assert message != null;
- // Need to make sure that the execuing thread has the right I/O and environment in context
- // FIXME: Need to find out what to do here, w/o this lookup
- // IOLookup.set(context.container, context.io);
- // FIXME: Need to find out what to do here, w/o this lookup
- // EnvironmentLookup.set(context.container, context.env);
-
ExecuteMessage.Result reply;
try {
- Object result = message.execute(context.shell.getExecutor());
+ Object result = message.execute(context.shell);
log.debug("Result: {}", result);
@@ -58,12 +52,12 @@
catch (Notification n) {
log.debug("Notification: " + n);
- reply = new ExecuteMessage.Notification(n);
+ reply = new ExecuteMessage.NotificationResult(n);
}
catch (Throwable t) {
log.debug("Fault: " + t);
- reply = new ExecuteMessage.Fault(t);
+ reply = new ExecuteMessage.FaultResult(t);
}
reply.setCorrelationId(message.getId());
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/LoginHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/LoginHandler.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/LoginHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/LoginHandler.java Sun Sep 21 03:57:50 2008
@@ -33,7 +33,7 @@
import org.springframework.beans.factory.annotation.Autowired;
/**
- * ???
+ * Server handler for {@link LoginMessage} messages.
*
* @version $Rev$ $Date$
*/
@@ -49,6 +49,16 @@
super(LoginMessage.class);
}
+ public String getDefaultRealm() {
+ return defaultRealm;
+ }
+
+ public void setDefaultRealm(final String defaultRealm) {
+ assert defaultRealm != null;
+
+ this.defaultRealm = defaultRealm;
+ }
+
@PostConstruct
public void init() {
new JaasConfigurationHelper("server.login.conf").init();
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java Sun Sep 21 03:57:50 2008
@@ -30,7 +30,7 @@
import java.util.UUID;
/**
- * ???
+ * Server handler for {@link OpenShellMessage} messages.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandler.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandler.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandler.java Sun Sep 21 03:57:50 2008
@@ -24,7 +24,7 @@
import org.apache.geronimo.gshell.whisper.transport.Session;
/**
- * ???
+ * Support for typed server message handlers.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandlerSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandlerSupport.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandlerSupport.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerMessageHandlerSupport.java Sun Sep 21 03:57:50 2008
@@ -25,7 +25,7 @@
import org.apache.mina.common.IoSession;
/**
- * ???
+ * Support for {@link ServerMessageHandler} implementations.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ServerSessionContext.java Sun Sep 21 03:57:50 2008
@@ -31,7 +31,7 @@
import org.apache.geronimo.gshell.spring.BeanContainer;
/**
- * ???
+ * Container for server-side session state.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml Sun Sep 21 03:57:50 2008
@@ -57,16 +57,18 @@
</property>
</bean>
- <bean class="org.apache.geronimo.gshell.remote.server.timeout.TimeoutManagerImpl"/>
+ <bean id="timeoutManager" class="org.apache.geronimo.gshell.remote.server.timeout.TimeoutManagerImpl"/>
- <bean class="org.apache.geronimo.gshell.remote.server.RshServer" scope="prototype">
+ <bean id="rshServer" class="org.apache.geronimo.gshell.remote.server.RshServer" scope="prototype">
<constructor-arg>
<list>
<bean class="org.apache.geronimo.gshell.remote.server.handler.CloseShellHandler"/>
<bean class="org.apache.geronimo.gshell.remote.server.handler.ConnectHandler"/>
<bean class="org.apache.geronimo.gshell.remote.server.handler.EchoHandler"/>
<bean class="org.apache.geronimo.gshell.remote.server.handler.ExecuteHandler"/>
- <bean class="org.apache.geronimo.gshell.remote.server.handler.LoginHandler"/>
+ <bean class="org.apache.geronimo.gshell.remote.server.handler.LoginHandler">
+ <property name="defaultRealm" value="BogusLogin"/>
+ </bean>
<bean class="org.apache.geronimo.gshell.remote.server.handler.OpenShellHandler"/>
</list>
</constructor-arg>
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java Sun Sep 21 03:57:50 2008
@@ -19,8 +19,6 @@
package org.apache.geronimo.gshell.wisdom.shell;
-import org.apache.geronimo.gshell.application.ApplicationManager;
-import org.apache.geronimo.gshell.command.Variables;
import org.apache.geronimo.gshell.commandline.CommandLine;
import org.apache.geronimo.gshell.commandline.CommandLineBuilder;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
@@ -30,6 +28,7 @@
import org.apache.geronimo.gshell.parser.ParseException;
import org.apache.geronimo.gshell.parser.visitor.ExecutingVisitor;
import org.apache.geronimo.gshell.parser.visitor.LoggingVisitor;
+import org.apache.geronimo.gshell.shell.ShellContext;
import org.codehaus.plexus.util.IOUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,9 +48,6 @@
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
- private ApplicationManager applicationManager;
-
- @Autowired
private CommandLineParser parser;
public CommandLineBuilderImpl() {}
@@ -77,27 +73,24 @@
return cl;
}
- protected Variables getVariables() {
- assert applicationManager != null;
- return applicationManager.getApplication().getVariables();
- }
+ public CommandLine create(final String line) throws ParseException {
+ assert line != null;
- public CommandLine create(final String commandLine) throws ParseException {
- assert commandLine != null;
+ log.debug("Building command-line for: {}", line);
- if (commandLine.trim().length() == 0) {
+ if (line.trim().length() == 0) {
throw new IllegalArgumentException("Command line is empty");
}
try {
- final Variables vars = getVariables();
- final ASTCommandLine root = parse(commandLine);
+ final ASTCommandLine root = parse(line);
return new CommandLine() {
- public Object execute(final CommandLineExecutor executor) throws Exception {
+ public Object execute(final ShellContext context, final CommandLineExecutor executor) throws Exception {
+ assert context != null;
assert executor != null;
- ExecutingVisitor visitor = new ExecutingVisitor(executor, vars);
+ ExecutingVisitor visitor = new ExecutingVisitor(context, executor);
return root.jjtAccept(visitor, null);
}
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java Sun Sep 21 03:57:50 2008
@@ -19,7 +19,6 @@
package org.apache.geronimo.gshell.wisdom.shell;
-import org.apache.geronimo.gshell.application.ApplicationManager;
import org.apache.geronimo.gshell.chronos.StopWatch;
import org.apache.geronimo.gshell.command.Arguments;
import org.apache.geronimo.gshell.command.Command;
@@ -35,6 +34,7 @@
import org.apache.geronimo.gshell.io.SystemOutputHijacker;
import org.apache.geronimo.gshell.notification.ErrorNotification;
import org.apache.geronimo.gshell.notification.Notification;
+import org.apache.geronimo.gshell.shell.ShellContext;
import org.codehaus.plexus.util.IOUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,15 +60,13 @@
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
- private ApplicationManager applicationManager;
-
- @Autowired
private CommandResolver commandResolver;
@Autowired
private CommandLineBuilder commandLineBuilder;
- public Object execute(final String line) throws Exception {
+ public Object execute(final ShellContext context, final String line) throws Exception {
+ assert context != null;
assert line != null;
log.info("Executing (String): {}", line);
@@ -76,7 +74,9 @@
try {
CommandLine commandLine = commandLineBuilder.create(line);
- return commandLine.execute(this);
+ log.trace("Command-line: {}", commandLine);
+
+ return commandLine.execute(context, this);
}
catch (ErrorNotification n) {
// Decode the error notifiation
@@ -95,42 +95,37 @@
}
}
- protected IO getIo() {
- assert applicationManager != null;
- return applicationManager.getApplication().getIo();
- }
-
- protected Variables getVariables() {
- assert applicationManager != null;
- return applicationManager.getApplication().getVariables();
- }
-
- public Object execute(final Object... args) throws Exception {
+ public Object execute(final ShellContext context, final Object... args) throws Exception {
+ assert context != null;
assert args != null;
assert args.length > 1;
log.info("Executing (Object...): [{}]", Arguments.asString(args));
- return execute(String.valueOf(args[0]), Arguments.shift(args), getIo());
+ return doExecute(context, String.valueOf(args[0]), Arguments.shift(args));
}
- public Object execute(final String path, final Object[] args) throws Exception {
+ public Object execute(final ShellContext context, final String path, final Object[] args) throws Exception {
+ assert context != null;
assert path != null;
assert args != null;
log.info("Executing ({}): [{}]", path, Arguments.asString(args));
- return execute(path, args, getIo());
+ return doExecute(context, path, args);
}
- public Object execute(final Object[][] commands) throws Exception {
+ public Object execute(final ShellContext context, final Object[][] commands) throws Exception {
+ assert context != null;
assert commands != null;
+ log.info("Executing (Object[][]): {}", Arguments.asString(commands));
+
// Prepare IOs
final IO[] ios = new IO[commands.length];
PipedOutputStream pos = null;
- IO io = getIo();
+ IO io = context.getIo();
for (int i = 0; i < ios.length; i++) {
InputStream is = (i == 0) ? io.inputStream : new PipedInputStream(pos);
@@ -156,10 +151,20 @@
threads[i] = createThread(new Runnable() {
public void run() {
try {
- Object o = execute(String.valueOf(commands[idx][0]), Arguments.shift(commands[idx]), ios[idx]);
+ ShellContext pipedContext = new ShellContext() {
+ public IO getIo() {
+ return ios[idx];
+ }
+
+ public Variables getVariables() {
+ return context.getVariables();
+ }
+ };
+
+ Object obj = execute(pipedContext, String.valueOf(commands[idx][0]), Arguments.shift(commands[idx]));
if (idx == commands.length - 1) {
- ref.set(o);
+ ref.set(obj);
}
}
catch (Throwable t) {
@@ -202,10 +207,13 @@
return new Thread(task);
}
- protected Object execute(final String path, final Object[] args, final IO io) throws Exception {
+ protected Object doExecute(final ShellContext context, final String path, final Object[] args) throws Exception {
+ assert context != null;
+
log.debug("Executing");
- Variables variables = getVariables();
+ IO io = context.getIo();
+ Variables variables = context.getVariables();
Command command = commandResolver.resolve(variables, path);
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java?rev=697471&r1=697470&r2=697471&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java Sun Sep 21 03:57:50 2008
@@ -21,23 +21,24 @@
import jline.History;
import org.apache.geronimo.gshell.ansi.Renderer;
-import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.application.Application;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
import org.apache.geronimo.gshell.console.Console;
import org.apache.geronimo.gshell.console.Console.ErrorHandler;
import org.apache.geronimo.gshell.console.Console.Prompter;
import org.apache.geronimo.gshell.console.JLineConsole;
-import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.event.Event;
+import org.apache.geronimo.gshell.event.EventListener;
+import org.apache.geronimo.gshell.event.EventManager;
import org.apache.geronimo.gshell.model.application.Branding;
import org.apache.geronimo.gshell.notification.ErrorNotification;
import org.apache.geronimo.gshell.notification.ExitNotification;
import org.apache.geronimo.gshell.shell.Shell;
import org.apache.geronimo.gshell.shell.ShellInfo;
-import org.apache.geronimo.gshell.event.EventManager;
-import org.apache.geronimo.gshell.event.EventListener;
-import org.apache.geronimo.gshell.event.Event;
+import org.apache.geronimo.gshell.shell.ShellContext;
import org.apache.geronimo.gshell.wisdom.application.ApplicationConfiguredEvent;
-import org.apache.geronimo.gshell.application.Application;
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.command.Variables;
import org.codehaus.plexus.util.IOUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,9 +72,7 @@
@Autowired
private History history;
- private Variables variables;
-
- private IO io;
+ private ShellContext context;
private Branding branding;
@@ -81,16 +80,11 @@
private ErrorHandler errorHandler;
- public IO getIo() {
- return io;
- }
-
- public Variables getVariables() {
- return variables;
- }
-
- public CommandLineExecutor getExecutor() {
- return executor;
+ public ShellContext getContext() {
+ if (context == null) {
+ throw new IllegalStateException("Shell context has not been initialized");
+ }
+ return context;
}
public ShellInfo getInfo() {
@@ -114,9 +108,17 @@
log.debug("Binding application io/variables/branding from context");
// Dereference some bits from the applciation context
- Application application = targetEvent.getApplication();
- io = application.getIo();
- variables = application.getVariables();
+ final Application application = targetEvent.getApplication();
+ context = new ShellContext() {
+ public IO getIo() {
+ return application.getIo();
+ }
+
+ public Variables getVariables() {
+ return application.getVariables();
+ }
+ };
+
branding = application.getModel().getBranding();
loadProfileScripts();
@@ -124,10 +126,26 @@
}
});
}
-
- //
- // Interactive Shell
- //
+
+ public Object execute(final String line) throws Exception {
+ assert executor != null;
+ return executor.execute(getContext(), line);
+ }
+
+ public Object execute(final String command, final Object[] args) throws Exception {
+ assert executor != null;
+ return executor.execute(getContext(), command, args);
+ }
+
+ public Object execute(final Object... args) throws Exception {
+ assert executor != null;
+ return executor.execute(getContext(), args);
+ }
+
+ public Object execute(final Object[][] commands) throws Exception {
+ assert executor != null;
+ return executor.execute(getContext(), commands);
+ }
public void run(final Object... args) throws Exception {
assert args != null;
@@ -147,7 +165,7 @@
assert line != null;
try {
- Object result = getExecutor().execute(line);
+ Object result = ShellImpl.this.execute(line);
lastResultHolder.set(result);
}
@@ -161,6 +179,8 @@
}
};
+ IO io = getContext().getIo();
+
// Ya, bust out the sexy JLine console baby!
JLineConsole console = new JLineConsole(executor, io);
@@ -187,7 +207,7 @@
// Check if there are args, and run them and then enter interactive
if (args.length != 0) {
- getExecutor().execute(args);
+ execute(args);
}
// And then spin up the console and go for a jog
@@ -272,6 +292,8 @@
cause = error.getCause();
}
+ IO io = getContext().getIo();
+
// Spit out the terse reason why we've failed
io.err.print("@|bold,red ERROR| ");
io.err.print(cause.getClass().getSimpleName());
@@ -340,7 +362,7 @@
String line;
while ((line = reader.readLine()) != null) {
- getExecutor().execute(line);
+ execute(line);
}
}
finally {