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 2007/09/19 01:05:48 UTC
svn commit: r577100 - in /geronimo/sandbox/gshell/trunk/gshell-remote:
gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/
gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/
gshell-remote-common/src/main/java...
Author: jdillon
Date: Tue Sep 18 16:05:47 2007
New Revision: 577100
URL: http://svn.apache.org/viewvc?rev=577100&view=rev
Log:
Adding RemoteShell interface, renamed RemoteShell class to DefaultRemoteShell
Moved stream handling to ProtocolHandler
Changed SessionInputStream.write() to take a WriteStreamMessage
Dropped the stream name muck for now (maybe bring it back after its all working)
Dropped MessageVisitorAdapter just use MessageVisitorSupport
Added:
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RemoteShell.java
- copied, changed from r577083, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RemoteShellProxy.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java (contents, props changed)
- copied, changed from r577083, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShell.java
Removed:
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorAdapter.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShell.java
Modified:
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RemoteShellProxy.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageCodecFactory.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorSupport.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/WriteStreamMessage.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RemoteShellProxy.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RemoteShellProxy.java?rev=577100&r1=577099&r2=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RemoteShellProxy.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RemoteShellProxy.java Tue Sep 18 16:05:47 2007
@@ -27,6 +27,7 @@
import org.apache.geronimo.gshell.command.IO;
import org.apache.geronimo.gshell.console.Console;
import org.apache.geronimo.gshell.console.JLineConsole;
+import org.apache.geronimo.gshell.remote.RemoteShell;
import org.apache.geronimo.gshell.remote.stream.StreamFeeder;
import org.apache.geronimo.gshell.shell.Environment;
import org.apache.geronimo.gshell.shell.InteractiveShell;
@@ -40,7 +41,7 @@
* @version $Rev$ $Date$
*/
public class RemoteShellProxy
- implements InteractiveShell
+ implements RemoteShell, InteractiveShell
{
private Logger log = LoggerFactory.getLogger(getClass());
@@ -79,7 +80,7 @@
public Environment getEnvironment() {
ensureOpened();
-
+
throw new Error("TODO");
}
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RemoteShell.java (from r577083, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RemoteShellProxy.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RemoteShell.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RemoteShell.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RemoteShellProxy.java&r1=577083&r2=577100&rev=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RemoteShellProxy.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RemoteShell.java Tue Sep 18 16:05:47 2007
@@ -17,230 +17,19 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.client;
+package org.apache.geronimo.gshell.remote;
-import java.util.concurrent.atomic.AtomicReference;
-
-import jline.Terminal;
-import org.apache.geronimo.gshell.ExitNotification;
-import org.apache.geronimo.gshell.ansi.Renderer;
-import org.apache.geronimo.gshell.command.IO;
-import org.apache.geronimo.gshell.console.Console;
-import org.apache.geronimo.gshell.console.JLineConsole;
-import org.apache.geronimo.gshell.remote.stream.StreamFeeder;
-import org.apache.geronimo.gshell.shell.Environment;
-import org.apache.geronimo.gshell.shell.InteractiveShell;
-import org.apache.geronimo.gshell.shell.ShellInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.geronimo.gshell.shell.Shell;
/**
- * Provides a shell interface which will proxy to a remote shell instance.
+ * Common interface for remote shell support.
*
* @version $Rev$ $Date$
*/
-public class RemoteShellProxy
- implements InteractiveShell
+public interface RemoteShell
+ extends Shell
{
- private Logger log = LoggerFactory.getLogger(getClass());
-
- private RshClient client;
-
- private IO io;
-
- private Terminal terminal;
-
- private StreamFeeder outputFeeder;
-
- private boolean opened;
-
- public RemoteShellProxy(final RshClient client, final IO io, final Terminal terminal) throws Exception {
- assert client != null;
- assert io != null;
- assert terminal != null;
-
- this.client = client;
- this.io = io;
- this.terminal = terminal;
-
- //
- // TODO: send over some client-side details, like the terminal features, etc, as well, verbosity too)
- // If any problem or denial occurs, throw an exception, once created the proxy is considered valid.
- //
-
- client.openShell();
-
- // Copy the client's input stream to our outputstream so users see command output
- outputFeeder = new StreamFeeder(client.getInputStream(), io.outputStream);
- outputFeeder.createThread().start();
-
- this.opened = true;
- }
-
- public Environment getEnvironment() {
- ensureOpened();
-
- throw new Error("TODO");
- }
-
- public ShellInfo getShellInfo() {
- ensureOpened();
-
- throw new Error("TODO");
- }
-
- private void ensureOpened() {
- if (!opened) {
- throw new IllegalStateException("Remote shell proxy has been closed");
- }
- }
-
- public boolean isOpened() {
- return opened;
- }
-
- public void close() {
- try {
- outputFeeder.close();
-
- client.closeShell();
- }
- catch (Exception e) {
- log.error("Failure occured while closing remote shell; ignoring", e);
- }
-
- opened = false;
-
- log.info("Closed");
- }
-
- //
- // Command Execution
- //
-
- public Object execute(final String line) throws Exception {
- ensureOpened();
-
- return client.execute(line);
- }
-
- public Object execute(final Object... args) throws Exception {
- ensureOpened();
-
- return client.execute((Object[])args);
- }
-
- public Object execute(final String path, final Object[] args) throws Exception {
- ensureOpened();
-
- return client.execute(path, args);
- }
-
- //
- // Interactive Shell
- //
-
- public void run(final Object... args) throws Exception {
- assert args != null;
-
- ensureOpened();
-
- log.debug("Starting interactive console; args: {}", args);
-
- //
- // FIXME: We need a hook into the session state here so that we can abort the console muck when the session closes
- //
-
- //
- // TODO: Request server to load...
- //
- // loadUserScript(branding.getInteractiveScriptName());
-
- final AtomicReference<ExitNotification> exitNotifHolder = new AtomicReference<ExitNotification>();
- final AtomicReference<Object> lastResultHolder = new AtomicReference<Object>();
-
- Console.Executor executor = new Console.Executor() {
- public Result execute(final String line) throws Exception {
- assert line != null;
-
- try {
- Object result = RemoteShellProxy.this.execute(line);
-
- lastResultHolder.set(result);
- }
- catch (ExitNotification n) {
- exitNotifHolder.set(n);
-
- return Result.STOP;
- }
-
- return Result.CONTINUE;
- }
- };
-
- JLineConsole console = new JLineConsole(executor, io, terminal);
-
- console.setPrompter(new Console.Prompter() {
- Renderer renderer = new Renderer();
-
- public String prompt() {
- //
- // FIXME:
- //
-
- String userName = "user"; // shellInfo.getUserName();
- String hostName = "remote"; // shellInfo.getLocalHost().getHostName();
- String path = "/";
-
- return renderer.render("@|bold " + userName + "|@" + hostName + ":@|bold " + path + "|> ");
- }
- });
-
- console.setErrorHandler(new Console.ErrorHandler() {
- public Result handleError(final Throwable error) {
- assert error != null;
-
- //
- // FIXME:
- //
-
- log.error("FIXME: " + error, error);
-
-
- return Result.CONTINUE;
- }
- });
-
- //
- // TODO: What are we to do with history here? Really should be history on the server...
- //
-
- /*
- // 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();
- console.setHistory(history);
- console.setHistoryFile(new File(branding.getUserDirectory(), branding.getHistoryFileName()));
- */
-
- // Unless the user wants us to shut up, then display a nice welcome banner
- /*
- if (!io.isQuiet()) {
- io.out.println(branding.getWelcomeBanner());
- }
- */
-
- // Check if there are args, and run them and then enter interactive
- if (args.length != 0) {
- execute(args);
- }
-
- // And then spin up the console and go for a jog
- console.run();
+ boolean isOpened();
- // If any exit notification occured while running, then puke it up
- ExitNotification n = exitNotifHolder.get();
- if (n != null) {
- throw n;
- }
- }
+ void close();
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageCodecFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageCodecFactory.java?rev=577100&r1=577099&r2=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageCodecFactory.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageCodecFactory.java Tue Sep 18 16:05:47 2007
@@ -111,7 +111,7 @@
msg.writeExternal(buff);
buff.flip();
-
+
out.write(buff);
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java?rev=577100&r1=577099&r2=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java Tue Sep 18 16:05:47 2007
@@ -33,6 +33,4 @@
void visitCloseShell(CloseShellMessage msg) throws Exception;
void visitExecute(ExecuteMessage msg) throws Exception;
-
- void visitWriteStream(WriteStreamMessage msg) throws Exception;
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorSupport.java?rev=577100&r1=577099&r2=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorSupport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorSupport.java Tue Sep 18 16:05:47 2007
@@ -34,9 +34,21 @@
* @version $Rev$ $Date$
*/
public abstract class MessageVisitorSupport
- extends MessageVisitorAdapter
+ implements MessageVisitor
{
- protected Logger log = LoggerFactory.getLogger(getClass());
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ //
+ // MessageVisitor
+ //
+
+ public void visitEcho(EchoMessage msg) throws Exception {}
+
+ public void visitOpenShell(OpenShellMessage msg) throws Exception {}
+
+ public void visitCloseShell(CloseShellMessage msg) throws Exception {}
+
+ public void visitExecute(ExecuteMessage msg) throws Exception {}
//
// Stream Access
@@ -65,33 +77,5 @@
return out;
- }
-
- //
- // MessageVisitor
- //
-
- public void visitWriteStream(final WriteStreamMessage msg) throws Exception {
- assert msg != null;
-
- log.debug("Writing stream: {}", msg);
-
- IoSession session = msg.getSession();
-
- // Look up the bound stream in the session context
- String key = Transport.STREAM_BASENAME + msg.getName();
- Object stream = session.getAttribute(key);
-
- // For now lets not toss any exceptions or send back any fault messages
- if (stream == null) {
- log.error("Stream is not registered: {}", key);
- }
- else if (!(stream instanceof SessionInputStream)) {
- log.error("Stream is not for input: {}", key);
- }
- else {
- SessionInputStream in = (SessionInputStream)stream;
- in.write(msg.getBuffer());
- }
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/WriteStreamMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/WriteStreamMessage.java?rev=577100&r1=577099&r2=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/WriteStreamMessage.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/WriteStreamMessage.java Tue Sep 18 16:05:47 2007
@@ -29,15 +29,11 @@
public class WriteStreamMessage
extends MessageSupport
{
- private String name;
-
private ByteBuffer buffer;
- public WriteStreamMessage(final String name, final ByteBuffer buffer) {
+ public WriteStreamMessage(final ByteBuffer buffer) {
super(MessageType.WRITE_STREAM);
- this.name = name;
-
if (buffer != null) {
ByteBuffer tmp = ByteBuffer.allocate(buffer.remaining());
@@ -49,15 +45,7 @@
}
public WriteStreamMessage() {
- this(null, null);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
+ this(null);
}
public ByteBuffer getBuffer() {
@@ -73,8 +61,6 @@
super.readExternal(in);
- name = readString(in);
-
buffer = readBuffer(in);
}
@@ -83,14 +69,6 @@
super.writeExternal(out);
- writeString(out, name);
-
writeBuffer(out, buffer);
- }
-
- public void process(final MessageVisitor visitor) throws Exception {
- assert visitor != null;
-
- visitor.visitWriteStream(this);
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java?rev=577100&r1=577099&r2=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java Tue Sep 18 16:05:47 2007
@@ -156,11 +156,15 @@
released = true;
}
- public void write(final ByteBuffer src) {
+ public void write(final WriteStreamMessage msg) {
+ assert msg != null;
+
synchronized (mutex) {
if (closed) {
return;
}
+
+ ByteBuffer src = msg.getBuffer();
log.debug("Filling {} byte(s) into stream from: {}", src.remaining(), src);
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java?rev=577100&r1=577099&r2=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java Tue Sep 18 16:05:47 2007
@@ -72,10 +72,10 @@
private synchronized void write(final ByteBuffer buff) throws IOException {
ensureOpened();
- log.trace("Writing stream from: {}", buff);
+ log.debug("Writing stream from: {}", buff);
+
+ WriteStreamMessage msg = new WriteStreamMessage(buff);
- WriteStreamMessage msg = new WriteStreamMessage("IN", buff);
-
lastWriteFuture = session.write(msg);
}
@@ -101,7 +101,7 @@
return;
}
- log.trace("Flushing stream...");
+ log.debug("Flushing stream...");
lastWriteFuture.awaitUninterruptibly();
@@ -109,6 +109,6 @@
throw new IOException("The bytes could not be written to the session");
}
- log.trace("Flushed");
+ log.debug("Flushed");
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java?rev=577100&r1=577099&r2=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java Tue Sep 18 16:05:47 2007
@@ -19,12 +19,10 @@
package org.apache.geronimo.gshell.remote.transport;
-import java.io.InputStream;
-import java.io.OutputStream;
-
import org.apache.geronimo.gshell.remote.message.Message;
import org.apache.geronimo.gshell.remote.message.MessageResponseInspector;
import org.apache.geronimo.gshell.remote.message.MessageVisitor;
+import org.apache.geronimo.gshell.remote.message.WriteStreamMessage;
import org.apache.geronimo.gshell.remote.stream.SessionInputStream;
import org.apache.geronimo.gshell.remote.stream.SessionOutputStream;
import org.apache.mina.common.IdleStatus;
@@ -74,7 +72,7 @@
// Stream Access
//
- private void setInputStream(final IoSession session, final InputStream in) {
+ private void setInputStream(final IoSession session, final SessionInputStream in) {
assert session != null;
assert in != null;
@@ -89,10 +87,10 @@
log.debug("Bound input stream: {}", in);
}
- private InputStream getInputStream(final IoSession session) {
+ private SessionInputStream getInputStream(final IoSession session) {
assert session != null;
- InputStream in = (InputStream) session.getAttribute(Transport.INPUT_STREAM);
+ SessionInputStream in = (SessionInputStream) session.getAttribute(Transport.INPUT_STREAM);
if (in == null) {
throw new IllegalStateException("Input stream not bound");
@@ -101,13 +99,13 @@
return in;
}
- private InputStream removeInputStream(final IoSession session) {
+ private SessionInputStream removeInputStream(final IoSession session) {
assert session != null;
- return (InputStream) session.removeAttribute(Transport.INPUT_STREAM);
+ return (SessionInputStream) session.removeAttribute(Transport.INPUT_STREAM);
}
- private void setOutputStream(final IoSession session, final OutputStream out) {
+ private void setOutputStream(final IoSession session, final SessionOutputStream out) {
assert session != null;
assert out != null;
@@ -122,10 +120,10 @@
log.debug("Bound output stream: {}", out);
}
- private OutputStream getOutputStream(final IoSession session) {
+ private SessionOutputStream getOutputStream(final IoSession session) {
assert session != null;
- OutputStream out = (OutputStream) session.getAttribute(Transport.OUTPUT_STREAM);
+ SessionOutputStream out = (SessionOutputStream) session.getAttribute(Transport.OUTPUT_STREAM);
if (out == null) {
throw new IllegalStateException("Output stream not bound");
@@ -135,10 +133,10 @@
return out;
}
- private OutputStream removeOutputStream(final IoSession session) {
+ private SessionOutputStream removeOutputStream(final IoSession session) {
assert session != null;
- return (OutputStream) session.removeAttribute(Transport.OUTPUT_STREAM);
+ return (SessionOutputStream) session.removeAttribute(Transport.OUTPUT_STREAM);
}
//
@@ -192,7 +190,7 @@
//
// TODO: Need to handle Exception muck, and send faul messages back to clients
//
-
+
if (obj instanceof Message) {
//
// This is the main protocol action, set the session, freeze the message and
@@ -201,9 +199,19 @@
Message msg = (Message)obj;
- if (visitor != null) {
- msg.setSession(session);
- msg.freeze();
+ msg.setSession(session);
+ msg.freeze();
+
+ if (msg instanceof WriteStreamMessage) {
+ //
+ // HACK: See if this fucking works...
+ //
+
+ SessionInputStream in = getInputStream(session);
+
+ in.write((WriteStreamMessage)msg);
+ }
+ else if (visitor != null) {
msg.process(visitor);
}
else {
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java (from r577083, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShell.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShell.java&r1=577083&r2=577100&rev=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShell.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java Tue Sep 18 16:05:47 2007
@@ -25,8 +25,8 @@
import org.apache.geronimo.gshell.branding.Branding;
import org.apache.geronimo.gshell.command.CommandExecutor;
+import org.apache.geronimo.gshell.remote.RemoteShell;
import org.apache.geronimo.gshell.shell.Environment;
-import org.apache.geronimo.gshell.shell.Shell;
import org.apache.geronimo.gshell.shell.ShellInfo;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.InstantiationStrategy;
@@ -43,11 +43,9 @@
* @version $Rev$ $Date$
*/
@Component(role=RemoteShell.class, instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
-public class RemoteShell
- implements Shell, Initializable
+public class DefaultRemoteShell
+ implements RemoteShell, Initializable
{
- public static final String SESSION_KEY = RemoteShell.class.getName();
-
private final Logger log = LoggerFactory.getLogger(getClass());
@Requirement
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/DefaultRemoteShell.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java?rev=577100&r1=577099&r2=577100&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java Tue Sep 18 16:05:47 2007
@@ -27,6 +27,7 @@
import org.apache.geronimo.gshell.common.Notification;
import org.apache.geronimo.gshell.lookup.EnvironmentLookup;
import org.apache.geronimo.gshell.lookup.IOLookup;
+import org.apache.geronimo.gshell.remote.RemoteShell;
import org.apache.geronimo.gshell.remote.message.CloseShellMessage;
import org.apache.geronimo.gshell.remote.message.EchoMessage;
import org.apache.geronimo.gshell.remote.message.ExecuteMessage;
@@ -105,7 +106,7 @@
private RemoteShell getRemoteShell(final IoSession session) {
assert session != null;
- RemoteShell shell = (RemoteShell) session.getAttribute(RemoteShell.SESSION_KEY);
+ RemoteShell shell = (RemoteShell) session.getAttribute(RemoteShell.class.getName());
if (shell == null) {
throw new IllegalStateException("Remote shell not bound");
@@ -119,7 +120,7 @@
assert shell != null;
// Make sure that no session already exists
- Object obj = session.getAttribute(RemoteShell.SESSION_KEY);
+ Object obj = session.getAttribute(RemoteShell.class.getName());
if (obj != null) {
throw new IllegalStateException("Remote shell already bound");
@@ -131,14 +132,14 @@
private void unsetRemoteShell(final IoSession session) {
assert session != null;
- Object obj = session.getAttribute(RemoteShell.SESSION_KEY);
+ Object obj = session.getAttribute(RemoteShell.class.getName());
// Complain if no remote shell has been bound
if (obj != null) {
log.warn("Ignoring request to unset remote shell; no shell is bound");
}
else {
- session.removeAttribute(RemoteShell.SESSION_KEY);
+ session.removeAttribute(RemoteShell.class.getName());
}
}