1 23 24 package com.sun.enterprise.management.config; 25 26 import java.io.IOException ; 27 import java.util.Set ; 28 import java.util.Map ; 29 import java.util.HashMap ; 30 31 import javax.management.ObjectName ; 32 33 import com.sun.appserv.management.base.AMX; 34 import com.sun.appserv.management.base.Container; 35 import com.sun.appserv.management.base.XTypes; 36 37 import com.sun.appserv.management.config.AMXConfig; 38 import com.sun.appserv.management.config.ThreadPoolConfig; 39 import com.sun.appserv.management.config.ThreadPoolConfigKeys; 40 import com.sun.appserv.management.config.ConfigConfig; 41 42 import com.sun.appserv.management.util.misc.MapUtil; 43 44 45 import com.sun.enterprise.management.AMXTestBase; 46 import com.sun.enterprise.management.Capabilities; 47 48 50 public final class ThreadPoolConfigTest extends ConfigMgrTestBase 51 { 52 static final Map <String ,String > OPTIONAL = new HashMap <String ,String >(); 53 static 54 { 55 OPTIONAL.put( ThreadPoolConfigKeys.MIN_THREAD_POOL_SIZE_KEY, "10" ); 56 OPTIONAL.put( ThreadPoolConfigKeys.MAX_THREAD_POOL_SIZE_KEY, "100" ); 57 OPTIONAL.put( ThreadPoolConfigKeys.IDLE_THREAD_TIMEOUT_IN_SECONDS_KEY, "120" ); 58 OPTIONAL.put( ThreadPoolConfigKeys.NUM_WORK_QUEUES_KEY, "10" ); 59 } 60 61 public 62 ThreadPoolConfigTest () 63 { 64 if ( checkNotOffline( "ensureDefaultInstance" ) ) 65 { 66 ensureDefaultInstance( getConfigConfig() ); 67 } 68 } 69 70 public static String 71 getDefaultInstanceName() 72 { 73 return getDefaultInstanceName( "ThreadPoolConfig" ); 74 } 75 76 public static ThreadPoolConfig 77 ensureDefaultInstance( final ConfigConfig cc ) 78 { 79 ThreadPoolConfig result = cc.getThreadPoolConfigMap().get( getDefaultInstanceName() ); 80 81 if ( result == null ) 82 { 83 result = createInstance( cc, getDefaultInstanceName(), OPTIONAL); 84 } 85 86 return result; 87 } 88 89 public static ThreadPoolConfig 90 createInstance( 91 final ConfigConfig cc, 92 final String name, 93 Map <String ,String > optional) 94 { 95 return cc.createThreadPoolConfig( name, optional ); 96 } 97 98 protected Container 99 getProgenyContainer() 100 { 101 return getConfigConfig(); 102 } 103 104 protected String 105 getProgenyJ2EEType() 106 { 107 return XTypes.THREAD_POOL_CONFIG; 108 } 109 110 111 protected void 112 removeProgeny( final String name ) 113 { 114 getConfigConfig().removeThreadPoolConfig( name ); 115 } 116 117 protected final AMXConfig 118 createProgeny( final String name, final Map <String ,String > options ) 119 { 120 final Map <String ,String > allOptions = MapUtil.newMap( options, OPTIONAL ); 121 122 return getConfigConfig().createThreadPoolConfig(name, allOptions ); 123 } 124 } 125 126 127 | Popular Tags |