directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r371273 - in /directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina: common/IoService.java transport/socket/nio/DatagramSession.java
Date Sun, 22 Jan 2006 11:59:11 GMT
Author: trustin
Date: Sun Jan 22 03:59:07 2006
New Revision: 371273

URL: http://svn.apache.org/viewcvs?rev=371273&view=rev
Log:
* Fixed NullPointerException in DatagramSession.<init>
* IoService adds a thread pool by default (this need more work)

Modified:
    directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java
    directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java

Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java?rev=371273&r1=371272&r2=371273&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java
(original)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java
Sun Jan 22 03:59:07 2006
@@ -29,6 +29,7 @@
 import org.apache.mina.common.IoServiceProvider.IoConnector;
 import org.apache.mina.common.support.DefaultExceptionMonitor;
 import org.apache.mina.common.support.discovery.tools.Service;
+import org.apache.mina.filter.ThreadPoolFilter;
 import org.apache.mina.util.IdentityHashSet;
 
 /**
@@ -42,6 +43,8 @@
 {
     private static final Map providers = new HashMap();
     private static ExceptionMonitor exceptionMonitor = new DefaultExceptionMonitor();
+    
+    private static IoFilter threadPoolFilter = new ThreadPoolFilter();
 
     static
     {
@@ -198,7 +201,9 @@
         {
             filterChainBuilder = IoFilterChainBuilder.NOOP;
         }
-    	acceptor.bind( address, handler, filterChainBuilder );
+    	acceptor.bind(
+                address, handler,
+                new IoFilterChainBuilderWrapper( filterChainBuilder ) );
     }
 
     /**
@@ -220,6 +225,11 @@
         unbind( createAddress( address ) );
     }
     
+    public static void unbindAll()
+    {
+        // TODO implement me
+    }
+    
     /**
      * Returns all sessions currently connected to the specified local address.
      * 
@@ -396,7 +406,9 @@
         {
             filterChainBuilder = IoFilterChainBuilder.NOOP;
         }
-    	return connector.connect( address, localAddress, handler, filterChainBuilder );
+    	return connector.connect(
+                address, localAddress, handler,
+                new IoFilterChainBuilderWrapper( filterChainBuilder ) );
     }
 
     /**
@@ -454,5 +466,21 @@
 
     private IoService()
     {
+    }
+    
+    private static class IoFilterChainBuilderWrapper implements IoFilterChainBuilder
+    {
+        private final IoFilterChainBuilder originalBuilder;
+
+        public IoFilterChainBuilderWrapper( IoFilterChainBuilder originalBuilder )
+        {
+            this.originalBuilder = originalBuilder;
+        }
+
+        public void buildFilterChain( IoFilterChain chain ) throws Exception
+        {
+            originalBuilder.buildFilterChain( chain );
+            chain.addFirst( "builtInThreadPool", threadPoolFilter );
+        }
     }
 }

Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java?rev=371273&r1=371272&r2=371273&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java
(original)
+++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java
Sun Jan 22 03:59:07 2006
@@ -18,6 +18,7 @@
  */
 package org.apache.mina.transport.socket.nio;
 
+import java.net.SocketAddress;
 import java.net.SocketException;
 import java.nio.channels.DatagramChannel;
 import java.nio.channels.SelectionKey;
@@ -61,7 +62,12 @@
         this.ch = ch;
         this.writeRequestQueue = new Queue();
         this.handler = defaultHandler;
-        this.remoteAddress = SocketAddresses.compose( "datagram", ch.socket().getRemoteSocketAddress()
);
+        
+        SocketAddress remoteAddress = ch.socket().getRemoteSocketAddress();
+        if( remoteAddress != null )
+        {
+            this.remoteAddress = SocketAddresses.compose( "datagram", remoteAddress );
+        }
         this.localAddress = SocketAddresses.compose( "datagram", ch.socket().getLocalSocketAddress()
);
     }
     



Mime
View raw message