KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > ThreadPoolConfigTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 package com.sun.enterprise.management.config;
25
26 import java.io.IOException JavaDoc;
27 import java.util.Set JavaDoc;
28 import java.util.Map JavaDoc;
29 import java.util.HashMap JavaDoc;
30
31 import javax.management.ObjectName JavaDoc;
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 /**
49  */

50 public final class ThreadPoolConfigTest extends ConfigMgrTestBase
51 {
52     static final Map JavaDoc<String JavaDoc,String JavaDoc> OPTIONAL = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
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 JavaDoc
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 JavaDoc name,
93         Map JavaDoc<String JavaDoc,String JavaDoc> optional)
94     {
95         return cc.createThreadPoolConfig( name, optional );
96     }
97     
98         protected Container
99     getProgenyContainer()
100     {
101         return getConfigConfig();
102     }
103
104         protected String JavaDoc
105     getProgenyJ2EEType()
106     {
107         return XTypes.THREAD_POOL_CONFIG;
108     }
109
110
111         protected void
112     removeProgeny( final String JavaDoc name )
113     {
114         getConfigConfig().removeThreadPoolConfig( name );
115     }
116
117         protected final AMXConfig
118     createProgeny( final String JavaDoc name, final Map JavaDoc<String JavaDoc,String JavaDoc> options )
119     {
120         final Map JavaDoc<String JavaDoc,String JavaDoc> allOptions = MapUtil.newMap( options, OPTIONAL );
121         
122         return getConfigConfig().createThreadPoolConfig(name, allOptions );
123     }
124 }
125
126
127
Popular Tags