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/27 23:53:52 UTC
svn commit: r580171 - in /geronimo/sandbox/gshell/trunk:
gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/
gshell-remote/gshell-remote-common/
gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo...
Author: jdillon
Date: Thu Sep 27 14:53:50 2007
New Revision: 580171
URL: http://svn.apache.org/viewvc?rev=580171&view=rev
Log:
Hook up the whisper bits
Added:
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CloseShellMessage.java (contents, props changed)
- copied, changed from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/CloseShellMessage.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ConnectMessage.java (contents, props changed)
- copied, changed from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ConnectMessage.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java (contents, props changed)
- copied, changed from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/EchoMessage.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java (contents, props changed)
- copied, changed from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java (contents, props changed)
- copied, changed from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/OpenShellMessage.java (contents, props changed)
- copied, changed from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/RshMessage.java (with props)
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/
geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java (with props)
geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandlerSupport.java (with props)
geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/UuidMessageID.java (contents, props changed)
- copied, changed from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java
Removed:
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientFactory.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientHandler.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/marshal/
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CryptoAwareMessageSupport.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/InvalidMessageException.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LongMessageID.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.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/MessageCodecSupport.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageDecoder.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageEncoder.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageException.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageHandler.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageType.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/UuidMessageID.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/ssl/
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerFactory.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/auth/
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-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/pom.xml
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteIO.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellContainer.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServer.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java
geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerHandler.java
geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestResponseFilter.java
geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java
geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.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=580171&r1=580170&r2=580171&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 Thu Sep 27 14:53:50 2007
@@ -28,10 +28,10 @@
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;
import org.apache.geronimo.gshell.shell.ShellInfo;
+import org.apache.geronimo.gshell.whisper.stream.StreamFeeder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -148,7 +148,7 @@
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: We need a hook into the session state here so that we can abort the console muck when the session closes
//
//
Modified: geronimo/sandbox/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/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java Thu Sep 27 14:53:50 2007
@@ -25,15 +25,22 @@
import java.security.PublicKey;
import org.apache.geronimo.gshell.remote.crypto.CryptoContext;
-import org.apache.geronimo.gshell.remote.message.Message;
-import org.apache.geronimo.gshell.remote.message.rsh.CloseShellMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.ConnectMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.EchoMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.ExecuteMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.LoginMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.OpenShellMessage;
-import org.apache.geronimo.gshell.remote.transport.Transport;
-import org.apache.geronimo.gshell.remote.transport.TransportFactory;
+import org.apache.geronimo.gshell.remote.message.CloseShellMessage;
+import org.apache.geronimo.gshell.remote.message.ConnectMessage;
+import org.apache.geronimo.gshell.remote.message.EchoMessage;
+import org.apache.geronimo.gshell.remote.message.ExecuteMessage;
+import org.apache.geronimo.gshell.remote.message.LoginMessage;
+import org.apache.geronimo.gshell.remote.message.OpenShellMessage;
+import org.apache.geronimo.gshell.whisper.message.Message;
+import org.apache.geronimo.gshell.whisper.transport.Transport;
+import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
+import org.apache.geronimo.gshell.whisper.transport.TransportFactoryLocator;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.demux.DemuxingIoHandler;
+import org.apache.mina.handler.demux.MessageHandler;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
+import org.codehaus.plexus.component.annotations.Requirement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,29 +49,24 @@
*
* @version $Rev$ $Date$
*/
+@Component(role=RshClient.class, instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
public class RshClient
{
- //
- // TODO: If/when we want to add a state-machine to keep things in order, add client-side here.
- //
-
private final Logger log = LoggerFactory.getLogger(getClass());
- private final CryptoContext crypto;
+ @Requirement
+ private CryptoContext crypto;
+
+ @Requirement
+ private TransportFactoryLocator locator;
- private final Transport transport;
+ private Transport transport;
- public RshClient(final CryptoContext crypto, final URI remote, final URI local, final TransportFactory factory) throws Exception {
- assert crypto != null;
- assert remote != null;
- // local may be null
- assert factory != null;
+ public void connect(final URI remote, final URI local) throws Exception {
+ TransportFactory factory = locator.locate(remote);
- this.crypto = crypto;
+ transport = factory.connect(remote, local, new ClientHandler());
- // And then lets connect to the remote server
- this.transport = factory.connect(remote, local);
-
log.debug("Connected to: {}", remote);
}
@@ -98,7 +100,7 @@
log.debug("Logging in: {}", username);
- response = transport.request(new LoginMessage(serverKey, username, password));
+ response = transport.request(new LoginMessage(username, password));
if (response instanceof LoginMessage.Success) {
log.debug("Login successful");
@@ -118,7 +120,7 @@
log.debug("Echoing: {}", text);
- transport.send(new EchoMessage(text));
+ transport.send(new EchoMessage(text)).join();
}
public void openShell() throws Exception {
@@ -188,5 +190,25 @@
assert args != null;
return doExecute(new ExecuteMessage(path, args));
+ }
+
+ //
+ // ClientHandler
+ //
+
+ private class ClientHandler
+ extends DemuxingIoHandler
+ {
+ public ClientHandler() {
+ addMessageHandler(EchoMessage.class, new EchoHandler());
+ }
+ }
+
+ private class EchoHandler
+ implements MessageHandler<EchoMessage>
+ {
+ public void messageReceived(final IoSession session, final EchoMessage message) throws Exception {
+ log.debug("ECHO: {}", message.getText());
+ }
}
}
Modified: geronimo/sandbox/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/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java Thu Sep 27 14:53:50 2007
@@ -48,7 +48,7 @@
@Option(name="-p", aliases={"--password"}, metaVar="PASSWORD", required=true)
private String password;
-
+
@Argument(metaVar="URI", required=true, index=0)
private URI remote;
@@ -59,21 +59,23 @@
private Terminal terminal;
@Requirement
- private RshClientFactory factory;
-
private RshClient client;
protected Object doExecute() throws Exception {
io.info("Connecting to: {}", remote);
- client = factory.connect(remote, local);
+ client.connect(remote, local);
io.info("Connected");
+ // client.echo("HELLO");
+ // Thread.sleep(10 * 1000);
+
+
//
// TODO: Allow username and/or password to be read from input, need access to the console instance to get password reading working
//
-
+
client.login(username, password);
// client.echo("NOISE MAKER");
@@ -99,7 +101,7 @@
client.close();
io.verbose("Disconnected");
-
- return rv;
+
+ return false;
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/pom.xml?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/pom.xml Thu Sep 27 14:53:50 2007
@@ -37,6 +37,14 @@
Common support for the GShell remote shell client and server.
</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.gshell</groupId>
+ <artifactId>gshell-whisper</artifactId>
+ <version>${version}</version>
+ </dependency>
+ </dependencies>
+
<build>
<plugins>
<plugin>
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CloseShellMessage.java (from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/CloseShellMessage.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/CloseShellMessage.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CloseShellMessage.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/CloseShellMessage.java&r1=579828&r2=580171&rev=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/CloseShellMessage.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CloseShellMessage.java Thu Sep 27 14:53:50 2007
@@ -17,12 +17,7 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.message.rsh;
-
-import org.apache.geronimo.gshell.remote.message.MessageSupport;
-import org.apache.geronimo.gshell.remote.message.MessageType;
-import org.apache.geronimo.gshell.remote.message.MessageVisitor;
-import org.apache.mina.common.IoSession;
+package org.apache.geronimo.gshell.remote.message;
/**
* Close the remote shell instance.
@@ -30,15 +25,9 @@
* @version $Rev$ $Date$
*/
public class CloseShellMessage
- extends MessageSupport
+ extends RshMessage
{
public CloseShellMessage() {
- super(MessageType.CLOSE_SHELL);
- }
-
- public void process(final IoSession session, final MessageVisitor visitor) throws Exception {
- assert visitor != null;
-
- visitor.visitCloseShell(session, this);
+ super(Type.CLOSE_SHELL);
}
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CloseShellMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CloseShellMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/CloseShellMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ConnectMessage.java (from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ConnectMessage.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/ConnectMessage.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ConnectMessage.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ConnectMessage.java&r1=579828&r2=580171&rev=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ConnectMessage.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ConnectMessage.java Thu Sep 27 14:53:50 2007
@@ -17,37 +17,29 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.message.rsh;
+package org.apache.geronimo.gshell.remote.message;
import java.security.PublicKey;
import java.util.UUID;
-import org.apache.geronimo.gshell.remote.marshal.Marshaller;
-import org.apache.geronimo.gshell.remote.message.CryptoAwareMessageSupport;
-import org.apache.geronimo.gshell.remote.message.MessageType;
-import org.apache.geronimo.gshell.remote.message.MessageVisitor;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-
/**
* Initial client to server message to initiate the connection.
*
* @version $Rev$ $Date$
*/
public class ConnectMessage
- extends CryptoAwareMessageSupport
- implements HandshakeMessage
+ extends RshMessage
{
private PublicKey publicKey;
- protected ConnectMessage(final MessageType type, final PublicKey publicKey) {
+ protected ConnectMessage(final Type type, final PublicKey publicKey) {
super(type);
this.publicKey = publicKey;
}
public ConnectMessage(final PublicKey clientKey) {
- this(MessageType.CONNECT, clientKey);
+ this(Type.CONNECT, clientKey);
}
public ConnectMessage() {
@@ -66,10 +58,7 @@
this.publicKey = publicKey;
}
- public void process(final IoSession session, final MessageVisitor visitor) throws Exception {
- visitor.visitConnect(session, this);
- }
-
+ /*
public void readExternal(final ByteBuffer in) throws Exception {
assert in != null;
@@ -91,6 +80,7 @@
Marshaller.writeBytes(out, getPublicKey().getEncoded());
}
+ */
/**
* Indicates the first part of the connection handshake was successful.
@@ -101,7 +91,7 @@
private UUID clientId;
public Result(final UUID clientId, final PublicKey serverKey) {
- super(MessageType.CONNECT_RESULT, serverKey);
+ super(Type.CONNECT_RESULT, serverKey);
this.clientId = clientId;
}
@@ -114,6 +104,7 @@
return clientId;
}
+ /*
public void readExternal(final ByteBuffer in) throws Exception {
assert in != null;
@@ -129,5 +120,6 @@
Marshaller.writeUuid(out, clientId);
}
+ */
}
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ConnectMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ConnectMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ConnectMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java (from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/EchoMessage.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/EchoMessage.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/EchoMessage.java&r1=579828&r2=580171&rev=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/EchoMessage.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java Thu Sep 27 14:53:50 2007
@@ -17,14 +17,7 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.message.rsh;
-
-import org.apache.geronimo.gshell.remote.marshal.Marshaller;
-import org.apache.geronimo.gshell.remote.message.MessageSupport;
-import org.apache.geronimo.gshell.remote.message.MessageType;
-import org.apache.geronimo.gshell.remote.message.MessageVisitor;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
+package org.apache.geronimo.gshell.remote.message;
/**
* Echo text.
@@ -32,43 +25,17 @@
* @version $Rev$ $Date$
*/
public class EchoMessage
- extends MessageSupport
+ extends RshMessage
{
- private String text;
+ private final String text;
public EchoMessage(final String text) {
- super(MessageType.ECHO);
+ super(Type.ECHO);
this.text = text;
}
- public EchoMessage() {
- this(null);
- }
-
public String getText() {
return text;
- }
-
- public void readExternal(final ByteBuffer in) throws Exception {
- assert in != null;
-
- super.readExternal(in);
-
- text = Marshaller.readString(in);
- }
-
- public void writeExternal(final ByteBuffer out) throws Exception {
- assert out != null;
-
- super.writeExternal(out);
-
- Marshaller.writeString(out, text);
- }
-
- public void process(final IoSession session, final MessageVisitor visitor) throws Exception {
- assert visitor != null;
-
- visitor.visitEcho(session, this);
}
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java (from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.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/ExecuteMessage.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.java&r1=579828&r2=580171&rev=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java Thu Sep 27 14:53:50 2007
@@ -17,15 +17,9 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.message.rsh;
+package org.apache.geronimo.gshell.remote.message;
import org.apache.geronimo.gshell.command.CommandExecutor;
-import org.apache.geronimo.gshell.remote.marshal.Marshaller;
-import org.apache.geronimo.gshell.remote.message.MessageSupport;
-import org.apache.geronimo.gshell.remote.message.MessageType;
-import org.apache.geronimo.gshell.remote.message.MessageVisitor;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
/**
* Execute a command. This supports all flavors of the {@link CommandExecutor} execution methods.
@@ -33,7 +27,7 @@
* @version $Rev$ $Date$
*/
public class ExecuteMessage
- extends MessageSupport
+ extends RshMessage
{
private Flavor flavor;
@@ -42,7 +36,7 @@
private Object[] args;
private ExecuteMessage(final Flavor flavor, final String path, final Object[] args) {
- super(MessageType.EXECUTE);
+ super(Type.EXECUTE);
this.flavor = flavor;
this.path = path;
@@ -71,6 +65,7 @@
return flavor.execute(this, executor);
}
+ /*
public void readExternal(final ByteBuffer in) throws Exception {
assert in != null;
@@ -94,12 +89,7 @@
Marshaller.writeObject(out, args);
}
-
- public void process(final IoSession session, final MessageVisitor visitor) throws Exception {
- assert visitor != null;
-
- visitor.visitExecute(session, this);
- }
+ */
//
// Flavor
@@ -136,18 +126,18 @@
* Response for execute messages which contain the result of the command execution.
*/
public static class Result
- extends MessageSupport
+ extends RshMessage
{
private Object result;
- protected Result(final MessageType type, final Object result) {
+ protected Result(final Type type, final Object result) {
super(type);
this.result = result;
}
public Result(final Object result) {
- this(MessageType.EXECUTE_RESULT, result);
+ this(Type.EXECUTE_RESULT, result);
this.result = result;
}
@@ -159,7 +149,8 @@
public Object getResult() {
return result;
}
-
+
+ /*
public void readExternal(final ByteBuffer in) throws Exception {
assert in != null;
@@ -175,6 +166,7 @@
Marshaller.writeObject(out, result);
}
+ */
}
/**
@@ -184,7 +176,7 @@
extends Result
{
public Fault(final Throwable cause) {
- super(MessageType.EXECUTE_FAULT, cause);
+ super(Type.EXECUTE_FAULT, cause);
}
public Fault() {
@@ -203,7 +195,7 @@
extends Result
{
public Notification(final org.apache.geronimo.gshell.common.Notification n) {
- super(MessageType.EXECUTE_NOTIFICATION, n);
+ super(Type.EXECUTE_NOTIFICATION, n);
}
public Notification() {
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java (from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.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/LoginMessage.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.java&r1=579828&r2=580171&rev=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java Thu Sep 27 14:53:50 2007
@@ -17,19 +17,10 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.message.rsh;
+package org.apache.geronimo.gshell.remote.message;
import java.security.PublicKey;
-import org.apache.geronimo.gshell.remote.marshal.Marshaller;
-import org.apache.geronimo.gshell.remote.message.CryptoAwareMessageSupport;
-import org.apache.geronimo.gshell.remote.message.MessageSupport;
-import org.apache.geronimo.gshell.remote.message.MessageType;
-import org.apache.geronimo.gshell.remote.message.MessageVisitor;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.codehaus.plexus.util.StringUtils;
-
/**
* Contains the user authentication details which the client will pass to the server after the
* authetication of the connection has been established.
@@ -37,35 +28,28 @@
* @version $Rev$ $Date$
*/
public class LoginMessage
- extends CryptoAwareMessageSupport
- implements HandshakeMessage
+ extends RshMessage
{
- private PublicKey serverKey;
-
private String username;
private String password;
- public LoginMessage(final PublicKey serverKey, final String username, final String password) {
- super(MessageType.LOGIN);
-
- this.serverKey = serverKey;
+ public LoginMessage(final String username, final String password) {
+ super(Type.LOGIN);
this.username = username;
this.password = password;
}
- public LoginMessage() {
- this(null, null, null);
- }
-
+ /*
public String toString() {
return createToStringBuilder()
.append("username", username)
.append("password", StringUtils.repeat("*", password.length()))
.toString();
}
+ */
public String getUsername() {
return username;
@@ -75,10 +59,7 @@
return password;
}
- public void process(final IoSession session, final MessageVisitor visitor) throws Exception {
- visitor.visitLogin(session, this);
- }
-
+ /*
public void readExternal(final ByteBuffer in) throws Exception {
assert in != null;
@@ -98,15 +79,16 @@
encryptString(out, serverKey, password);
}
+ */
/**
* Response for login messages which were sucessful.
*/
public static class Success
- extends MessageSupport
+ extends RshMessage
{
public Success() {
- super(MessageType.LOGIN_SUCCESS);
+ super(Type.LOGIN_SUCCESS);
}
}
@@ -114,12 +96,12 @@
* Response for login messages which have failed.
*/
public static class Failure
- extends MessageSupport
+ extends RshMessage
{
private String reason;
public Failure(final String reason) {
- super(MessageType.LOGIN_FAILURE);
+ super(Type.LOGIN_FAILURE);
this.reason = reason;
}
@@ -132,6 +114,7 @@
return reason;
}
+ /*
public void readExternal(final ByteBuffer in) throws Exception {
assert in != null;
@@ -147,5 +130,6 @@
Marshaller.writeString(out, reason);
}
+ */
}
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/OpenShellMessage.java (from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.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/OpenShellMessage.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/OpenShellMessage.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.java&r1=579828&r2=580171&rev=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/OpenShellMessage.java Thu Sep 27 14:53:50 2007
@@ -17,12 +17,7 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.message.rsh;
-
-import org.apache.geronimo.gshell.remote.message.MessageSupport;
-import org.apache.geronimo.gshell.remote.message.MessageType;
-import org.apache.geronimo.gshell.remote.message.MessageVisitor;
-import org.apache.mina.common.IoSession;
+package org.apache.geronimo.gshell.remote.message;
/**
* Open a remote shell instance.
@@ -30,15 +25,9 @@
* @version $Rev$ $Date$
*/
public class OpenShellMessage
- extends MessageSupport
+ extends RshMessage
{
public OpenShellMessage() {
- super(MessageType.OPEN_SHELL);
- }
-
- public void process(final IoSession session, final MessageVisitor visitor) throws Exception {
- assert visitor != null;
-
- visitor.visitOpenShell(session, this);
+ super(Type.OPEN_SHELL);
}
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/OpenShellMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/OpenShellMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/OpenShellMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/RshMessage.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/RshMessage.java?rev=580171&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/RshMessage.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/RshMessage.java Thu Sep 27 14:53:50 2007
@@ -0,0 +1,66 @@
+/*
+ * 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.remote.message;
+
+import org.apache.geronimo.gshell.whisper.message.BaseMessage;
+import org.apache.geronimo.gshell.whisper.message.Message;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class RshMessage
+ extends BaseMessage
+{
+ protected RshMessage(final Type type) {
+ super(type);
+ }
+
+ public static enum Type
+ implements Message.Type
+ {
+ ECHO (EchoMessage.class),
+ CONNECT (ConnectMessage.class),
+ CONNECT_RESULT (ConnectMessage.Result.class),
+ LOGIN (LoginMessage.class),
+ LOGIN_SUCCESS (LoginMessage.Success.class),
+ LOGIN_FAILURE (LoginMessage.Failure.class),
+ OPEN_SHELL (OpenShellMessage.class),
+ CLOSE_SHELL (CloseShellMessage.class),
+ EXECUTE (ExecuteMessage.class),
+ EXECUTE_RESULT (ExecuteMessage.Result.class),
+ EXECUTE_NOTIFICATION (ExecuteMessage.Notification.class),
+ EXECUTE_FAULT (ExecuteMessage.Fault.class),
+ ;
+
+ private final Class<? extends RshMessage> type;
+
+ private Type(Class<? extends RshMessage> type) {
+ assert type != null;
+
+ this.type = type;
+ }
+
+ public Class<? extends RshMessage> getType() {
+ return type;
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/RshMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/RshMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/RshMessage.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/RemoteIO.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/RemoteIO.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteIO.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteIO.java Thu Sep 27 14:53:50 2007
@@ -20,8 +20,8 @@
package org.apache.geronimo.gshell.remote.server;
import org.apache.geronimo.gshell.command.IO;
-import org.apache.geronimo.gshell.remote.stream.SessionInputStream;
-import org.apache.geronimo.gshell.remote.stream.SessionOutputStream;
+import org.apache.geronimo.gshell.whisper.stream.SessionInputStream;
+import org.apache.geronimo.gshell.whisper.stream.SessionOutputStream;
import org.apache.mina.common.IoSession;
/**
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellContainer.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/RemoteShellContainer.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellContainer.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RemoteShellContainer.java Thu Sep 27 14:53:50 2007
@@ -21,7 +21,7 @@
import java.util.UUID;
-import org.apache.geronimo.gshell.remote.session.SessionAttributeBinder;
+import org.apache.geronimo.gshell.whisper.session.SessionAttributeBinder;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServer.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/RshServer.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServer.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServer.java Thu Sep 27 14:53:50 2007
@@ -20,9 +20,46 @@
package org.apache.geronimo.gshell.remote.server;
import java.net.URI;
+import java.security.PublicKey;
+import java.util.UUID;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
-import org.apache.geronimo.gshell.remote.transport.TransportFactory;
-import org.apache.geronimo.gshell.remote.transport.TransportServer;
+import org.apache.geronimo.gshell.DefaultEnvironment;
+import org.apache.geronimo.gshell.common.Duration;
+import org.apache.geronimo.gshell.common.NamedThreadFactory;
+import org.apache.geronimo.gshell.common.Notification;
+import org.apache.geronimo.gshell.common.tostring.ToStringBuilder;
+import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+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.crypto.CryptoContext;
+import org.apache.geronimo.gshell.remote.message.CloseShellMessage;
+import org.apache.geronimo.gshell.remote.message.ConnectMessage;
+import org.apache.geronimo.gshell.remote.message.EchoMessage;
+import org.apache.geronimo.gshell.remote.message.ExecuteMessage;
+import org.apache.geronimo.gshell.remote.message.LoginMessage;
+import org.apache.geronimo.gshell.remote.message.OpenShellMessage;
+import org.apache.geronimo.gshell.remote.message.RshMessage;
+import org.apache.geronimo.gshell.shell.Environment;
+import org.apache.geronimo.gshell.whisper.message.MessageHandler;
+import org.apache.geronimo.gshell.whisper.message.MessageHandlerSupport;
+import org.apache.geronimo.gshell.whisper.session.SessionAttributeBinder;
+import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
+import org.apache.geronimo.gshell.whisper.transport.TransportFactoryLocator;
+import org.apache.geronimo.gshell.whisper.transport.TransportServer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.demux.DemuxingIoHandler;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.classworlds.ClassWorld;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,24 +68,398 @@
*
* @version $Rev$ $Date$
*/
+@Component(role=RshServer.class, instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
public class RshServer
+ implements Initializable
{
private final Logger log = LoggerFactory.getLogger(getClass());
- private final TransportServer server;
+ @Requirement
+ private PlexusContainer container;
- public RshServer(final URI location, final TransportFactory factory) throws Exception {
- assert location != null;
- assert factory != null;
+ private ClassWorld classWorld;
- server = factory.bind(location);
+ private ScheduledThreadPoolExecutor scheduler;
+
+ @Requirement
+ private CryptoContext crypto;
+
+ @Requirement
+ private TransportFactoryLocator locator;
+
+ private TransportServer server;
+
+ private final UUID securityToken = UUID.randomUUID();
+
+ public void initialize() throws InitializationException {
+ classWorld = container.getContainerRealm().getWorld();
+
+ ThreadFactory tf = new NamedThreadFactory(getClass());
+ scheduler = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), tf);
+ }
+
+ public void bind(final URI location) throws Exception {
+ TransportFactory factory = locator.locate(location);
+
+ server = factory.bind(location, new ServerHandler());
log.debug("Bound to: {}", location);
}
public void close() {
server.close();
+ }
+
+ //
+ // SessionState
+ //
+
+ /**
+ * Session binding helper for {@link SessionState} instances.
+ */
+ private static final SessionAttributeBinder<SessionState> SESSION_STATE = new SessionAttributeBinder<SessionState>(SessionState.class);
+
+ /**
+ * Container for various bits of state we are tracking.
+ */
+ private class SessionState
+ {
+ /** The remote client's unique identifier. */
+ public final UUID id = UUID.randomUUID();
+
+ /** The remove client's public key. */
+ public PublicKey pk;
+
+ /** The shared security token */
+ public UUID sectoken;
+
+ /** The remote client's logged in username. */
+ public String username;
+
+ /** The container which the remote shell is running in. */
+ public RemoteShellContainer container;
+
+ /** The I/O context for the remote shell. */
+ public RemoteIO io;
+
+ /** The environment for the remote shell. */
+ public Environment env;
+
+ /** The remote shell instance. */
+ public RemoteShell shell;
+
+ public void destroy() {
+ shell.close();
+
+ container.disposeAllComponents();
+ }
+
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+ .append("id", id)
+ .append("username", username)
+ .toString();
+ }
+ }
+
+ private class ServerHandler
+ extends DemuxingIoHandler
+ {
+ public ServerHandler() throws Exception {
+ register(new ConnectHandler());
+ register(new LoginHandler());
+ register(new OpenShellHandler());
+ register(new CloseShellHandler());
+ register(new ExecuteHandler());
+ register(new EchoHandler());
+ }
+
+ public void register(final MessageHandler handler) {
+ assert handler != null;
+
+ addMessageHandler(handler.getType(), handler);
+ }
+
+ /*
+ @Override
+ public void messageReceived(final IoSession session, final Object obj) throws Exception {
+ assert session != null;
+ assert obj != null;
+
+ SessionState state = SESSION_STATE.lookup(session, null);
+
+ if (state != null && securityToken.equals(state.sectoken)) {
+ log.debug("Message is already authenticated");
+
+ super.messageReceived(session, obj);
+ }
+ else if (obj instanceof HandshakeMessage) {
+ log.debug("Message requires handshake/authentication");
+
+ super.messageReceived(session, obj);
+ }
+ else {
+ // If we get to here, then the message is not valid, so complain, then kill the session
+ log.error("Invalid message: {}", obj);
+
+ //
+ // TODO: See if we can just toss an IOException here instead?
+ //
+
+ session.close();
+ }
+ }
+ */
+
+ @Override
+ public void sessionOpened(final IoSession session) throws Exception {
+ assert session != null;
+
+ // Schedule a task to timeout the handshake process
+ scheduleTimeout(session, AUTH_TIMEOUT);
+ }
+
+ @Override
+ public void sessionClosed(final IoSession session) throws Exception {
+ assert session != null;
+
+ SessionState state = SESSION_STATE.unbind(session);
+
+ // If there is still state bound then clean it up
+ if (state != null) {
+ log.warn("Delinquent state detected: {}", state);
+
+ try {
+ state.destroy();
+ }
+ catch (Exception e) {
+ log.warn("Failed to clean up after delinquent state", e);
+ }
+ }
+ }
+ }
+
+ private class ConnectHandler
+ extends MessageHandlerSupport<ConnectMessage>
+ {
+ public ConnectHandler() {
+ super(RshMessage.Type.CONNECT);
+ }
+
+ public void messageReceived(IoSession session, ConnectMessage message) throws Exception {
+ // Try to cancel the timeout task
+ if (!cancelTimeout(session)) {
+ log.warn("Aborting handshake processing; timeout has triggered");
+ }
+ else {
+ // Setup the initial client state
+ SessionState state = SESSION_STATE.bind(session, new SessionState());
+ log.info("Initiating state for client: {}", state.id);
+
+ // Hold on to the client's public key
+ state.pk = message.getPublicKey();
+
+ // Reply to the client with some details about the connection
+ ConnectMessage.Result reply = new ConnectMessage.Result(state.id, crypto.getPublicKey());
+ reply.setCorrelationId(message.getId());
+ session.write(reply);
+
+ // Schedule a task to timeout the login process
+ scheduleTimeout(session, AUTH_TIMEOUT);
+ }
+ }
+ }
+
+ private class LoginHandler
+ extends MessageHandlerSupport<LoginMessage>
+ {
+ protected LoginHandler() {
+ super(RshMessage.Type.LOGIN);
+ }
+
+ public void messageReceived(IoSession session, LoginMessage message) throws Exception {
+ // Try to cancel the timeout task
+ if (!cancelTimeout(session)) {
+ log.warn("Aborting login processing; timeout has triggered");
+ }
+ else {
+ String username = message.getUsername();
+ String password = message.getPassword();
+
+ SessionState state = SESSION_STATE.lookup(session);
+
+ //
+ // TODO: Implement something else...
+ //
+
+ // Mark the session as authenticated (which is done by setting the sectoken)
+ state.sectoken = securityToken;
+
+ // Remember our username
+ state.username = username;
+
+ log.info("Successfull authentication for user: {}, at location: {}", username, session.getRemoteAddress());
+
+ LoginMessage.Success reply = new LoginMessage.Success();
+ reply.setCorrelationId(message.getId());
+ session.write(reply);
+ }
+ }
+ }
+
+ private class OpenShellHandler
+ extends MessageHandlerSupport<OpenShellMessage>
+ {
+ protected OpenShellHandler() {
+ super(RshMessage.Type.OPEN_SHELL);
+ }
+
+ public void messageReceived(IoSession session, OpenShellMessage message) throws Exception {
+ SessionState state = SESSION_STATE.lookup(session);
+
+ // Create a new container which will be the parent for our remote shells
+ state.container = RemoteShellContainer.create(classWorld);
+
+ // Setup the I/O context (w/o auto-flushing)
+ state.io = new RemoteIO(session);
+ IOLookup.set(state.container, state.io);
+
+ // Setup shell environemnt
+ state.env = new DefaultEnvironment(state.io);
+ EnvironmentLookup.set(state.container, state.env);
+
+ // Create a new shell instance
+ state.shell = (RemoteShell) state.container.lookup(RemoteShell.class);
+
+ //
+ // TODO: Send a meaningful response
+ //
+
+ EchoMessage reply = new EchoMessage("OPEN SHELL SUCCESS");
+ reply.setCorrelationId(message.getId());
+ session.write(reply);
+ }
+ }
+
+ private class CloseShellHandler
+ extends MessageHandlerSupport<CloseShellMessage>
+ {
+ protected CloseShellHandler() {
+ super(RshMessage.Type.CLOSE_SHELL);
+ }
+
+ public void messageReceived(IoSession session, CloseShellMessage message) throws Exception {
+ SessionState state = SESSION_STATE.unbind(session);
+
+ //
+ // TODO: This should just clean up the bits related to shell muck...
+ //
+
+ state.destroy();
+
+ //
+ // TODO: Send a meaningful response
+ //
+
+ EchoMessage reply = new EchoMessage("CLOSE SHELL SUCCESS");
+ reply.setCorrelationId(message.getId());
+ session.write(reply);
+ }
+ }
+
+ private class ExecuteHandler
+ extends MessageHandlerSupport<ExecuteMessage>
+ {
+ protected ExecuteHandler() {
+ super(RshMessage.Type.EXECUTE);
+ }
+
+ public void messageReceived(IoSession session, ExecuteMessage message) throws Exception {
+ SessionState state = SESSION_STATE.lookup(session);
+
+ // Need to make sure that the execuing thread has the right I/O and environment in context
+ IOLookup.set(state.container, state.io);
+ EnvironmentLookup.set(state.container, state.env);
+
+ ExecuteMessage.Result reply;
+
+ try {
+ Object result = message.execute(state.shell);
+
+ log.debug("Result: {}", result);
+
+ reply = new ExecuteMessage.Result(result);
+ }
+ catch (Notification n) {
+ log.debug("Notification: " + n);
+
+ reply = new ExecuteMessage.Notification(n);
+ }
+ catch (Throwable t) {
+ log.debug("Fault: " + t);
+
+ reply = new ExecuteMessage.Fault(t);
+ }
+
+ reply.setCorrelationId(message.getId());
+ session.write(reply);
+ }
+ }
+
+ private class EchoHandler
+ extends MessageHandlerSupport<EchoMessage>
+ {
+ protected EchoHandler() {
+ super(RshMessage.Type.ECHO);
+ }
+
+ public void messageReceived(IoSession session, EchoMessage message) throws Exception {
+ EchoMessage reply = new EchoMessage(message.getText());
+ reply.setCorrelationId(message.getId());
+ session.write(reply);
+ }
+ }
+
+ //
+ // Timeout Support
+ //
+
+ //
+ // TODO: Move this timeout stuff to a component, a few things need this functionality, probably more than I can think of too..
+ //
+
+ private static final SessionAttributeBinder<ScheduledFuture> TIMEOUT_BINDER = new SessionAttributeBinder<ScheduledFuture>(RshServer.class, "timeout");
+
+ private static final Duration AUTH_TIMEOUT = new Duration(10, TimeUnit.SECONDS);
+
+ private ScheduledFuture scheduleTimeout(final IoSession session, final Duration timeout) {
+ assert session != null;
+ assert timeout != null;
+
+ Runnable task = new Runnable() {
+ public void run() {
+ log.error("Timeout waiting for handshake or authentication from: {}", session.getRemoteAddress());
+
+ session.close();
+ }
+ };
+
+ ScheduledFuture tf = scheduler.schedule(task, timeout.value, timeout.unit);
+
+ TIMEOUT_BINDER.rebind(session, tf);
+
+ return tf;
+ }
+
+ private boolean cancelTimeout(final IoSession session) {
+ assert session != null;
+
+ ScheduledFuture tf = TIMEOUT_BINDER.lookup(session);
- log.debug("Closed");
+ return tf.cancel(false);
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.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/RshServerCommand.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java Thu Sep 27 14:53:50 2007
@@ -43,12 +43,10 @@
private URI location;
@Requirement
- private RshServerFactory factory;
-
private RshServer server;
protected Object doExecute() throws Exception {
- server = factory.connect(location);
+ server.bind(location);
io.info("Listening on: {}", location);
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerHandler.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/RshServerHandler.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerHandler.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerHandler.java Thu Sep 27 14:53:50 2007
@@ -24,51 +24,34 @@
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import org.apache.geronimo.gshell.DefaultEnvironment;
import org.apache.geronimo.gshell.common.Duration;
-import org.apache.geronimo.gshell.common.NamedThreadFactory;
import org.apache.geronimo.gshell.common.Notification;
import org.apache.geronimo.gshell.common.tostring.ToStringBuilder;
import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
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.crypto.CryptoContext;
-import org.apache.geronimo.gshell.remote.message.MessageHandler;
-import org.apache.geronimo.gshell.remote.message.MessageVisitorSupport;
-import org.apache.geronimo.gshell.remote.message.rsh.CloseShellMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.ConnectMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.EchoMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.ExecuteMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.HandshakeMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.LoginMessage;
-import org.apache.geronimo.gshell.remote.message.rsh.OpenShellMessage;
-import org.apache.geronimo.gshell.remote.server.auth.UserAuthenticator;
-import org.apache.geronimo.gshell.remote.session.SessionAttributeBinder;
-import org.apache.geronimo.gshell.remote.stream.SessionOutputStream;
+import org.apache.geronimo.gshell.remote.message.CloseShellMessage;
+import org.apache.geronimo.gshell.remote.message.ConnectMessage;
+import org.apache.geronimo.gshell.remote.message.EchoMessage;
+import org.apache.geronimo.gshell.remote.message.ExecuteMessage;
+import org.apache.geronimo.gshell.remote.message.LoginMessage;
+import org.apache.geronimo.gshell.remote.message.OpenShellMessage;
import org.apache.geronimo.gshell.shell.Environment;
+import org.apache.geronimo.gshell.whisper.session.SessionAttributeBinder;
import org.apache.mina.common.IoSession;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.classworlds.ClassWorld;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
/**
* Provides the server-side message handling for the GShell rsh protocol.
*
* @version $Rev$ $Date$
*/
-@Component(role=MessageHandler.class, hint="server")
public class RshServerHandler
- extends MessageHandler
- implements Initializable
{
+/*
@Requirement
private PlexusContainer container;
@@ -154,6 +137,8 @@
}
}
+ */
+
//
// SessionState
//
@@ -214,6 +199,7 @@
// MessageVisitor
//
+ /*
private class Visitor
extends MessageVisitorSupport
{
@@ -449,4 +435,5 @@
return tf.cancel(false);
}
+ */
}
Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java?rev=580171&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java Thu Sep 27 14:53:50 2007
@@ -0,0 +1,31 @@
+/*
+ * 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.whisper.message;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MessageHandler<T extends Message>
+ extends org.apache.mina.handler.demux.MessageHandler<T>
+{
+ Class<T> getType();
+}
Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandlerSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandlerSupport.java?rev=580171&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandlerSupport.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandlerSupport.java Thu Sep 27 14:53:50 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.whisper.message;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class MessageHandlerSupport<T extends Message>
+ implements MessageHandler<T>
+{
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ private Message.Type type;
+
+ protected MessageHandlerSupport(final Message.Type type) {
+ assert type != null;
+
+ this.type = type;
+ }
+
+ public Class<T> getType() {
+ return (Class<T>) type.getType();
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandlerSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandlerSupport.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandlerSupport.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/UuidMessageID.java (from r579828, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/UuidMessageID.java?p2=geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/UuidMessageID.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java&r1=579828&r2=580171&rev=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/UuidMessageID.java Thu Sep 27 14:53:50 2007
@@ -17,13 +17,10 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.message;
+package org.apache.geronimo.gshell.whisper.message;
import java.util.UUID;
-import org.apache.geronimo.gshell.remote.marshal.Marshaller;
-import org.apache.mina.common.ByteBuffer;
-
/**
* Provides {@link Message.ID} instances based on {@link UUID} objects.
*
@@ -32,14 +29,10 @@
public class UuidMessageID
implements Message.ID
{
- private UUID value;
-
- public UuidMessageID(final UUID value) {
- this.value = value;
- }
+ private final UUID value;
public UuidMessageID() {
- this(UUID.randomUUID());
+ value = UUID.randomUUID();
}
public int hashCode() {
@@ -64,22 +57,7 @@
return String.valueOf(value);
}
- public void writeExternal(final ByteBuffer out) throws Exception {
- Marshaller.writeUuid(out, value);
- }
-
- public void readExternal(final ByteBuffer in) throws Exception {
- value = Marshaller.readUuid(in);
- }
-
- /**
- * Factory to create {@link UuidMessageID} instances.
- */
- public static class Generator
- implements Message.IDGenerator
- {
- public Message.ID generate() {
- return new UuidMessageID();
- }
+ public static Message.ID generate() {
+ return new UuidMessageID();
}
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/UuidMessageID.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/UuidMessageID.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/UuidMessageID.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestResponseFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestResponseFilter.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestResponseFilter.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestResponseFilter.java Thu Sep 27 14:53:50 2007
@@ -61,7 +61,7 @@
* When a request is sent, register it with the request manager.
*/
@Override
- public void filterWrite(final NextFilter nextFilter, final IoSession session, final WriteRequest writeRequest) throws Exception {
+ public void filterWrite(final NextFilter nextFilter, final IoSession session, WriteRequest writeRequest) throws Exception {
Object message = writeRequest.getMessage();
if (message instanceof Request) {
@@ -70,6 +70,9 @@
RequestManager manager = RequestManager.BINDER.lookup(session);
manager.register(request);
+
+ // Send the actual message, not our request handle
+ writeRequest = new WriteRequest(request.getMessage(), writeRequest.getFuture(), writeRequest.getDestination());
}
nextFilter.filterWrite(session, writeRequest);
Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java Thu Sep 27 14:53:50 2007
@@ -19,6 +19,11 @@
package org.apache.geronimo.gshell.whisper.stream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.channels.Channels;
+import java.nio.channels.WritableByteChannel;
+
import org.apache.geronimo.gshell.whisper.message.BaseMessage;
import org.apache.geronimo.gshell.whisper.message.Message;
import org.apache.mina.common.ByteBuffer;
@@ -31,35 +36,26 @@
public class StreamMessage
extends BaseMessage
{
- private ByteBuffer buffer;
+ private byte[] bytes;
- public StreamMessage(final Type type, final ByteBuffer buffer) {
+ public StreamMessage(final Type type, final ByteBuffer buffer) throws IOException {
super(type);
- if (buffer != null) {
- ByteBuffer tmp = ByteBuffer.allocate(buffer.remaining());
-
- tmp.put(buffer);
- tmp.flip();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ WritableByteChannel channel = Channels.newChannel(baos);
+ channel.write(buffer.buf());
+ channel.close();
- this.buffer = tmp;
- }
+ bytes = baos.toByteArray();
}
- public StreamMessage(final ByteBuffer buffer) {
+ public StreamMessage(final ByteBuffer buffer) throws IOException {
this(StreamMessage.Type.IN, buffer);
}
-
- public StreamMessage() {
- this(null, null);
- }
public ByteBuffer getBuffer() {
- return buffer;
- }
-
- public void setBuffer(final ByteBuffer buffer) {
- this.buffer = buffer;
+ return ByteBuffer.wrap(bytes);
}
public static enum Type
Modified: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java?rev=580171&r1=580170&r2=580171&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseService.java Thu Sep 27 14:53:50 2007
@@ -23,6 +23,8 @@
import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+import org.apache.geronimo.gshell.whisper.request.RequestResponseFilter;
+import org.apache.geronimo.gshell.whisper.stream.SessionStreamFilter;
import org.apache.geronimo.gshell.whisper.transport.Transport;
import org.apache.geronimo.gshell.whisper.transport.TransportExceptionMonitor;
import org.apache.geronimo.gshell.whisper.transport.TransportServer;
@@ -178,11 +180,17 @@
log.debug("Configure: {}", chain);
- // For right now just add a few hard codded to test with
+ //
+ // HACK: For right now just add a few hard codded to test with
+ //
chain.addLast(ProtocolCodecFilter.class.getSimpleName(), new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
chain.addLast(LoggingFilter.class.getSimpleName(), new LoggingFilter());
+
+ chain.addLast(SessionStreamFilter.class.getSimpleName(), new SessionStreamFilter());
+
+ chain.addLast(RequestResponseFilter.class.getSimpleName(), new RequestResponseFilter());
}
protected void configure(final IoSession session) throws Exception {