1 20 21 package org.jacorb.orb.giop; 22 23 import org.apache.avalon.framework.logger.Logger; 24 import org.apache.avalon.framework.configuration.Configuration; 25 26 import org.jacorb.util.threadpool.*; 27 28 37 38 public class MessageReceptorPool 39 { 40 private static final int MAX_DEFAULT = 1000; 41 42 private static MessageReceptorPool singleton = null; 43 44 private int maxConnectionThreads = 1000; 45 private ThreadPool pool = null; 46 47 private MessageReceptorPool(Configuration myConfiguration) 48 { 49 org.jacorb.config.Configuration configuration = 50 (org.jacorb.config.Configuration) myConfiguration; 51 52 int maxConnectionThreads = MAX_DEFAULT; 53 54 final String attribute = "jacorb.connection.max_threads"; 55 56 maxConnectionThreads = 57 configuration.getAttributeAsInteger(attribute, MAX_DEFAULT); 58 59 Logger logger = configuration.getNamedLogger("jacorb.orb.giop"); 60 61 if (logger.isDebugEnabled()) 62 { 63 logger.debug("Maximum connection threads: " + maxConnectionThreads); 64 } 65 66 pool = 67 new ThreadPool( new ConsumerFactory(){ 68 public Consumer create() 69 { 70 return new MessageReceptor(); 71 } 72 }, 73 maxConnectionThreads, 5 ); } 76 77 public static synchronized MessageReceptorPool getInstance(Configuration myConfiguration) 78 { 79 if( singleton == null ) 80 { 81 singleton = new MessageReceptorPool(myConfiguration); 82 } 83 84 return singleton; 85 } 86 87 public void connectionCreated( GIOPConnection conn ) 88 { 89 pool.putJob( conn ); 90 } 91 } | Popular Tags |