KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.Set JavaDoc;
27 import java.util.Map JavaDoc;
28 import com.sun.appserv.management.util.misc.MapUtil;
29 import javax.management.AttributeList JavaDoc;
30
31 import javax.management.ObjectName JavaDoc;
32
33 import com.sun.appserv.management.util.misc.GSetUtil;
34 import com.sun.appserv.management.config.ClusterRefConfigCR;
35 import com.sun.enterprise.management.support.oldconfig.OldClusterMBean;
36 import com.sun.enterprise.management.support.oldconfig.OldLbConfig;
37
38 final class ClusterRefConfigFactory extends ConfigFactory {
39     
40     private final OldLbConfig mOldLbConfigMBean;
41     
42     private final Set JavaDoc<String JavaDoc> LEGAL_OPTIONAL_KEYS =
43         GSetUtil.newUnmodifiableStringSet(
44             ClusterRefConfigCR.LB_POLICY_KEY,
45             ClusterRefConfigCR.LB_POLICY_MODULE_KEY );
46
47     protected Map JavaDoc<String JavaDoc,String JavaDoc> getParamNameOverrides() {
48         return(MapUtil.newMap(CONFIG_NAME_KEY, "ref"));
49     }
50
51     protected Set JavaDoc<String JavaDoc> getLegalOptionalCreateKeys() {
52         return(LEGAL_OPTIONAL_KEYS);
53     }
54
55     public ClusterRefConfigFactory(final ConfigFactoryCallback callbacks) {
56         super(callbacks);
57         final String JavaDoc containerName = getFactoryContainer().getName();
58         mOldLbConfigMBean = getOldConfigProxies().getOldLbConfig(containerName);
59     }
60         
61     protected ObjectName JavaDoc createOldChildConfig(final AttributeList JavaDoc translatedAttrs) {
62         return mOldLbConfigMBean.createClusterRef(translatedAttrs);
63     }
64
65     public ObjectName JavaDoc create(final String JavaDoc referencedClusterName,
66         final Map JavaDoc<String JavaDoc,String JavaDoc> optional) {
67
68         final String JavaDoc[] requiredParams = new String JavaDoc[] {};
69         final Map JavaDoc<String JavaDoc,String JavaDoc> params = initParams(referencedClusterName, requiredParams, optional);
70         final ObjectName JavaDoc amxName = createNamedChild(referencedClusterName, params);
71         return(amxName);
72     }
73
74     public ObjectName JavaDoc create(final String JavaDoc referencedClusterName,
75         final String JavaDoc lbPolicy, final String JavaDoc lbPolicyModule) {
76
77         final Map JavaDoc<String JavaDoc,String JavaDoc> optionalParams = new java.util.HashMap JavaDoc<String JavaDoc,String JavaDoc>();
78         optionalParams.put(ClusterRefConfigCR.LB_POLICY_KEY,lbPolicy);
79         optionalParams.put(ClusterRefConfigCR.LB_POLICY_MODULE_KEY,lbPolicyModule);
80
81         return create(referencedClusterName, optionalParams);
82     }
83
84     public void removeByName(final String JavaDoc referencedClusterName) {
85         mOldLbConfigMBean.removeClusterRefByRef(referencedClusterName);
86     }
87 }
Popular Tags