geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r578262 - in /geronimo/sandbox/gshell/trunk: gshell-assembly/src/main/assembly/ gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/logging/ gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo...
Date Fri, 21 Sep 2007 20:38:54 GMT
Author: jdillon
Date: Fri Sep 21 13:38:53 2007
New Revision: 578262

URL: http://svn.apache.org/viewvc?rev=578262&view=rev
Log:
Fixed ssl support to work with Mina 1.1.2
Moved some more common transport bits to TransportCommon and some other clean up

Removed:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/logging/
Modified:
    geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/ssl/BogusSSLContextFactory.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.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/TransportServer.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/SslTransportFactory.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

Modified: geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml?rev=578262&r1=578261&r2=578262&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml Fri Sep 21 13:38:53
2007
@@ -79,6 +79,7 @@
                 <include>org.apache.geronimo.gshell.remote:gshell-remote-server</include>
                 <include>org.apache.geronimo.gshell.remote:gshell-remote-client</include>
                 <include>org.apache.mina:mina-core</include>
+                <include>org.apache.mina:mina-filter-ssl</include>
             </includes>
         </dependencySet>
 

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/ssl/BogusSSLContextFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/ssl/BogusSSLContextFactory.java?rev=578262&r1=578261&r2=578262&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/ssl/BogusSSLContextFactory.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/ssl/BogusSSLContextFactory.java
Fri Sep 21 13:38:53 2007
@@ -52,7 +52,7 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role=SSLContextFactory.class, hint="bogus")
+@Component(role=SSLContextFactory.class) // HACK: hint="bogus")
 public class BogusSSLContextFactory
     implements SSLContextFactory, Initializable
 {

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.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?rev=578262&r1=578261&r2=578262&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java
Fri Sep 21 13:38:53 2007
@@ -22,6 +22,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.concurrent.TimeUnit;
+import java.net.URI;
 
 import org.apache.geronimo.gshell.remote.message.Message;
 import org.apache.mina.common.WriteFuture;
@@ -33,6 +34,10 @@
  */
 public interface Transport
 {
+    URI getRemoteLocation();
+
+    URI getLocalLocation();
+
     WriteFuture send(Object msg) throws Exception;
 
     Message request(Message msg, long timeout, TimeUnit unit) throws Exception;

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=578262&r1=578261&r2=578262&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
Fri Sep 21 13:38:53 2007
@@ -19,18 +19,24 @@
 
 package org.apache.geronimo.gshell.remote.transport;
 
+import java.net.SocketAddress;
+
 import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
 import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
 import org.apache.geronimo.gshell.remote.codec.MessageCodecFactory;
-import org.apache.geronimo.gshell.remote.logging.LoggingFilter;
 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.IoFilterChain;
+import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoServiceConfig;
+import org.apache.mina.common.IoServiceListener;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.SimpleByteBufferAllocator;
+import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.management.IoSessionStat;
 import org.apache.mina.management.StatCollector;
@@ -51,18 +57,10 @@
 
     // protected final ScheduledExecutorService scheduler;
 
-    private PlexusContainer container;
+    // private StatCollector statCollector;
 
     private IoService service;
 
-    private StatCollector statCollector;
-
-    private MessageVisitor messageVisitor;
-
-    private ProtocolHandler protocolHandler;
-    
-    private MessageCodecFactory codecFactory;
-
     protected TransportCommon() {
         ByteBuffer.setUseDirectBuffers(false);
         ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
@@ -87,24 +85,50 @@
 
         this.service = service;
 
+        service.addListener(new IoServiceListener() {
+            public void serviceActivated(IoService service, SocketAddress serviceAddress,
IoHandler handler, IoServiceConfig config) {
+                log.info("Service activated: {}", service);
+
+                // log.info("Service activated: {}, {}, {}, {}", service, serviceAddress,
handler, config);
+
+                logFilters(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) {
+                log.info("Session created: {}", session);
+
+                logFilters(session);
+            }
+
+            public void sessionDestroyed(IoSession session) {
+                log.info("Session destroyed: {}", session);
+            }
+        });
+
         ProtocolHandler handler = getProtocolHandler();
 
         MessageVisitor visitor = getMessageVisitor();
 
         handler.setVisitor(visitor);
-        
-        // service.setHandler(handler);
+
+        // Install the default set of filters
 
         DefaultIoFilterChainBuilder filterChain = service.getFilterChain();
+
+        //
+        // NOTE: We don't need an executor filter here, since the ThreadModel does that for
us
+        //
         
         // filterChain.addLast(ExecutorFilter.class.getSimpleName(), new ExecutorFilter(executor));
 
         // filterChain.addLast(ProfilerTimerFilter.class.getSimpleName(), new ProfilerTimerFilter());
 
-        //
-        // NOTE: I read that executor might be best *after* protocl...
-        //
-
         filterChain.addLast(ProtocolCodecFilter.class.getSimpleName(), new ProtocolCodecFilter(getMessageCodecFactory()));
 
         filterChain.addLast(LoggingFilter.class.getSimpleName(), new LoggingFilter());
@@ -113,16 +137,52 @@
 
         filterChain.addLast(RequestResponseFilter.class.getSimpleName(), new RequestResponseFilter());
 
+        //
+        // TODO: Start up a scheduled task to periodically log stats
+        //
+
         // Setup stat collection
         // statCollector = new StatCollector(service);
         // statCollector.start();
+    }
 
-        //
-        // TODO: Start up a scheduled task to periodically log stats
-        //
+    public IoService getService() {
+        return service;
     }
 
-    private void logStats(final IoSession session) throws Exception {
+    public void close() {
+        // statCollector.stop();
+
+        // executor.shutdownNow();
+
+        // scheduler.shutdownNow();
+    }
+
+    //
+    // Logging Helpers
+    //
+    
+    protected void logFilters(IoService service) {
+        DefaultIoFilterChainBuilder filterChain = service.getFilterChain();
+
+        log.debug("Service filters:");
+
+        for (IoFilterChain.Entry entry : filterChain.getAll()) {
+            log.debug("    {}", entry);
+        }
+    }
+
+    protected void logFilters(IoSession session) {
+        IoFilterChain filterChain = session.getFilterChain();
+
+        log.debug("Session filters:");
+
+        for (IoFilterChain.Entry entry : filterChain.getAll()) {
+            log.debug("    {}", entry);
+        }
+    }
+
+    protected void logStats(final IoSession session) throws Exception {
         assert session != null;
 
         IoSessionStat stat = (IoSessionStat) session.getAttribute(StatCollector.KEY);
@@ -131,14 +191,18 @@
             log.debug("Stats: {}", ReflectionToStringBuilder.toString(stat, ToStringStyle.SHORT_PREFIX_STYLE));
         }
     }
-    
-    public void close() {
-        // statCollector.stop();
 
-        // executor.shutdownNow();
+    //
+    // AutoWire Support
+    //
 
-        // scheduler.shutdownNow();
-    }
+    private PlexusContainer container;
+
+    private MessageVisitor messageVisitor;
+
+    private ProtocolHandler protocolHandler;
+
+    private MessageCodecFactory codecFactory;
 
     //
     // NOTE: Setters exposed to support Plexus autowire()  Getters exposed to handle state
checking.

Modified: 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=578262&r1=578261&r2=578262&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java
Fri Sep 21 13:38:53 2007
@@ -19,6 +19,8 @@
 
 package org.apache.geronimo.gshell.remote.transport;
 
+import java.net.URI;
+
 /**
  * Provides the server-side protocol interface.
  *
@@ -26,5 +28,7 @@
  */
 public interface TransportServer
 {
+    URI getLocation();
+
     void close();
 }

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=578262&r1=578261&r2=578262&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
Fri Sep 21 13:38:53 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.common.IoService;
 import org.apache.mina.filter.SSLFilter;
-import org.apache.mina.filter.executor.ExecutorFilter;
 
 /**
  * Provides TCP+SSL client-side support.
@@ -35,24 +35,28 @@
 public class SslTransport
     extends TcpTransport
 {
-    private SSLContextFactory sslContextFactory;
-
     public SslTransport(final URI remote, final URI local) throws Exception {
         super(remote, local);
     }
 
-    protected void init() throws Exception {
-        super.init();
+    protected void configure(final IoService service) throws Exception {
+        super.configure(service);
 
-        DefaultIoFilterChainBuilder filterChain = connector.getFilterChain();
+        DefaultIoFilterChainBuilder filterChain = service.getFilterChain();
 
-        SSLFilter sslFilter = new SSLFilter(sslContextFactory.createClientContext());
+        SSLFilter sslFilter = new SSLFilter(getSslContextFactory().createClientContext());
         sslFilter.setUseClientMode(true);
 
-        filterChain.addAfter(ExecutorFilter.class.getSimpleName(), SSLFilter.class.getSimpleName(),
sslFilter);
+        filterChain.addFirst(SSLFilter.class.getSimpleName(), sslFilter);
     }
 
     //
+    // AutoWire Support
+    //
+
+    private SSLContextFactory sslContextFactory;
+
+    //
     // NOTE: Setters exposed to support Plexus autowire()
     //
 
@@ -60,5 +64,13 @@
         log.debug("Using SSL Context Factory: {}", factory);
 
         this.sslContextFactory = factory;
+    }
+
+    protected SSLContextFactory getSslContextFactory() {
+        if (sslContextFactory == null) {
+            throw new IllegalStateException("SSL context factory not bound");
+        }
+
+        return sslContextFactory;
     }
 }

Modified: 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=578262&r1=578261&r2=578262&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportFactory.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ssl/SslTransportFactory.java
Fri Sep 21 13:38:53 2007
@@ -36,10 +36,12 @@
 public class SslTransportFactory
     extends TcpTransportFactory
 {
-    protected TcpTransport createTransport(final URI location) throws Exception {
-        return new SslTransport(location, null);
+    @Override
+    protected TcpTransport createTransport(final URI remote, final URI local) throws Exception
{
+        return new SslTransport(remote, local);
     }
 
+    @Override
     protected TcpTransportServer createTransportServer(final URI location) throws Exception
{
         return new SslTransportServer(location);
     }

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=578262&r1=578261&r2=578262&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
Fri Sep 21 13:38:53 2007
@@ -24,7 +24,7 @@
 import org.apache.geronimo.gshell.remote.ssl.SSLContextFactory;
 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.common.IoService;
 import org.apache.mina.filter.SSLFilter;
 
 /**
@@ -35,22 +35,26 @@
 public class SslTransportServer
     extends TcpTransportServer
 {
-    private SSLContextFactory sslContextFactory;
-
     public SslTransportServer(final URI location) throws Exception {
         super(location);
     }
 
-    protected void init() throws Exception {
-        super.init();
-        
-        DefaultIoFilterChainBuilder filterChain = acceptor.getFilterChain();
+    protected void configure(final IoService service) throws Exception {
+        super.configure(service);
+
+        DefaultIoFilterChainBuilder filterChain = service.getFilterChain();
 
-        SSLFilter sslFilter = new SSLFilter(sslContextFactory.createServerContext());
+        SSLFilter sslFilter = new SSLFilter(getSslContextFactory().createServerContext());
 
-        filterChain.addAfter(ExecutorFilter.class.getSimpleName(), SSLFilter.class.getSimpleName(),
sslFilter);
+        filterChain.addFirst(SSLFilter.class.getSimpleName(), sslFilter);
     }
-    
+
+    //
+    // AutoWire Support
+    //
+
+    private SSLContextFactory sslContextFactory;
+
     //
     // NOTE: Setters exposed to support Plexus autowire()
     //
@@ -59,5 +63,13 @@
         log.debug("Using SSL Context Factory: {}", factory);
 
         this.sslContextFactory = factory;
+    }
+
+    protected SSLContextFactory getSslContextFactory() {
+        if (sslContextFactory == null) {
+            throw new IllegalStateException("SSL context factory not bound");
+        }
+
+        return sslContextFactory;
     }
 }

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=578262&r1=578261&r2=578262&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
Fri Sep 21 13:38:53 2007
@@ -28,29 +28,20 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
-import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
 import org.apache.geronimo.gshell.remote.message.Message;
 import org.apache.geronimo.gshell.remote.message.MessageVisitor;
 import org.apache.geronimo.gshell.remote.request.Requestor;
 import org.apache.geronimo.gshell.remote.stream.SessionInputStream;
 import org.apache.geronimo.gshell.remote.stream.SessionOutputStream;
-import org.apache.geronimo.gshell.remote.transport.ConnectionException;
 import org.apache.geronimo.gshell.remote.transport.Transport;
 import org.apache.geronimo.gshell.remote.transport.TransportCommon;
 import org.apache.mina.common.CloseFuture;
 import org.apache.mina.common.ConnectFuture;
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoFilterChain;
-import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceListener;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.WriteFuture;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.transport.socket.nio.SocketConnector;
+import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
 
 /**
  * Provides TCP client-side support.
@@ -107,12 +98,11 @@
     }
 
     protected IoConnector createConnector() throws Exception {
-        SocketConnector connector = new SocketConnector(/*Runtime.getRuntime().availableProcessors()
+ 1*/ 4, /* executor */ Executors.newCachedThreadPool());
+        SocketConnector connector = new SocketConnector(Runtime.getRuntime().availableProcessors()
+ 1, Executors.newCachedThreadPool());
 
-        // SocketSessionConfig config = connector.getSessionConfig();
+        SocketConnectorConfig config = connector.getDefaultConfig();
 
-        // config.setTcpNoDelay(true);
-        // config.setKeepAlive(true);
+        config.getSessionConfig().setKeepAlive(true);
 
         return connector;
     }
@@ -120,31 +110,6 @@
     protected synchronized void init() throws Exception {
         connector = createConnector();
 
-        connector.addListener(new IoServiceListener() {
-            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, SocketAddress serviceAddress,
IoHandler handler, IoServiceConfig config) {
-                log.info("Service deactivated: {}", service);
-
-                // log.info("Service deactivated: {}, {}, {}, {}", service, serviceAddress,
handler, config);
-            }
-
-            public void sessionCreated(IoSession session) {
-                log.info("Session created: {}", session);
-            }
-
-            public void sessionDestroyed(IoSession session) {
-                log.info("Session destroyed: {}", session);
-            }
-        });
-
-
-        // connector.setConnectTimeout(30);
-
         //
         // HACK: Need to manually wire in the visitor impl for now... :-(
         //
@@ -152,30 +117,6 @@
         setMessageVisitor((MessageVisitor) getContainer().lookup(MessageVisitor.class, "client"));
         
         configure(connector);
-
-        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:");
-
-        for (IoFilterChain.Entry entry : filterChain.getAll()) {
-            log.debug("    {}", entry);
-        }
-
-        /*
-        IoSessionConfig config = connector.getSessionConfig();
-
-        log.debug("Session config: {}", ReflectionToStringBuilder.toString(config, ToStringStyle.MULTI_LINE_STYLE));
-        */
     }
 
     public synchronized void connect() throws Exception {
@@ -193,22 +134,12 @@
 
         session = cf.getSession();
 
-        IoFilterChain filterChain = session.getFilterChain();
-
-        log.debug("Session filters:");
-
-        for (IoFilterChain.Entry entry : filterChain.getAll()) {
-            log.debug("    {}", entry);
-        }
-
         connected = true;
         
         log.info("Connected");
     }
 
     public synchronized void close() {
-        log.info("Closing");
-
         try {
             CloseFuture cf = session.close();
 
@@ -217,8 +148,6 @@
         finally {
             super.close();
         }
-
-        log.info("Closed");
     }
 
     public URI getRemoteLocation() {

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=578262&r1=578261&r2=578262&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
Fri Sep 21 13:38:53 2007
@@ -25,22 +25,14 @@
 import java.net.URI;
 import java.util.concurrent.Executors;
 
-import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
-import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
 import org.apache.geronimo.gshell.remote.message.MessageVisitor;
 import org.apache.geronimo.gshell.remote.security.SecurityFilter;
 import org.apache.geronimo.gshell.remote.transport.TransportCommon;
 import org.apache.geronimo.gshell.remote.transport.TransportServer;
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoFilterChain;
-import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceListener;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.common.IoSessionConfig;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
+import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 
 /**
  * Provides TCP server-side support.
@@ -59,8 +51,6 @@
 
     protected boolean bound;
 
-    private SecurityFilter securityFilter;
-
     protected TcpTransportServer(final URI location, final SocketAddress address) {
         assert location != null;
         assert address != null;
@@ -77,32 +67,12 @@
         return location;
     }
     
-    //
-    // NOTE: Setters exposed to support Plexus autowire()  Getters exposed to handle state
checking.
-    //
-
-    public void setSecurityFilter(final SecurityFilter securityFilter) {
-        this.securityFilter = securityFilter;
-    }
-
-    protected SecurityFilter getSecurityFilter() {
-        if (securityFilter == null) {
-            throw new IllegalStateException("Security filter not bound");
-        }
-        
-        return securityFilter;
-    }
-
     protected IoAcceptor createAcceptor() throws Exception {
-        SocketAcceptor acceptor = new SocketAcceptor(/*Runtime.getRuntime().availableProcessors()
+ 1*/ 4, /* executor */ Executors.newCachedThreadPool());
+        SocketAcceptor acceptor = new SocketAcceptor(Runtime.getRuntime().availableProcessors()
+ 1, Executors.newCachedThreadPool());
 
-        /*
-        SocketSessionConfig config = acceptor.getSessionConfig();
+        SocketAcceptorConfig config = acceptor.getDefaultConfig();
 
-        // ????
-        config.setTcpNoDelay(true);
-        config.setKeepAlive(true);
-        */
+        config.getSessionConfig().setKeepAlive(true);
 
         return acceptor;
     }
@@ -110,28 +80,6 @@
     protected synchronized void init() throws Exception {
         acceptor = createAcceptor();
 
-        acceptor.addListener(new IoServiceListener() {
-            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, SocketAddress serviceAddress,
IoHandler handler, IoServiceConfig config) {
-                log.info("Service deactivated: {}", service);
-
-                // log.info("Service deactivated: {}, {}, {}, {}", service, serviceAddress,
handler, config);
-            }
-
-            public void sessionCreated(IoSession session) {
-                log.info("Session created: {}", session);
-            }
-
-            public void sessionDestroyed(IoSession session) {
-                log.info("Session destroyed: {}", session);
-            }
-        });
-
         //
         // HACK: Need to manually wire in the visitor impl for now... :-(
         //
@@ -143,19 +91,6 @@
         DefaultIoFilterChainBuilder filterChain = acceptor.getFilterChain();
         
         filterChain.addLast(SecurityFilter.class.getSimpleName(), getSecurityFilter());
-
-        log.debug("Service filters:");
-        
-        for (IoFilterChain.Entry entry : filterChain.getAll()) {
-            log.debug("    {}", entry);
-        }
-
-        /*
-        IoSessionConfig config = acceptor.getSessionConfig();
-
-        log.debug("Session config: {}", ReflectionToStringBuilder.toString(config, ToStringStyle.MULTI_LINE_STYLE));
-        */
-
     }
 
     public synchronized void bind() throws Exception {
@@ -173,10 +108,34 @@
     }
 
     public synchronized void close() {
-        super.close();
+        try {
+            acceptor.unbind(address);
+        }
+        finally {
+            super.close();
+        }
+    }
+
+    //
+    // AutoWire Support
+    //
 
-        acceptor.unbind(address);
+    private SecurityFilter securityFilter;
+    
+    //
+    // NOTE: Setters exposed to support Plexus autowire()  Getters exposed to handle state
checking.
+    //
 
-        log.info("Closed");
+    public void setSecurityFilter(final SecurityFilter securityFilter) {
+        this.securityFilter = securityFilter;
     }
+
+    protected SecurityFilter getSecurityFilter() {
+        if (securityFilter == null) {
+            throw new IllegalStateException("Security filter not bound");
+        }
+
+        return securityFilter;
+    }
+
 }



Mime
View raw message