geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r576612 [1/2] - 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/mai...
Date Mon, 17 Sep 2007 22:27:59 GMT
Author: jdillon
Date: Mon Sep 17 15:27:55 2007
New Revision: 576612

URL: http://svn.apache.org/viewvc?rev=576612&view=rev
Log:
Refactored to abstract the transport impl

Added:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientFactory.java
      - copied, changed from r575934, 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-common/src/main/java/org/apache/geronimo/gshell/remote/filter/
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/AuthenticationFilter.java   (contents, props changed)
      - copied, changed from r575934, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/AuthenticationFilter.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/LoggingFilter.java   (with props)
    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-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java
      - copied, changed from r575934, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RshProtocolHandlerSupport.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportServer.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpClientMessageVisitor.java
      - copied, changed from r575934, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpProtocolHandler.java
      - copied, changed from r575934, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RshProtocolHandlerSupport.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpServerMessageVisitor.java
      - copied, changed from r575934, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportServer.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerFactory.java   (with props)
Removed:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandler.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RshProtocolHandlerSupport.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/AuthenticationFilter.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandler.java
Modified:
    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-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

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=576612&r1=576611&r2=576612&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 Mon Sep 17 15:27:55 2007
@@ -21,34 +21,13 @@
 
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
+import java.net.URI;
 
-import org.apache.geronimo.gshell.remote.RshProtocolHandlerSupport;
 import org.apache.geronimo.gshell.remote.message.EchoMessage;
 import org.apache.geronimo.gshell.remote.message.HandShakeMessage;
 import org.apache.geronimo.gshell.remote.message.Message;
-import org.apache.geronimo.gshell.remote.message.MessageCodecFactory;
-import org.apache.geronimo.gshell.remote.ssl.BogusSSLContextFactory;
-import org.apache.mina.common.ConnectFuture;
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
-import org.apache.mina.common.IoEventType;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.common.WriteFuture;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.apache.mina.filter.logging.LoggingFilter;
-import org.apache.mina.filter.reqres.Request;
-import org.apache.mina.filter.reqres.RequestResponseFilter;
-import org.apache.mina.filter.reqres.Response;
-import org.apache.mina.filter.ssl.SSLFilter;
-import org.apache.mina.transport.socket.nio.SocketConnector;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.InstantiationStrategy;
-import org.codehaus.plexus.component.annotations.Requirement;
+import org.apache.geronimo.gshell.remote.transport.Transport;
+import org.apache.geronimo.gshell.remote.transport.TransportFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -57,156 +36,44 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role=RshClient.class, instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
 public class RshClient
 {
-    public static final int CONNECT_TIMEOUT = 3000;
-    
-    private Logger log = LoggerFactory.getLogger(getClass());
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @Requirement(role=IoHandler.class, hint="rsh-client")
-    private RshClientProtocolHandler handler;
+    private final Transport transport;
 
-    private boolean ssl = true;
-    
-    private InetSocketAddress address;
+    public RshClient(final URI location, final TransportFactory factory) throws Exception {
+        assert location != null;
+        assert factory != null;
 
-    private SocketConnector connector;
-
-    private IoSession session;
-
-    private boolean connected = false;
-
-    public void connect(final String hostname, final int port) throws Exception {
-        if (connected) {
-            throw new IllegalStateException("Already connected");
-        }
-
-        address = new InetSocketAddress(hostname, port);
-
-        handler.setVisitor(new RshClientMessageVisitor());
-
-        ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
-        connector = new SocketConnector(Runtime.getRuntime().availableProcessors(), executor);
-        
-        connector.setConnectTimeout(30);
-        connector.setHandler(handler);
-
-        DefaultIoFilterChainBuilder filterChain = connector.getFilterChain();
-
-        LoggingFilter loggingFilter = new LoggingFilter();
-        loggingFilter.setLogLevel(IoEventType.EXCEPTION_CAUGHT, LoggingFilter.WARN);
-        loggingFilter.setLogLevel(IoEventType.WRITE, LoggingFilter.TRACE);
-        loggingFilter.setLogLevel(IoEventType.MESSAGE_RECEIVED, LoggingFilter.TRACE);
-        loggingFilter.setLogLevel(IoEventType.MESSAGE_SENT, LoggingFilter.TRACE);
-        loggingFilter.setLogLevel(IoEventType.SESSION_CLOSED, LoggingFilter.DEBUG);
-        loggingFilter.setLogLevel(IoEventType.SESSION_CREATED, LoggingFilter.DEBUG);
-        loggingFilter.setLogLevel(IoEventType.SESSION_IDLE, LoggingFilter.DEBUG);
-        loggingFilter.setLogLevel(IoEventType.SESSION_OPENED, LoggingFilter.DEBUG);
-        filterChain.addLast("logger", loggingFilter);
-
-        filterChain.addLast("protocol", new ProtocolCodecFilter(new MessageCodecFactory()));
-
-        ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors());
-
-        filterChain.addLast("reqres", new RequestResponseFilter(handler.getResponseInspector(), scheduler));
-
-        if (ssl) {
-            SSLFilter sslFilter = new SSLFilter(BogusSSLContextFactory.getInstance(false));
-            sslFilter.setUseClientMode(true);
-            
-            filterChain.addFirst("ssl", sslFilter);
-        }
-
-        log.info("Connecting to: {}", address);
-
-        ConnectFuture cf = connector.connect(address);
-        if (cf.awaitUninterruptibly(CONNECT_TIMEOUT)) {
-             session = cf.getSession();
-        }
-        else {
-            throw new RuntimeException("Failed to connect");
-        }
-
-        log.info("Connected");
-        
-        connected = true;
-    }
-
-    public boolean isConnected() {
-        return connected;
-    }
-    
-    private void ensureConnected() {
-        if (!connected) {
-            throw new IllegalStateException("Not connected");
-        }
-
-        if (!session.isConnected()) {
-            throw new IllegalStateException("Session not connected");
-        }
-
-        if (session.isClosing()) {
-            throw new IllegalStateException("Session is closing");
-        }
+        transport = factory.connect(location);
     }
 
-    public void echo(final String text) {
-        ensureConnected();
-
+    public void echo(final String text) throws Exception {
         log.debug("Echoing: {}", text);
 
-        WriteFuture wf = session.write(new EchoMessage(text));
-
-        wf.awaitUninterruptibly();
-
-        if (!wf.isWritten()) {
-            log.error("Failed to send request; session did not fully write the message");
-        }
-    }
-
-    protected Response request(final Message msg, final long timeout, final TimeUnit unit) throws InterruptedException {
-        Request req = new Request(msg.getId(), msg, timeout, unit);
-
-        WriteFuture wf = session.write(req);
-        wf.awaitUninterruptibly();
-
-        if (!wf.isWritten()) {
-            log.error("Failed to send request; session did not fully write the message");
-        }
-
-        return req.awaitResponse();
+        transport.send(new EchoMessage(text));
     }
 
     public void handshake() throws Exception {
-        ensureConnected();
-
         log.info("Starting handshake");
-        
-        HandShakeMessage msg = new HandShakeMessage();
 
-        Response resp = request(msg, 5, TimeUnit.SECONDS);
+        Message resp = transport.request(new HandShakeMessage());
 
-        log.info("Response: {}", resp.getMessage());
+        log.info("Response: {}", resp);
     }
 
     public InputStream getInputStream() {
-        return (InputStream) session.getAttribute(RshProtocolHandlerSupport.INPUT_STREAM);
+        return transport.getInputStream();
     }
 
     public OutputStream getOutputStream() {
-        return (OutputStream) session.getAttribute(RshProtocolHandlerSupport.OUTPUT_STREAM);
+        return transport.getOutputStream();
     }
 
     public void close() {
-        if (isConnected()) {
-            session.close().awaitUninterruptibly();
-            
-            session = null;
-            connector = null;
-            address = null;
-            
-            connected = false;
-        }
+        transport.close();
+
+        log.debug("Closed");
     }
 }

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientFactory.java (from r575934, 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/RshClientFactory.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientFactory.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java&r1=575934&r2=576612&rev=576612&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/RshClientFactory.java Mon Sep 17 15:27:55 2007
@@ -19,194 +19,27 @@
 
 package org.apache.geronimo.gshell.remote.client;
 
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
+import java.net.URI;
 
-import org.apache.geronimo.gshell.remote.RshProtocolHandlerSupport;
-import org.apache.geronimo.gshell.remote.message.EchoMessage;
-import org.apache.geronimo.gshell.remote.message.HandShakeMessage;
-import org.apache.geronimo.gshell.remote.message.Message;
-import org.apache.geronimo.gshell.remote.message.MessageCodecFactory;
-import org.apache.geronimo.gshell.remote.ssl.BogusSSLContextFactory;
-import org.apache.mina.common.ConnectFuture;
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
-import org.apache.mina.common.IoEventType;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.common.WriteFuture;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.apache.mina.filter.logging.LoggingFilter;
-import org.apache.mina.filter.reqres.Request;
-import org.apache.mina.filter.reqres.RequestResponseFilter;
-import org.apache.mina.filter.reqres.Response;
-import org.apache.mina.filter.ssl.SSLFilter;
-import org.apache.mina.transport.socket.nio.SocketConnector;
+import org.apache.geronimo.gshell.remote.transport.TransportFactory;
+import org.apache.geronimo.gshell.remote.transport.TransportFactoryLocator;
 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;
 
 /**
  * ???
  *
  * @version $Rev$ $Date$
  */
-@Component(role=RshClient.class, instantiationStrategy=InstantiationStrategy.PER_LOOKUP)
-public class RshClient
+@Component(role=RshClientFactory.class)
+public class RshClientFactory
 {
-    public static final int CONNECT_TIMEOUT = 3000;
-    
-    private Logger log = LoggerFactory.getLogger(getClass());
+    @Requirement
+    private TransportFactoryLocator locator;
 
-    @Requirement(role=IoHandler.class, hint="rsh-client")
-    private RshClientProtocolHandler handler;
+    public RshClient connect(final URI location) throws Exception {
+        TransportFactory factory = locator.locate(location);
 
-    private boolean ssl = true;
-    
-    private InetSocketAddress address;
-
-    private SocketConnector connector;
-
-    private IoSession session;
-
-    private boolean connected = false;
-
-    public void connect(final String hostname, final int port) throws Exception {
-        if (connected) {
-            throw new IllegalStateException("Already connected");
-        }
-
-        address = new InetSocketAddress(hostname, port);
-
-        handler.setVisitor(new RshClientMessageVisitor());
-
-        ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
-        connector = new SocketConnector(Runtime.getRuntime().availableProcessors(), executor);
-        
-        connector.setConnectTimeout(30);
-        connector.setHandler(handler);
-
-        DefaultIoFilterChainBuilder filterChain = connector.getFilterChain();
-
-        LoggingFilter loggingFilter = new LoggingFilter();
-        loggingFilter.setLogLevel(IoEventType.EXCEPTION_CAUGHT, LoggingFilter.WARN);
-        loggingFilter.setLogLevel(IoEventType.WRITE, LoggingFilter.TRACE);
-        loggingFilter.setLogLevel(IoEventType.MESSAGE_RECEIVED, LoggingFilter.TRACE);
-        loggingFilter.setLogLevel(IoEventType.MESSAGE_SENT, LoggingFilter.TRACE);
-        loggingFilter.setLogLevel(IoEventType.SESSION_CLOSED, LoggingFilter.DEBUG);
-        loggingFilter.setLogLevel(IoEventType.SESSION_CREATED, LoggingFilter.DEBUG);
-        loggingFilter.setLogLevel(IoEventType.SESSION_IDLE, LoggingFilter.DEBUG);
-        loggingFilter.setLogLevel(IoEventType.SESSION_OPENED, LoggingFilter.DEBUG);
-        filterChain.addLast("logger", loggingFilter);
-
-        filterChain.addLast("protocol", new ProtocolCodecFilter(new MessageCodecFactory()));
-
-        ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors());
-
-        filterChain.addLast("reqres", new RequestResponseFilter(handler.getResponseInspector(), scheduler));
-
-        if (ssl) {
-            SSLFilter sslFilter = new SSLFilter(BogusSSLContextFactory.getInstance(false));
-            sslFilter.setUseClientMode(true);
-            
-            filterChain.addFirst("ssl", sslFilter);
-        }
-
-        log.info("Connecting to: {}", address);
-
-        ConnectFuture cf = connector.connect(address);
-        if (cf.awaitUninterruptibly(CONNECT_TIMEOUT)) {
-             session = cf.getSession();
-        }
-        else {
-            throw new RuntimeException("Failed to connect");
-        }
-
-        log.info("Connected");
-        
-        connected = true;
-    }
-
-    public boolean isConnected() {
-        return connected;
-    }
-    
-    private void ensureConnected() {
-        if (!connected) {
-            throw new IllegalStateException("Not connected");
-        }
-
-        if (!session.isConnected()) {
-            throw new IllegalStateException("Session not connected");
-        }
-
-        if (session.isClosing()) {
-            throw new IllegalStateException("Session is closing");
-        }
-    }
-
-    public void echo(final String text) {
-        ensureConnected();
-
-        log.debug("Echoing: {}", text);
-
-        WriteFuture wf = session.write(new EchoMessage(text));
-
-        wf.awaitUninterruptibly();
-
-        if (!wf.isWritten()) {
-            log.error("Failed to send request; session did not fully write the message");
-        }
-    }
-
-    protected Response request(final Message msg, final long timeout, final TimeUnit unit) throws InterruptedException {
-        Request req = new Request(msg.getId(), msg, timeout, unit);
-
-        WriteFuture wf = session.write(req);
-        wf.awaitUninterruptibly();
-
-        if (!wf.isWritten()) {
-            log.error("Failed to send request; session did not fully write the message");
-        }
-
-        return req.awaitResponse();
-    }
-
-    public void handshake() throws Exception {
-        ensureConnected();
-
-        log.info("Starting handshake");
-        
-        HandShakeMessage msg = new HandShakeMessage();
-
-        Response resp = request(msg, 5, TimeUnit.SECONDS);
-
-        log.info("Response: {}", resp.getMessage());
-    }
-
-    public InputStream getInputStream() {
-        return (InputStream) session.getAttribute(RshProtocolHandlerSupport.INPUT_STREAM);
-    }
-
-    public OutputStream getOutputStream() {
-        return (OutputStream) session.getAttribute(RshProtocolHandlerSupport.OUTPUT_STREAM);
-    }
-
-    public void close() {
-        if (isConnected()) {
-            session.close().awaitUninterruptibly();
-            
-            session = null;
-            connector = null;
-            address = null;
-            
-            connected = false;
-        }
+        return new RshClient(location, factory);
     }
 }

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=576612&r1=576611&r2=576612&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 Mon Sep 17 15:27:55 2007
@@ -24,6 +24,7 @@
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.net.URI;
 import java.util.Date;
 
 import org.apache.geronimo.gshell.command.CommandSupport;
@@ -39,20 +40,20 @@
 public class RshCommand
     extends CommandSupport
 {
-    //
-    // TODO: Use a URI
-    //
-    
-    private String hostname = "localhost";
-
-    private int port = 9999;
-
     @Requirement
+    private RshClientFactory factory;
+
     private RshClient client;
 
     protected Object doExecute() throws Exception {
-        client.connect(hostname, port);
+        URI location = new URI("ssl://localhost:9999");
+
+        io.out.println("Connecting to: " + location);
+
+        client = factory.connect(location);
 
+        io.out.println("Connected");
+        
         client.echo("TESTING");
 
         client.handshake();

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/AuthenticationFilter.java (from r575934, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/AuthenticationFilter.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/AuthenticationFilter.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/AuthenticationFilter.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/AuthenticationFilter.java&r1=575934&r2=576612&rev=576612&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/AuthenticationFilter.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/AuthenticationFilter.java Mon Sep 17 15:27:55 2007
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.remote.server;
+package org.apache.geronimo.gshell.remote.filter;
 
 import org.apache.mina.common.IoFilterAdapter;
 import org.slf4j.Logger;

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/AuthenticationFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/AuthenticationFilter.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/filter/AuthenticationFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/LoggingFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/LoggingFilter.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/LoggingFilter.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/LoggingFilter.java Mon Sep 17 15:27:55 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.remote.filter;
+
+import java.net.URI;
+import java.io.IOException;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.apache.mina.common.IoEventType;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class LoggingFilter
+    extends org.apache.mina.filter.logging.LoggingFilter
+{
+    public LoggingFilter() {
+        setLogLevel(IoEventType.EXCEPTION_CAUGHT, org.apache.mina.filter.logging.LoggingFilter.WARN);
+        setLogLevel(IoEventType.WRITE, org.apache.mina.filter.logging.LoggingFilter.TRACE);
+        setLogLevel(IoEventType.MESSAGE_RECEIVED, org.apache.mina.filter.logging.LoggingFilter.TRACE);
+        setLogLevel(IoEventType.MESSAGE_SENT, org.apache.mina.filter.logging.LoggingFilter.TRACE);
+        setLogLevel(IoEventType.SESSION_CLOSED, org.apache.mina.filter.logging.LoggingFilter.DEBUG);
+        setLogLevel(IoEventType.SESSION_CREATED, org.apache.mina.filter.logging.LoggingFilter.DEBUG);
+        setLogLevel(IoEventType.SESSION_IDLE, org.apache.mina.filter.logging.LoggingFilter.DEBUG);
+        setLogLevel(IoEventType.SESSION_OPENED, org.apache.mina.filter.logging.LoggingFilter.DEBUG);
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/LoggingFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/filter/LoggingFilter.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/filter/LoggingFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java (from r575934, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RshProtocolHandlerSupport.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/Transport.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RshProtocolHandlerSupport.java&r1=575934&r2=576612&rev=576612&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RshProtocolHandlerSupport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java Mon Sep 17 15:27:55 2007
@@ -17,143 +17,35 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.remote;
+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.stream.IoSessionInputStream;
-import org.apache.geronimo.gshell.remote.stream.IoSessionOutputStream;
-import org.apache.mina.common.IdleStatus;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.reqres.Request;
-import org.apache.mina.filter.reqres.Response;
-import org.apache.mina.filter.reqres.ResponseInspector;
-import org.codehaus.plexus.util.IOUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * ???
  *
  * @version $Rev$ $Date$
  */
-public abstract class RshProtocolHandlerSupport
-    implements IoHandler
+public interface Transport
 {
-    public static final String STREAM_BASENAME = "org.apache.geronimo.gshell.remote.stream.";
-
-    public static final String INPUT_STREAM = STREAM_BASENAME + "IN";
-
-    public static final String OUTPUT_STREAM = STREAM_BASENAME + "OUT";
-
-    public static final String ERROR_STREAM = STREAM_BASENAME + "ERR";
-
-    protected Logger log = LoggerFactory.getLogger(getClass());
-
-    protected MessageVisitor visitor;
-
-    protected MessageResponseInspector responseInspector = new MessageResponseInspector(); 
-
-    public MessageVisitor getVisitor() {
-        return visitor;
-    }
-
-    public void setVisitor(final MessageVisitor visitor) {
-        this.visitor = visitor;
-    }
-
-    public MessageResponseInspector getResponseInspector() {
-        return responseInspector;
-    }
-    
-    public void messageReceived(final IoSession session, final Object message) throws Exception {
-        assert session != null;
-        assert message != null;
-
-        if (message instanceof Message) {
-            Message msg = (Message)message;
-
-            if (visitor != null) {
-                msg.setAttachment(session);
-                msg.process(visitor);
-            }
-        }
-        else if (message instanceof Response) {
-            Response resp = (Response)message;
-
-            Request req = resp.getRequest();
-
-            responseInspector.deregister(req);
-        }
-        else {
-            log.error("Unhandled message: {}", message);
-        }
-    }
-
-    //
-    // IoHandler
-    //
-
-    public void sessionCreated(final IoSession session) throws Exception {
-        log.info("Session created: {}", session);
-    }
-
-    public void sessionOpened(final IoSession session) throws Exception {
-        log.info("Session opened: {}", session);
-
-        IoSessionInputStream in = new IoSessionInputStream();
-        session.setAttribute(INPUT_STREAM, in);
-
-        IoSessionOutputStream out = new IoSessionOutputStream(session);
-        session.setAttribute(OUTPUT_STREAM, out);
-
-        //
-        // TODO: Add err
-        //
-    }
-
-    public void sessionClosed(final IoSession session) throws Exception {
-        log.info("Session closed: {}", session);
-
-        IoSessionInputStream in = (IoSessionInputStream) session.getAttribute(INPUT_STREAM);
-        IOUtil.close(in);
-
-        IoSessionOutputStream out = (IoSessionOutputStream) session.getAttribute(OUTPUT_STREAM);
-        IOUtil.close(out);
-
-        //
-        // TODO: Add err
-        //
-    }
+    String STREAM_BASENAME = "org.apache.geronimo.gshell.remote.stream.";
 
-    public void sessionIdle(final IoSession session, final IdleStatus status) throws Exception {
-        log.info("Session idle: {}, status: {}", session, status);
+    String INPUT_STREAM = STREAM_BASENAME + "IN";
 
-        /*
-        if (status == IdleStatus.READER_IDLE) {
-            throw new SocketTimeoutException("Read timeout");
-        }
-        */
-    }
+    String OUTPUT_STREAM = STREAM_BASENAME + "OUT";
 
-    public void exceptionCaught(final IoSession session, final Throwable cause) throws Exception {
-        assert session != null;
-        assert cause != null;
+    String ERROR_STREAM = STREAM_BASENAME + "ERR";
 
-        log.error("Unhandled error: " + cause, cause);
+    void send(Message msg) throws Exception;
 
-        session.close();
-    }
+    Message request(Message msg) throws Exception;
 
-    public void messageSent(final IoSession session, final Object message) throws Exception {
-        log.info("Message sent: {}", message);
+    InputStream getInputStream();
 
-        if (message instanceof Request) {
-            Request req = (Request) message;
+    OutputStream getOutputStream();
 
-            responseInspector.register(req);
-        }
-    }
+    void close();
 }

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactory.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/TransportFactory.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactory.java Mon Sep 17 15:27:55 2007
@@ -0,0 +1,34 @@
+/*
+ * 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.transport;
+
+import java.net.URI;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TransportFactory
+{
+    Transport connect(final URI location) throws Exception;
+
+    TransportServer bind(final URI location) throws Exception;
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactory.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/transport/TransportFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.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/TransportFactoryLocator.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.java Mon Sep 17 15:27:55 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.transport;
+
+import java.net.URI;
+
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=TransportFactoryLocator.class)
+public class TransportFactoryLocator
+{
+    @Requirement
+    private PlexusContainer container;
+
+    public TransportFactory locate(final URI location) throws Exception {
+        assert location != null;
+
+        String scheme = location.getScheme();
+        if (scheme == null) {
+            throw new Exception("Invalid location; missing scheme: " + location);
+        }
+
+        TransportFactory factory = (TransportFactory) container.lookup(TransportFactory.class, scheme);
+
+        return factory;
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.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/transport/TransportFactoryLocator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.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/TransportServer.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java Mon Sep 17 15:27:55 2007
@@ -0,0 +1,30 @@
+/*
+ * 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.transport;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TransportServer
+{
+    void close();
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.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/transport/TransportServer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/package-info.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/package-info.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/package-info.java Mon Sep 17 15:27:55 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.remote.transport;
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/package-info.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/transport/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransport.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/ssl/SslTransport.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransport.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransport.java Mon Sep 17 15:27:55 2007
@@ -0,0 +1,55 @@
+/*
+ * 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.transport.ssl;
+
+import java.net.URI;
+
+import org.apache.geronimo.gshell.remote.transport.tcp.TcpTransport;
+import org.apache.geronimo.gshell.remote.ssl.BogusSSLContextFactory;
+import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.filter.ssl.SSLFilter;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class SslTransport
+    extends TcpTransport
+{
+    public SslTransport(final URI remote, final URI local) throws Exception {
+        super(remote, local);
+    }
+
+    protected void init() throws Exception {
+        super.init();
+
+        DefaultIoFilterChainBuilder filterChain = connector.getFilterChain();
+
+        //
+        // TODO: Get the SSL context factory injected
+        //
+        
+        SSLFilter sslFilter = new SSLFilter(BogusSSLContextFactory.getInstance(false));
+        sslFilter.setUseClientMode(true);
+
+        filterChain.addFirst("ssl", sslFilter);
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransport.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/transport/ssl/SslTransport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportFactory.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/ssl/SslTransportFactory.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportFactory.java Mon Sep 17 15:27:55 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.remote.transport.ssl;
+
+import java.net.URI;
+
+import org.apache.geronimo.gshell.remote.transport.TransportFactory;
+import org.apache.geronimo.gshell.remote.transport.tcp.TcpTransport;
+import org.apache.geronimo.gshell.remote.transport.tcp.TcpTransportFactory;
+import org.apache.geronimo.gshell.remote.transport.tcp.TcpTransportServer;
+import org.codehaus.plexus.component.annotations.Component;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=TransportFactory.class, hint="ssl")
+public class SslTransportFactory
+    extends TcpTransportFactory
+{
+    protected TcpTransport createTcpTransport(final URI location) throws Exception {
+        return new SslTransport(location, null);
+    }
+
+    protected TcpTransportServer createTransportServer(final URI location) throws Exception {
+        return new SslTransportServer(location);
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportFactory.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/transport/ssl/SslTransportFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportServer.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/ssl/SslTransportServer.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportServer.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportServer.java Mon Sep 17 15:27:55 2007
@@ -0,0 +1,53 @@
+/*
+ * 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.transport.ssl;
+
+import java.net.URI;
+
+import org.apache.geronimo.gshell.remote.transport.tcp.TcpTransportServer;
+import org.apache.geronimo.gshell.remote.ssl.BogusSSLContextFactory;
+import org.apache.mina.filter.ssl.SSLFilter;
+import org.apache.mina.common.DefaultIoFilterChainBuilder;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class SslTransportServer
+    extends TcpTransportServer
+{
+    public SslTransportServer(final URI location) throws Exception {
+        super(location);
+    }
+
+    protected void init() throws Exception {
+        super.init();
+        
+        DefaultIoFilterChainBuilder filterChain = acceptor.getFilterChain();
+
+        //
+        // TODO: Get the SSL context factory injected
+        //
+        
+        SSLFilter sslFilter = new SSLFilter(BogusSSLContextFactory.getInstance(true));
+        filterChain.addFirst("ssl", sslFilter);
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportServer.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/transport/ssl/SslTransportServer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/package-info.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/ssl/package-info.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/package-info.java Mon Sep 17 15:27:55 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.remote.transport.ssl;
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/package-info.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/transport/ssl/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpClientMessageVisitor.java (from r575934, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.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/tcp/TcpClientMessageVisitor.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpClientMessageVisitor.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.java&r1=575934&r2=576612&rev=576612&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpClientMessageVisitor.java Mon Sep 17 15:27:55 2007
@@ -17,14 +17,15 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.remote.client;
+package org.apache.geronimo.gshell.remote.transport.tcp;
 
-import org.apache.geronimo.gshell.remote.RshProtocolHandlerSupport;
 import org.apache.geronimo.gshell.remote.message.EchoMessage;
 import org.apache.geronimo.gshell.remote.message.MessageVisitorAdapter;
 import org.apache.geronimo.gshell.remote.message.WriteStreamMessage;
 import org.apache.geronimo.gshell.remote.stream.IoSessionInputStream;
+import org.apache.geronimo.gshell.remote.transport.Transport;
 import org.apache.mina.common.IoSession;
+import org.codehaus.plexus.component.annotations.Component;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,11 +34,12 @@
  *
  * @version $Rev$ $Date$
  */
-public class RshClientMessageVisitor
+@Component(role=TcpClientMessageVisitor.class)
+public class TcpClientMessageVisitor
     extends MessageVisitorAdapter
 {
     private Logger log = LoggerFactory.getLogger(getClass());
-    
+
     public void visitEcho(final EchoMessage msg) {
         assert msg != null;
 
@@ -51,7 +53,7 @@
         assert session != null;
 
         // Look up the bound stream in the session context
-        String key = RshProtocolHandlerSupport.STREAM_BASENAME + msg.getName();
+        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

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpProtocolHandler.java (from r575934, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RshProtocolHandlerSupport.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/tcp/TcpProtocolHandler.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpProtocolHandler.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RshProtocolHandlerSupport.java&r1=575934&r2=576612&rev=576612&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/RshProtocolHandlerSupport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpProtocolHandler.java Mon Sep 17 15:27:55 2007
@@ -17,19 +17,20 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.remote;
+package org.apache.geronimo.gshell.remote.transport.tcp;
 
 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.stream.IoSessionInputStream;
 import org.apache.geronimo.gshell.remote.stream.IoSessionOutputStream;
+import org.apache.geronimo.gshell.remote.transport.Transport;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.reqres.Request;
 import org.apache.mina.filter.reqres.Response;
-import org.apache.mina.filter.reqres.ResponseInspector;
+import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.util.IOUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,22 +40,15 @@
  *
  * @version $Rev$ $Date$
  */
-public abstract class RshProtocolHandlerSupport
+@Component(role=TcpProtocolHandler.class)
+public class TcpProtocolHandler
     implements IoHandler
 {
-    public static final String STREAM_BASENAME = "org.apache.geronimo.gshell.remote.stream.";
-
-    public static final String INPUT_STREAM = STREAM_BASENAME + "IN";
-
-    public static final String OUTPUT_STREAM = STREAM_BASENAME + "OUT";
-
-    public static final String ERROR_STREAM = STREAM_BASENAME + "ERR";
-
     protected Logger log = LoggerFactory.getLogger(getClass());
 
     protected MessageVisitor visitor;
 
-    protected MessageResponseInspector responseInspector = new MessageResponseInspector(); 
+    protected MessageResponseInspector responseInspector = new MessageResponseInspector();
 
     public MessageVisitor getVisitor() {
         return visitor;
@@ -67,7 +61,7 @@
     public MessageResponseInspector getResponseInspector() {
         return responseInspector;
     }
-    
+
     public void messageReceived(final IoSession session, final Object message) throws Exception {
         assert session != null;
         assert message != null;
@@ -104,10 +98,10 @@
         log.info("Session opened: {}", session);
 
         IoSessionInputStream in = new IoSessionInputStream();
-        session.setAttribute(INPUT_STREAM, in);
+        session.setAttribute(Transport.INPUT_STREAM, in);
 
         IoSessionOutputStream out = new IoSessionOutputStream(session);
-        session.setAttribute(OUTPUT_STREAM, out);
+        session.setAttribute(Transport.OUTPUT_STREAM, out);
 
         //
         // TODO: Add err
@@ -117,10 +111,10 @@
     public void sessionClosed(final IoSession session) throws Exception {
         log.info("Session closed: {}", session);
 
-        IoSessionInputStream in = (IoSessionInputStream) session.getAttribute(INPUT_STREAM);
+        IoSessionInputStream in = (IoSessionInputStream) session.getAttribute(Transport.INPUT_STREAM);
         IOUtil.close(in);
 
-        IoSessionOutputStream out = (IoSessionOutputStream) session.getAttribute(OUTPUT_STREAM);
+        IoSessionOutputStream out = (IoSessionOutputStream) session.getAttribute(Transport.OUTPUT_STREAM);
         IOUtil.close(out);
 
         //

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpServerMessageVisitor.java (from r575934, 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-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpServerMessageVisitor.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpServerMessageVisitor.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java&r1=575934&r2=576612&rev=576612&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-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpServerMessageVisitor.java Mon Sep 17 15:27:55 2007
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.remote.server;
+package org.apache.geronimo.gshell.remote.transport.tcp;
 
 import java.io.BufferedReader;
 import java.io.InputStream;
@@ -26,14 +26,15 @@
 import java.io.PrintWriter;
 import java.util.Date;
 
-import org.apache.geronimo.gshell.remote.RshProtocolHandlerSupport;
 import org.apache.geronimo.gshell.remote.message.EchoMessage;
 import org.apache.geronimo.gshell.remote.message.HandShakeMessage;
 import org.apache.geronimo.gshell.remote.message.MessageVisitorAdapter;
 import org.apache.geronimo.gshell.remote.message.WriteStreamMessage;
 import org.apache.geronimo.gshell.remote.stream.IoSessionInputStream;
+import org.apache.geronimo.gshell.remote.transport.Transport;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
+import org.codehaus.plexus.component.annotations.Component;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,7 +43,8 @@
  *
  * @version $Rev$ $Date$
  */
-public class RshServerMessageVisitor
+@Component(role=TcpServerMessageVisitor.class)
+public class TcpServerMessageVisitor
     extends MessageVisitorAdapter
 {
     private Logger log = LoggerFactory.getLogger(getClass());
@@ -52,7 +54,7 @@
 
         final IoSession session = (IoSession) msg.getAttachment();
         assert session != null;
-        
+
         String text = msg.getText();
 
         //
@@ -60,10 +62,10 @@
         //
 
         if ("READ_STREAMS".equals(text)) {
-            OutputStream out = (OutputStream) session.getAttribute(RshProtocolHandlerSupport.OUTPUT_STREAM);
+            OutputStream out = (OutputStream) session.getAttribute(Transport.OUTPUT_STREAM);
             final PrintWriter writer = new PrintWriter(out);
 
-            InputStream in = (InputStream) session.getAttribute(RshProtocolHandlerSupport.INPUT_STREAM);
+            InputStream in = (InputStream) session.getAttribute(Transport.INPUT_STREAM);
             final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
 
             Thread t = new Thread("Stream Consumer") {
@@ -75,7 +77,7 @@
                         while ((line = reader.readLine()) != null) {
                             System.err.println(line);
                         }
-                        
+
                         log.debug("Consumer stopped");
                     }
                     catch (Exception e) {
@@ -117,7 +119,7 @@
         assert msg != null;
 
         log.info("HANDSHAKE");
-        
+
         IoSession session = (IoSession) msg.getAttachment();
         assert session != null;
 
@@ -135,7 +137,7 @@
         assert session != null;
 
         // Look up the bound stream in the session context
-        String key = RshProtocolHandlerSupport.STREAM_BASENAME + msg.getName();
+        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

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.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/tcp/TcpTransport.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java Mon Sep 17 15:27:55 2007
@@ -0,0 +1,214 @@
+/*
+ * 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.transport.tcp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.geronimo.gshell.remote.filter.LoggingFilter;
+import org.apache.geronimo.gshell.remote.message.Message;
+import org.apache.geronimo.gshell.remote.message.MessageCodecFactory;
+import org.apache.geronimo.gshell.remote.transport.Transport;
+import org.apache.mina.common.CloseFuture;
+import org.apache.mina.common.ConnectFuture;
+import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.WriteFuture;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.reqres.Request;
+import org.apache.mina.filter.reqres.RequestResponseFilter;
+import org.apache.mina.filter.reqres.Response;
+import org.apache.mina.transport.socket.nio.SocketConnector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class TcpTransport
+    implements Transport
+{
+    private static final int CONNECT_TIMEOUT = 3000;
+
+    protected Logger log = LoggerFactory.getLogger(getClass());
+
+    protected TcpClientMessageVisitor messageVisitor;
+
+    protected TcpProtocolHandler protocolHandler;
+
+    protected URI remoteLocation;
+
+    protected InetSocketAddress remoteAddress;
+
+    protected URI localLocation;
+
+    protected InetSocketAddress localAddress;
+
+    protected SocketConnector connector;
+
+    protected IoSession session;
+
+    protected boolean connected;
+
+    public TcpTransport(final URI remote, final URI local) throws Exception {
+        assert remote != null;
+        // local may be null
+
+        this.remoteLocation = remote;
+        this.remoteAddress = new InetSocketAddress(InetAddress.getByName(remote.getHost()), remote.getPort());
+
+        if (local != null) {
+            this.localLocation = local;
+            this.localAddress = new InetSocketAddress(InetAddress.getByName(local.getHost()), local.getPort());
+        }
+    }
+
+    protected void init() throws Exception {
+        if (protocolHandler == null) {
+            throw new IllegalStateException("Protocol handler not injected");
+        }
+        if (messageVisitor == null) {
+            throw new IllegalStateException("Message visitor not injected");
+        }
+        
+        protocolHandler.setVisitor(messageVisitor);
+
+        ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
+
+        connector = new SocketConnector(Runtime.getRuntime().availableProcessors(), executor);
+        connector.setConnectTimeout(30);
+        connector.setHandler(protocolHandler);
+
+        DefaultIoFilterChainBuilder filterChain = connector.getFilterChain();
+
+        filterChain.addLast("logger", new LoggingFilter());
+
+        filterChain.addLast("protocol", new ProtocolCodecFilter(new MessageCodecFactory()));
+
+        ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors());
+
+        filterChain.addLast("reqres", new RequestResponseFilter(protocolHandler.getResponseInspector(), scheduler));
+    }
+
+    //
+    // NOTE: Setters exposed to support Plexus autowire()
+    //
+
+    public void setMessageVisitor(final TcpClientMessageVisitor messageVisitor) {
+        log.debug("Using message visitor: {}", messageVisitor);
+
+        this.messageVisitor = messageVisitor;
+    }
+
+    public void setProtocolHandler(final TcpProtocolHandler protocolHandler) {
+        log.debug("Using protocol handler: {}", protocolHandler);
+
+        this.protocolHandler = protocolHandler;
+    }
+
+    public void connect() throws Exception {
+        if (connected) {
+            throw new IllegalStateException("Already connected");
+        }
+        
+        init();
+
+        log.info("Connecting to: {}", remoteAddress);
+
+        ConnectFuture cf = connector.connect(remoteAddress, localAddress);
+
+        if (cf.awaitUninterruptibly(CONNECT_TIMEOUT)) {
+             session = cf.getSession();
+        }
+        else {
+            throw new Exception("Failed to connect");
+        }
+
+        connected = true;
+        
+        log.info("Connected");
+    }
+
+    public URI getRemoteLocation() {
+        return remoteLocation;
+    }
+
+    public URI getLocalLocation() {
+        return localLocation;
+    }
+
+    //
+    // Transport
+    //
+
+    private void doSend(final Object msg) throws Exception {
+        assert msg != null;
+
+        WriteFuture wf = session.write(msg);
+
+        wf.awaitUninterruptibly();
+
+        if (!wf.isWritten()) {
+            throw new IOException("Session did not fully write the message");
+        }
+    }
+
+    public void send(final Message msg) throws Exception {
+        assert msg != null;
+
+        doSend(msg);
+    }
+
+    public Message request(final Message msg) throws Exception {
+        assert msg != null;
+
+        Request req = new Request(msg.getId(), msg, 1, TimeUnit.SECONDS);
+
+        doSend(req);
+
+        Response resp = req.awaitResponse();
+
+        return (Message) resp.getMessage();
+    }
+
+    public InputStream getInputStream() {
+        return (InputStream) session.getAttribute(Transport.INPUT_STREAM);
+    }
+
+    public OutputStream getOutputStream() {
+        return (OutputStream) session.getAttribute(Transport.OUTPUT_STREAM);
+    }
+
+    public void close() {
+        CloseFuture cf = session.close();
+
+        cf.awaitUninterruptibly();
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.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/transport/tcp/TcpTransport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportFactory.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/tcp/TcpTransportFactory.java?rev=576612&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportFactory.java Mon Sep 17 15:27:55 2007
@@ -0,0 +1,74 @@
+/*
+ * 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.transport.tcp;
+
+import java.net.URI;
+
+import org.apache.geronimo.gshell.remote.transport.Transport;
+import org.apache.geronimo.gshell.remote.transport.TransportFactory;
+import org.apache.geronimo.gshell.remote.transport.TransportServer;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=TransportFactory.class, hint="tcp")
+public class TcpTransportFactory
+    implements TransportFactory
+{
+    @Requirement
+    private PlexusContainer container;
+
+    public Transport connect(final URI location) throws Exception {
+        assert location != null;
+
+        TcpTransport transport = createTcpTransport(location);
+
+        container.autowire(transport);
+
+        transport.connect();
+
+        return transport;
+    }
+
+    protected TcpTransport createTcpTransport(final URI location) throws Exception {
+        return new TcpTransport(location, null);
+    }
+
+    public TransportServer bind(final URI location) throws Exception {
+        assert location != null;
+
+        TcpTransportServer server = createTransportServer(location);
+
+        container.autowire(server);
+
+        server.bind();
+
+        return server;
+    }
+
+    protected TcpTransportServer createTransportServer(final URI location) throws Exception {
+        return new TcpTransportServer(location);
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportFactory.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/transport/tcp/TcpTransportFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message