directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r371274 - /directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.java
Date Sun, 22 Jan 2006 12:06:35 GMT
Author: trustin
Date: Sun Jan 22 04:06:32 2006
New Revision: 371274

URL: http://svn.apache.org/viewcvs?rev=371274&view=rev
Log:
IoService can understand "threadModel" property now.

Modified:
    directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoService.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=371274&r1=371273&r2=371274&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 04:06:32 2006
@@ -23,6 +23,7 @@
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 import org.apache.mina.common.IoServiceProvider.IoAcceptor;
@@ -203,7 +204,7 @@
         }
     	acceptor.bind(
                 address, handler,
-                new IoFilterChainBuilderWrapper( filterChainBuilder ) );
+                createFilterChainBuilder( address, filterChainBuilder ) );
     }
 
     /**
@@ -408,7 +409,7 @@
         }
     	return connector.connect(
                 address, localAddress, handler,
-                new IoFilterChainBuilderWrapper( filterChainBuilder ) );
+                createFilterChainBuilder( address, filterChainBuilder ) );
     }
 
     /**
@@ -463,11 +464,36 @@
         }
         exceptionMonitor = monitor;
     }
-
-    private IoService()
+    
+    private static IoFilterChainBuilder createFilterChainBuilder( IoAddress address, IoFilterChainBuilder
originalBuilder )
     {
+        final String THREAD_MODEL = "threadModel";
+
+        Properties props = address.getProperties();
+        if( props.containsKey( THREAD_MODEL ) )
+        {
+            String threadModel = props.getProperty( THREAD_MODEL );
+            if( "single".equalsIgnoreCase( threadModel ) ||
+                "manual".equalsIgnoreCase( threadModel ) )
+            {
+                return originalBuilder;
+            }
+            else if( "normal".equalsIgnoreCase( threadModel ) ||
+                     "default".equalsIgnoreCase( threadModel ) )
+            {
+                return new IoFilterChainBuilderWrapper( originalBuilder );
+            }
+            else
+            {
+                throw new IllegalArgumentException( "Unknown thread model: " + threadModel
);
+            }
+        }
+        else
+        {
+            return new IoFilterChainBuilderWrapper( originalBuilder );
+        }
     }
-    
+
     private static class IoFilterChainBuilderWrapper implements IoFilterChainBuilder
     {
         private final IoFilterChainBuilder originalBuilder;
@@ -482,5 +508,9 @@
             originalBuilder.buildFilterChain( chain );
             chain.addFirst( "builtInThreadPool", threadPoolFilter );
         }
+    }
+
+    private IoService()
+    {
     }
 }



Mime
View raw message