directory-commits mailing list archives

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

URL: http://svn.apache.org/viewcvs?rev=371275&view=rev
Log:
Added threadPoolSize parameter

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=371275&r1=371274&r2=371275&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:16:54 2006
@@ -45,8 +45,6 @@
     private static final Map providers = new HashMap();
     private static ExceptionMonitor exceptionMonitor = new DefaultExceptionMonitor();
     
-    private static IoFilter threadPoolFilter = new ThreadPoolFilter();
-
     static
     {
         registerServiceProviders();
@@ -468,6 +466,7 @@
     private static IoFilterChainBuilder createFilterChainBuilder( IoAddress address, IoFilterChainBuilder
originalBuilder )
     {
         final String THREAD_MODEL = "threadModel";
+        final String THREAD_POOL_SIZE = "threadPoolSize";
 
         Properties props = address.getProperties();
         if( props.containsKey( THREAD_MODEL ) )
@@ -478,34 +477,33 @@
             {
                 return originalBuilder;
             }
-            else if( "normal".equalsIgnoreCase( threadModel ) ||
-                     "default".equalsIgnoreCase( threadModel ) )
-            {
-                return new IoFilterChainBuilderWrapper( originalBuilder );
-            }
-            else
+            else if( !"normal".equalsIgnoreCase( threadModel ) &&
+                     !"default".equalsIgnoreCase( threadModel ) )
             {
                 throw new IllegalArgumentException( "Unknown thread model: " + threadModel
);
             }
         }
-        else
-        {
-            return new IoFilterChainBuilderWrapper( originalBuilder );
-        }
+
+        int poolSize = Integer.parseInt( props.getProperty( THREAD_POOL_SIZE, "16" ) );
+        return new ThreadPooledFilterChainBuilder( originalBuilder, poolSize );
     }
 
-    private static class IoFilterChainBuilderWrapper implements IoFilterChainBuilder
+    private static class ThreadPooledFilterChainBuilder implements IoFilterChainBuilder
     {
         private final IoFilterChainBuilder originalBuilder;
+        private final ThreadPoolFilter threadPoolFilter;
 
-        public IoFilterChainBuilderWrapper( IoFilterChainBuilder originalBuilder )
+        public ThreadPooledFilterChainBuilder( IoFilterChainBuilder originalBuilder, int
poolSize )
         {
             this.originalBuilder = originalBuilder;
+            threadPoolFilter = new ThreadPoolFilter();
+            threadPoolFilter.setMaximumPoolSize( poolSize );
         }
 
         public void buildFilterChain( IoFilterChain chain ) throws Exception
         {
             originalBuilder.buildFilterChain( chain );
+            
             chain.addFirst( "builtInThreadPool", threadPoolFilter );
         }
     }



Mime
View raw message