1 17 18 package org.apache.avalon.cornerstone.blocks.threads; 19 20 import java.util.Map ; 21 22 import org.apache.avalon.excalibur.thread.impl.DefaultThreadPool; 23 24 import org.apache.avalon.framework.configuration.Configuration; 25 import org.apache.avalon.framework.configuration.ConfigurationException; 26 27 35 public class DefaultThreadManager 36 extends AbstractThreadManager 37 { 38 protected void configureThreadPool( final Map threadPools, 39 final Configuration configuration ) 40 throws ConfigurationException 41 { 42 final String name = configuration.getChild( "name" ).getValue(); 43 final boolean isDaemon = configuration.getChild( "is-daemon" ).getValueAsBoolean( false ); 46 47 final int minThreads = configuration.getChild( "min-threads" ).getValueAsInteger( 5 ); 48 final int maxThreads = configuration.getChild( "max-threads" ).getValueAsInteger( 10 ); 49 50 54 try 55 { 56 final DefaultThreadPool threadPool = 57 new DefaultThreadPool( name, minThreads, maxThreads ); 58 threadPool.setDaemon( isDaemon ); 59 threadPool.enableLogging( getLogger() ); 60 threadPools.put( name, threadPool ); 61 } 62 catch( final Exception e ) 63 { 64 final String message = "Error creating ThreadPool named " + name; 65 throw new ConfigurationException( message, e ); 66 } 67 } 68 } 69 | Popular Tags |