geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r577587 - 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/codec/ gshell-remote-common/src/...
Date Thu, 20 Sep 2007 07:06:37 GMT
Author: jdillon
Date: Thu Sep 20 00:06:36 2007
New Revision: 577587

URL: http://svn.apache.org/viewvc?rev=577587&view=rev
Log:
Updated to use Mina 1.1.2... which fricken works!!!! Yay... happy birthday to me :-P

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-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MarshallingUtil.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MessageCodecFactory.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/logging/LoggingFilter.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.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/request/RequestResponseFilter.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Requestor.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/security/SecurityFilter.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionStreamFilter.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportCommon.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransport.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportServer.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportServer.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/pom.xml

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=577587&r1=577586&r2=577587&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 20 00:06:36 2007
@@ -71,13 +71,9 @@
         
         client.openShell();
 
-        //
-        // HACK: Turn this off for the moment to test more...
-        //
-        
         // Copy the client's input stream to our outputstream so users see command output
-        // outputFeeder = new StreamFeeder(client.getInputStream(), io.outputStream);
-        // outputFeeder.createThread().start();
+        outputFeeder = new StreamFeeder(client.getInputStream(), io.outputStream);
+        outputFeeder.createThread().start();
 
         opened = true;
     }
@@ -105,18 +101,17 @@
     }
 
     public void close() {
-        // outputFeeder.close();
+        try {
+            outputFeeder.close();
+        }
+        catch (Exception ignore) {}
 
         try {
             client.closeShell();
         }
-        catch (Exception e) {
-            log.error("Failure occured while closing remote shell; ignoring", e);
-        }
+        catch (Exception ignore) {}
 
         opened = false;
-        
-        log.info("Closed");
     }
 
     //

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=577587&r1=577586&r2=577587&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 20 00:06:36 2007
@@ -170,7 +170,5 @@
 
     public void close() {
         transport.close();
-
-        log.debug("Closed");
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MarshallingUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MarshallingUtil.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MarshallingUtil.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MarshallingUtil.java
Thu Sep 20 00:06:36 2007
@@ -243,4 +243,32 @@
             out.putLong(uuid.getLeastSignificantBits());
         }
     }
+
+    //
+    // Enum Serialization (adapted from Mina 2.x)
+    //
+
+    public static ByteBuffer writeEnum(final ByteBuffer out, Enum<?> e) {
+        if (e.ordinal() > Byte.MAX_VALUE) {
+            throw new IllegalArgumentException(enumConversionErrorMessage(e, "byte"));
+        }
+
+        return out.put((byte) e.ordinal());
+    }
+
+    public static <E extends Enum<E>> E readEnum(final ByteBuffer in, final Class<E>
enumClass) {
+        return toEnum(enumClass, in.get());
+    }
+    
+    private static <E> E toEnum(Class<E> enumClass, int i) {
+        E[] enumConstants = enumClass.getEnumConstants();
+        if (i > enumConstants.length) {
+            throw new IndexOutOfBoundsException(String.format("%d is too large of an ordinal
to convert to the enum %s", i, enumClass.getName()));
+        }
+        return enumConstants[i];
+    }
+
+    private static String enumConversionErrorMessage(Enum<?> e, String type) {
+        return String.format("%s.%s has an ordinal value too large for a %s", e.getClass().getName(),
e.name(), type);
+    }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MessageCodecFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MessageCodecFactory.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MessageCodecFactory.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/codec/MessageCodecFactory.java
Thu Sep 20 00:06:36 2007
@@ -23,12 +23,15 @@
 import java.nio.channels.Channels;
 import java.nio.channels.WritableByteChannel;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.geronimo.gshell.remote.crypto.CryptoContext;
 import org.apache.geronimo.gshell.remote.crypto.CryptoContextAware;
 import org.apache.geronimo.gshell.remote.message.Message;
 import org.apache.geronimo.gshell.remote.message.MessageType;
+import org.apache.geronimo.gshell.remote.request.Request;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecException;
@@ -36,7 +39,6 @@
 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 import org.apache.mina.filter.codec.demux.DemuxingProtocolCodecFactory;
 import org.apache.mina.filter.codec.demux.MessageDecoder;
-import org.apache.mina.filter.codec.demux.MessageDecoderAdapter;
 import org.apache.mina.filter.codec.demux.MessageDecoderFactory;
 import org.apache.mina.filter.codec.demux.MessageDecoderResult;
 import org.apache.mina.filter.codec.demux.MessageEncoder;
@@ -71,9 +73,11 @@
     private CryptoContext crypto;
 
     public MessageCodecFactory() {
+        register(new EncoderFactory());
+        
         register(new DecoderFactory());
 
-        register(new EncoderFactory());
+        register(new RequestEncoderFactory());
     }
 
     private void attachCryptoContext(final Message msg) {
@@ -135,7 +139,7 @@
 
         writeVersion(out);
 
-        out.putEnum(msg.getType());
+        MarshallingUtil.writeEnum(out, msg.getType());
 
         // Determine the length of the message body
         out.mark();
@@ -182,7 +186,7 @@
     public class Encoder
         implements MessageEncoder
     {
-        public Set getMessageTypes() {
+        public Set<Class<?>> getMessageTypes() {
             return MessageType.types();
         }
 
@@ -218,7 +222,7 @@
     }
 
     public class Decoder
-        extends MessageDecoderAdapter
+        implements MessageDecoder
     {
         public MessageDecoderResult decodable(final IoSession session, final ByteBuffer in)
{
             assert session != null;
@@ -233,7 +237,7 @@
 
                 readVersion(in);
 
-                MessageType type = in.getEnum(MessageType.class);
+                MessageType type = MarshallingUtil.readEnum(in, MessageType.class);
 
                 if (type == null) {
                     return MessageDecoderResult.NOT_OK;
@@ -262,7 +266,7 @@
 
             readVersion(in);
 
-            MessageType type = in.getEnum(MessageType.class);
+            MessageType type = MarshallingUtil.readEnum(in, MessageType.class);
 
             Message msg = MessageType.create(type);
 
@@ -279,6 +283,40 @@
             out.write(msg);
 
             return MessageDecoderResult.OK;
+        }
+
+        public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws Exception
{}
+    }
+
+    //
+    // RequestEncoder
+    //
+
+    public class RequestEncoderFactory
+        implements MessageEncoderFactory
+    {
+        public MessageEncoder getEncoder() throws Exception {
+            return new RequestEncoder();
+        }
+    }
+
+    public class RequestEncoder
+        extends Encoder
+    {
+        public Set<Class<?>> getMessageTypes() {
+            Set<Class<?>> types = new HashSet<Class<?>>();
+
+            types.add(Request.class);
+
+            return Collections.unmodifiableSet(types);
+        }
+
+        public void encode(final IoSession session, final Object message, final ProtocolEncoderOutput
out) throws Exception {
+            Request request = (Request) message;
+
+            Message msg = request.getMessage();
+
+            super.encode(session, msg, out);
         }
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/logging/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/logging/LoggingFilter.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/logging/LoggingFilter.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/logging/LoggingFilter.java
Thu Sep 20 00:06:36 2007
@@ -19,16 +19,15 @@
 
 package org.apache.geronimo.gshell.remote.logging;
 
-import org.apache.mina.common.IoEventType;
-
 /**
- * Custom logging filter to setup some better levels.
+ * ???
  *
  * @version $Rev$ $Date$
  */
 public class LoggingFilter
-    extends org.apache.mina.filter.logging.LoggingFilter
+    extends org.apache.mina.filter.LoggingFilter
 {
+    /*
     public LoggingFilter() {
         setLogLevel(IoEventType.EXCEPTION_CAUGHT,   WARN);
         setLogLevel(IoEventType.MESSAGE_RECEIVED,   DEBUG);
@@ -40,4 +39,5 @@
         setLogLevel(IoEventType.WRITE,              DEBUG);
         setLogLevel(IoEventType.CLOSE,              DEBUG);
     }
+    */
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ExecuteMessage.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/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 20 00:06:36 2007
@@ -72,7 +72,7 @@
 
         super.readExternal(in);
 
-        this.flavor = in.getEnum(Flavor.class);
+        this.flavor = MarshallingUtil.readEnum(in, Flavor.class);
 
         this.path = MarshallingUtil.readString(in);
 
@@ -84,7 +84,7 @@
 
         super.writeExternal(out);
 
-        out.putEnum(flavor);
+        MarshallingUtil.writeEnum(out, flavor);
 
         MarshallingUtil.writeString(out, path);
 

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageType.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/MessageType.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageType.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageType.java
Thu Sep 20 00:06:36 2007
@@ -74,8 +74,8 @@
         }
     }
 
-    public static Set<Class> types() {
-        Set<Class> set = new HashSet<Class>();
+    public static Set<Class<?>> types() {
+        Set<Class<?>> set = new HashSet<Class<?>>();
 
         for (MessageType type : values()) {
             set.add(type.type);

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestResponseFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestResponseFilter.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestResponseFilter.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestResponseFilter.java
Thu Sep 20 00:06:36 2007
@@ -25,8 +25,6 @@
 import org.apache.geronimo.gshell.remote.message.Message;
 import org.apache.mina.common.IoFilterAdapter;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.common.WriteRequest;
-import org.apache.mina.common.WriteRequestWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -70,6 +68,20 @@
         nextFilter.sessionClosed(session);
     }
 
+    public void filterWrite(final NextFilter nextFilter, final IoSession session, final WriteRequest
writeRequest) throws Exception {
+        Object message = writeRequest.getMessage();
+
+        if (message instanceof Request) {
+            // Register the request with the manager
+            Request request = (Request) message;
+
+            RequestManager manager = RequestManager.lookup(session);
+            manager.add(request);
+        }
+
+        nextFilter.filterWrite(session, writeRequest);
+    }
+
     public void messageReceived(final NextFilter nextFilter, final IoSession session, final
Object message) throws Exception {
         Message msg = null;
 
@@ -109,23 +121,7 @@
         }
     }
 
-    public void filterWrite(final NextFilter nextFilter, final IoSession session, final WriteRequest
writeRequest) throws Exception {
-        Object message = writeRequest.getMessage();
-
-        if (message instanceof Request) {
-            // Register the request with the manager
-            Request request = (Request) message;
-
-            RequestManager manager = RequestManager.lookup(session);
-            manager.add(request);
-
-            nextFilter.filterWrite(session, new RequestWriteRequest(writeRequest));
-        }
-        else {
-            nextFilter.filterWrite(session, writeRequest);
-        }
-    }
-
+    /*
     public void messageSent(final NextFilter nextFilter, final IoSession session, final WriteRequest
writeRequest) throws Exception {
         if (writeRequest instanceof RequestWriteRequest) {
             // Setup a timeout for the request now that its been sent
@@ -142,20 +138,17 @@
             nextFilter.messageSent(session, writeRequest);
         }
     }
+    */
 
-    private static class RequestWriteRequest
-        extends WriteRequestWrapper
-    {
-        public RequestWriteRequest(final WriteRequest wr) {
-            super(wr);
-        }
+    public void messageSent(NextFilter nextFilter, IoSession session, Object message) throws
Exception {
+        if (message instanceof Request) {
+            Request request = (Request) message;
 
-        public Object getMessage() {
-            return ((Request) super.getMessage()).getMessage();
-        }
+            RequestManager manager = RequestManager.lookup(session);
 
-        public Request getRequest() {
-            return (Request) super.getWriteRequest().getMessage();
+            manager.schedule(request);
         }
+
+        nextFilter.messageSent(session, message);
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Requestor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Requestor.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Requestor.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Requestor.java
Thu Sep 20 00:06:36 2007
@@ -190,50 +190,24 @@
             return delegate.getSession();
         }
 
-        public WriteFuture await() throws InterruptedException {
-            return delegate.await();
-        }
-
-        public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
-            return delegate.await(timeout, unit);
-        }
-
-        public boolean await(long timeoutMillis) throws InterruptedException {
-            return delegate.await(timeoutMillis);
-        }
-
-        public WriteFuture awaitUninterruptibly() {
-            return delegate.awaitUninterruptibly();
-        }
-
-        public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
-            return delegate.awaitUninterruptibly(timeout, unit);
-        }
-
-        public boolean awaitUninterruptibly(long timeoutMillis) {
-            return delegate.awaitUninterruptibly(timeoutMillis);
-        }
-
-        @Deprecated
         public void join() {
             delegate.join();
         }
 
-        @Deprecated
-        public boolean join(long timeoutMillis) {
-            return delegate.join(timeoutMillis);
+        public boolean join(long timeoutInMillis) {
+            return delegate.join(timeoutInMillis);
         }
 
         public boolean isReady() {
             return delegate.isReady();
         }
 
-        public WriteFuture addListener(IoFutureListener listener) {
-            return delegate.addListener(listener);
+        public void addListener(IoFutureListener listener) {
+            delegate.addListener(listener);
         }
 
-        public WriteFuture removeListener(IoFutureListener listener) {
-            return delegate.removeListener(listener);
+        public void removeListener(IoFutureListener listener) {
+            delegate.removeListener(listener);
         }
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/security/SecurityFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/security/SecurityFilter.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/security/SecurityFilter.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/security/SecurityFilter.java
Thu Sep 20 00:06:36 2007
@@ -76,16 +76,19 @@
 
         securityToken = UUID.randomUUID();
     }
-    
+
+    @Override
     public void init() throws Exception {
         // Install the schedule purger to purge any cancelled tasks to prevent memory leaks
         scheduler.scheduleWithFixedDelay(new SchedulePurgerTask(), 10, 10, TimeUnit.SECONDS);
     }
 
+    @Override
     public void destroy() throws Exception {
         scheduler.shutdownNow();
     }
 
+    @Override
     public void sessionOpened(final NextFilter nextFilter, final IoSession session) throws
Exception {
         assert nextFilter != null;
         assert session != null;
@@ -96,6 +99,7 @@
         nextFilter.sessionOpened(session);
     }
 
+    @Override
     public void messageReceived(final NextFilter nextFilter, final IoSession session, final
Object obj) throws Exception {
         assert nextFilter != null;
         assert session != null;

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
Thu Sep 20 00:06:36 2007
@@ -123,7 +123,7 @@
                 public void run() {
                     log.debug("Waiting for full write");
 
-                    wf.awaitUninterruptibly();
+                    wf.join();
 
                     log.debug("Completed; written: {}", wf.isWritten());
                 }
@@ -145,7 +145,7 @@
             WriteFuture wf = lastWriteFuture;
             lastWriteFuture = null;
 
-            wf.awaitUninterruptibly();
+            wf.join();
 
             if (!wf.isWritten()) {
                 throw new IOException("Failed to fully write bytes to the session");

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionStreamFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionStreamFilter.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionStreamFilter.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionStreamFilter.java
Thu Sep 20 00:06:36 2007
@@ -25,9 +25,6 @@
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.IoFilterAdapter;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.common.IoSessionConfig;
-import org.apache.mina.common.IoFilter;
-import org.apache.mina.common.WriteRequest;
 import org.codehaus.plexus.util.IOUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -58,6 +55,7 @@
     // TODO: See if we need to put the executor into the session context
     //
 
+    @Override
     public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception
{
         log.debug("Binding session streams");
 
@@ -68,17 +66,7 @@
         nextFilter.sessionCreated(session);
     }
 
-    /*
-    public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception
{
-        IoSessionConfig config = session.getConfig();
-
-        config.setWriteTimeout(60);
-        config.setIdleTime(IdleStatus.READER_IDLE, 60);
-
-        nextFilter.sessionOpened(session);
-    }
-    */
-    
+    @Override
     public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception
{
         log.debug("Unbinding session streams");
 
@@ -89,18 +77,21 @@
         nextFilter.sessionClosed(session);
     }
 
+    @Override
     public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status)
throws Exception {
         log.debug("Session idle: {}, status: {}", session, status);
 
         nextFilter.sessionIdle(session, status);
     }
 
+    @Override
     public void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable cause)
throws Exception {
         log.debug("Exception caught: " + session + ", cause: " + cause, cause);
 
         nextFilter.exceptionCaught(session, cause);
     }
 
+    @Override
     public void messageReceived(final NextFilter nextFilter, final IoSession session, final
Object message) throws Exception {
         if (message instanceof WriteStreamMessage) {
             final WriteStreamMessage msg = (WriteStreamMessage) message;
@@ -117,7 +108,9 @@
                 }
             };
 
-            executor.execute(task);
+            task.run();
+
+            // executor.execute(task);
 
             // There is no need to pass on this message to any other filters, they have no
use for it...
         }
@@ -126,9 +119,8 @@
         }
     }
 
-    public void messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
throws Exception {
-        Object message = writeRequest.getMessage();
-
+    @Override
+    public void messageSent(NextFilter nextFilter, IoSession session, Object message) throws
Exception {
         if (message instanceof WriteStreamMessage) {
             log.debug("Message sent: {}, msg: {}", session, message);
 
@@ -137,6 +129,6 @@
             //
         }
 
-        nextFilter.messageSent(session, writeRequest);
+        nextFilter.messageSent(session, message);
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ProtocolHandler.java
Thu Sep 20 00:06:36 2007
@@ -52,7 +52,7 @@
     //
     // TODO: Do we need to stuff the visitor into the session context?
     //
-    
+
     public void sessionCreated(IoSession session) throws Exception {
         log.debug("Session created: {}", session);
     }
@@ -64,7 +64,7 @@
     public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
         log.debug("Session idle: {}, status: {}", session, status);
     }
-    
+
     public void sessionClosed(final IoSession session) throws Exception {
         log.debug("Session closed: {}", session);
     }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportCommon.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/TransportCommon.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportCommon.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportCommon.java
Thu Sep 20 00:06:36 2007
@@ -26,9 +26,11 @@
 import org.apache.geronimo.gshell.remote.message.MessageVisitor;
 import org.apache.geronimo.gshell.remote.request.RequestResponseFilter;
 import org.apache.geronimo.gshell.remote.stream.SessionStreamFilter;
+import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoService;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.common.SimpleByteBufferAllocator;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.management.IoSessionStat;
 import org.apache.mina.management.StatCollector;
@@ -62,6 +64,9 @@
     private MessageCodecFactory codecFactory;
 
     protected TransportCommon() {
+        ByteBuffer.setUseDirectBuffers(false);
+        ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
+        
         //
         // TODO: Add custom thread factory ?
         //
@@ -88,7 +93,7 @@
 
         handler.setVisitor(visitor);
         
-        service.setHandler(handler);
+        // service.setHandler(handler);
 
         DefaultIoFilterChainBuilder filterChain = service.getFilterChain();
         

Modified: 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=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransport.java
Thu Sep 20 00:06:36 2007
@@ -24,8 +24,8 @@
 import org.apache.geronimo.gshell.remote.ssl.SSLContextFactory;
 import org.apache.geronimo.gshell.remote.transport.tcp.TcpTransport;
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.filter.SSLFilter;
 import org.apache.mina.filter.executor.ExecutorFilter;
-import org.apache.mina.filter.ssl.SslFilter;
 
 /**
  * Provides TCP+SSL client-side support.
@@ -46,10 +46,10 @@
 
         DefaultIoFilterChainBuilder filterChain = connector.getFilterChain();
 
-        SslFilter sslFilter = new SslFilter(sslContextFactory.createClientContext());
+        SSLFilter sslFilter = new SSLFilter(sslContextFactory.createClientContext());
         sslFilter.setUseClientMode(true);
 
-        filterChain.addAfter(ExecutorFilter.class.getSimpleName(), SslFilter.class.getSimpleName(),
sslFilter);
+        filterChain.addAfter(ExecutorFilter.class.getSimpleName(), SSLFilter.class.getSimpleName(),
sslFilter);
     }
 
     //

Modified: 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=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportServer.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportServer.java
Thu Sep 20 00:06:36 2007
@@ -25,7 +25,7 @@
 import org.apache.geronimo.gshell.remote.transport.tcp.TcpTransportServer;
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.filter.executor.ExecutorFilter;
-import org.apache.mina.filter.ssl.SslFilter;
+import org.apache.mina.filter.SSLFilter;
 
 /**
  * Provides TCP+SSL server-side support.
@@ -46,9 +46,9 @@
         
         DefaultIoFilterChainBuilder filterChain = acceptor.getFilterChain();
 
-        SslFilter sslFilter = new SslFilter(sslContextFactory.createServerContext());
+        SSLFilter sslFilter = new SSLFilter(sslContextFactory.createServerContext());
 
-        filterChain.addAfter(ExecutorFilter.class.getSimpleName(), SslFilter.class.getSimpleName(),
sslFilter);
+        filterChain.addAfter(ExecutorFilter.class.getSimpleName(), SSLFilter.class.getSimpleName(),
sslFilter);
     }
     
     //

Modified: 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=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java
Thu Sep 20 00:06:36 2007
@@ -48,7 +48,8 @@
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.WriteFuture;
-import org.apache.mina.transport.socket.SocketSessionConfig;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.transport.socket.nio.SocketConnector;
 
 /**
@@ -108,7 +109,7 @@
     protected IoConnector createConnector() throws Exception {
         SocketConnector connector = new SocketConnector(/*Runtime.getRuntime().availableProcessors()
+ 1*/ 4, /* executor */ Executors.newCachedThreadPool());
 
-        SocketSessionConfig config = connector.getSessionConfig();
+        // SocketSessionConfig config = connector.getSessionConfig();
 
         // config.setTcpNoDelay(true);
         // config.setKeepAlive(true);
@@ -120,12 +121,16 @@
         connector = createConnector();
 
         connector.addListener(new IoServiceListener() {
-            public void serviceActivated(IoService service) {
+            public void serviceActivated(IoService service, SocketAddress serviceAddress,
IoHandler handler, IoServiceConfig config) {
                 log.info("Service activated: {}", service);
+
+                // log.info("Service activated: {}, {}, {}, {}", service, serviceAddress,
handler, config);
             }
 
-            public void serviceDeactivated(IoService service) {
+            public void serviceDeactivated(IoService service, SocketAddress serviceAddress,
IoHandler handler, IoServiceConfig config) {
                 log.info("Service deactivated: {}", service);
+
+                // log.info("Service deactivated: {}, {}, {}, {}", service, serviceAddress,
handler, config);
             }
 
             public void sessionCreated(IoSession session) {
@@ -148,7 +153,17 @@
         
         configure(connector);
 
-        DefaultIoFilterChainBuilder filterChain = connector.getFilterChain();
+        DefaultIoFilterChainBuilder filterChain;
+
+        filterChain = connector.getDefaultConfig().getFilterChain();
+
+        log.debug("Default filters:");
+
+        for (IoFilterChain.Entry entry : filterChain.getAll()) {
+            log.debug("    {}", entry);
+        }
+
+        filterChain = connector.getFilterChain();
 
         log.debug("Service filters:");
 
@@ -156,9 +171,11 @@
             log.debug("    {}", entry);
         }
 
+        /*
         IoSessionConfig config = connector.getSessionConfig();
 
         log.debug("Session config: {}", ReflectionToStringBuilder.toString(config, ToStringStyle.MULTI_LINE_STYLE));
+        */
     }
 
     public synchronized void connect() throws Exception {
@@ -170,13 +187,18 @@
 
         log.info("Connecting to: {}", remoteAddress);
 
-        ConnectFuture cf = connector.connect(remoteAddress, localAddress);
+        ConnectFuture cf = connector.connect(remoteAddress, localAddress, getProtocolHandler());
 
-        if (cf.awaitUninterruptibly(CONNECT_TIMEOUT, TimeUnit.SECONDS)) {
-             session = cf.getSession();
-        }
-        else {
-            throw new ConnectionException("Failed to connect in allocated time");
+        cf.join();
+
+        session = cf.getSession();
+
+        IoFilterChain filterChain = session.getFilterChain();
+
+        log.debug("Session filters:");
+
+        for (IoFilterChain.Entry entry : filterChain.getAll()) {
+            log.debug("    {}", entry);
         }
 
         connected = true;
@@ -190,7 +212,7 @@
         try {
             CloseFuture cf = session.close();
 
-            cf.awaitUninterruptibly();
+            cf.join();
         }
         finally {
             super.close();

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportServer.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/TcpTransportServer.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportServer.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransportServer.java
Thu Sep 20 00:06:36 2007
@@ -38,7 +38,8 @@
 import org.apache.mina.common.IoServiceListener;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionConfig;
-import org.apache.mina.transport.socket.SocketSessionConfig;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
 
 /**
@@ -95,11 +96,13 @@
     protected IoAcceptor createAcceptor() throws Exception {
         SocketAcceptor acceptor = new SocketAcceptor(/*Runtime.getRuntime().availableProcessors()
+ 1*/ 4, /* executor */ Executors.newCachedThreadPool());
 
+        /*
         SocketSessionConfig config = acceptor.getSessionConfig();
 
         // ????
         config.setTcpNoDelay(true);
         config.setKeepAlive(true);
+        */
 
         return acceptor;
     }
@@ -107,15 +110,17 @@
     protected synchronized void init() throws Exception {
         acceptor = createAcceptor();
 
-        acceptor.setLocalAddress(address);
-
         acceptor.addListener(new IoServiceListener() {
-            public void serviceActivated(IoService service) {
+            public void serviceActivated(IoService service, SocketAddress serviceAddress,
IoHandler handler, IoServiceConfig config) {
                 log.info("Service activated: {}", service);
+
+                // log.info("Service activated: {}, {}, {}, {}", service, serviceAddress,
handler, config);
             }
 
-            public void serviceDeactivated(IoService service) {
+            public void serviceDeactivated(IoService service, SocketAddress serviceAddress,
IoHandler handler, IoServiceConfig config) {
                 log.info("Service deactivated: {}", service);
+
+                // log.info("Service deactivated: {}, {}, {}, {}", service, serviceAddress,
handler, config);
             }
 
             public void sessionCreated(IoSession session) {
@@ -145,9 +150,11 @@
             log.debug("    {}", entry);
         }
 
+        /*
         IoSessionConfig config = acceptor.getSessionConfig();
 
         log.debug("Session config: {}", ReflectionToStringBuilder.toString(config, ToStringStyle.MULTI_LINE_STYLE));
+        */
 
     }
 
@@ -158,7 +165,7 @@
 
         init();
 
-        acceptor.bind();
+        acceptor.bind(address, getProtocolHandler());
 
         bound = true;
 
@@ -168,7 +175,7 @@
     public synchronized void close() {
         super.close();
 
-        acceptor.unbind();
+        acceptor.unbind(address);
 
         log.info("Closed");
     }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
Thu Sep 20 00:06:36 2007
@@ -257,12 +257,8 @@
                 }
                 catch (Notification n) {
                     msg.reply(new ExecuteMessage.Notification(n));
-
-                    session.close();
                 }
                 catch (Throwable t) {
-                    log.error("Unhandled failure; sending to client: " + t, t);
-
                     msg.reply(new ExecuteMessage.Fault(t));
                 }
             }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/pom.xml?rev=577587&r1=577586&r2=577587&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/pom.xml Thu Sep 20 00:06:36 2007
@@ -69,7 +69,13 @@
         <dependency>
             <groupId>org.apache.mina</groupId>
             <artifactId>mina-core</artifactId>
-            <version>2.0.0-M1-SNAPSHOT</version>
+            <version>1.1.2</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.mina</groupId>
+            <artifactId>mina-filter-ssl</artifactId>
+            <version>1.1.2</version>
         </dependency>
         
         <dependency>



Mime
View raw message