KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.enterprise.management.config;
24
25 import java.util.Map JavaDoc;
26 import java.util.Set JavaDoc;
27 import java.util.Collections JavaDoc;
28
29 import javax.management.ObjectName JavaDoc;
30 import javax.management.AttributeList JavaDoc;
31
32 import com.sun.appserv.management.base.XTypes;
33 import com.sun.appserv.management.base.Util;
34
35 import com.sun.appserv.management.util.misc.MapUtil;
36 import com.sun.appserv.management.util.misc.GSetUtil;
37
38 import com.sun.enterprise.management.support.Delegate;
39 import com.sun.enterprise.management.support.oldconfig.OldThreadPoolsConfigMBean;
40
41
42 import com.sun.appserv.management.config.ThreadPoolConfigKeys;
43
44
45
46 /**
47     Configuration for the <thread-pools> element.
48  */

49 public final class ThreadPoolConfigFactory extends ConfigFactory
50 {
51         public
52     ThreadPoolConfigFactory( final ConfigFactoryCallback callbacks )
53     {
54         super( callbacks );
55     }
56     
57     private final Set JavaDoc<String JavaDoc> LEGAL_OPTIONAL_KEYS =
58         GSetUtil.newUnmodifiableStringSet(
59         ThreadPoolConfigKeys.MIN_THREAD_POOL_SIZE_KEY,
60         ThreadPoolConfigKeys.MAX_THREAD_POOL_SIZE_KEY,
61         ThreadPoolConfigKeys.IDLE_THREAD_TIMEOUT_IN_SECONDS_KEY,
62         ThreadPoolConfigKeys.NUM_WORK_QUEUES_KEY
63     );
64     
65         protected Set JavaDoc<String JavaDoc>
66     getLegalOptionalCreateKeys()
67     {
68         return( LEGAL_OPTIONAL_KEYS );
69     }
70     
71     
72         private OldThreadPoolsConfigMBean
73     getOldThreadPoolsConfigMBean( )
74     {
75         return getOldConfigProxies().getOldThreadPoolsConfigMBean( getConfigName() );
76     }
77     
78     /**
79         Create a new &lt;thread-pool>
80         
81         @param name name of the &lt;thread-pool> (thread-pool-id)
82         @param optional
83         @return ObjectName of the newly-created ThreadPoolConfig
84      */

85         public ObjectName JavaDoc
86     create( String JavaDoc name, Map JavaDoc<String JavaDoc,String JavaDoc> optional )
87     {
88         final Map JavaDoc<String JavaDoc,String JavaDoc> params = initParams( name, null, optional );
89         
90         final ObjectName JavaDoc amxName = createNamedChild( name, params );
91         
92         return( amxName );
93     }
94
95         public void
96     internalRemove( final ObjectName JavaDoc objectName)
97     {
98         final String JavaDoc name = Util.getName( objectName );
99         
100         getOldThreadPoolsConfigMBean().removeThreadPoolByThreadPoolId( name );
101     }
102
103         protected Map JavaDoc<String JavaDoc,String JavaDoc>
104     getParamNameOverrides()
105     {
106         return( MapUtil.newMap( CONFIG_NAME_KEY, "thread-pool-id" ) );
107     }
108
109         protected ObjectName JavaDoc
110     createOldChildConfig( final AttributeList JavaDoc translatedAttrs )
111     {
112         final ObjectName JavaDoc objectName =
113                 getOldThreadPoolsConfigMBean().createThreadPool( translatedAttrs );
114         
115         return( objectName );
116     }
117
118 }
119
120
Popular Tags