KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
25  */

26
27
28 package com.sun.enterprise.management.config;
29
30 import java.util.Set JavaDoc;
31 import java.util.Map JavaDoc;
32
33 import javax.management.AttributeList JavaDoc;
34 import javax.management.ObjectName JavaDoc;
35
36 import com.sun.appserv.management.base.Util;
37 import com.sun.appserv.management.config.AMXConfig;
38 import com.sun.appserv.management.config.ServerRefConfigCR;
39 import com.sun.appserv.management.config.ClusterConfig;
40 import com.sun.appserv.management.config.LBConfig;
41
42 import com.sun.appserv.management.util.misc.MapUtil;
43 import com.sun.appserv.management.util.misc.GSetUtil;
44
45 import com.sun.enterprise.management.support.oldconfig.OldLbConfig;
46 import com.sun.enterprise.management.support.oldconfig.OldClusterMBean;
47 import com.sun.enterprise.management.support.oldconfig.OldCreateRemoveServerRef;
48
49
50 final class ServerRefConfigFactory extends ConfigFactory
51 {
52     public ServerRefConfigFactory(final ConfigFactoryCallback callbacks)
53     {
54         super( callbacks );
55     }
56                 
57         protected Map JavaDoc<String JavaDoc,String JavaDoc>
58     getParamNameOverrides()
59     {
60         return( MapUtil.newMap( CONFIG_NAME_KEY, "ref" ) );
61     }
62
63     private final Set JavaDoc<String JavaDoc> LEGAL_OPTIONAL_KEYS =
64         GSetUtil.newUnmodifiableStringSet(
65                 ServerRefConfigCR.DISABLE_TIMEOUT_IN_MINUTES_KEY,
66                 ServerRefConfigCR.LB_ENABLED_KEY,
67                 ServerRefConfigCR.ENABLED_KEY );
68
69         protected Set JavaDoc<String JavaDoc> getLegalOptionalCreateKeys() {
70         return( LEGAL_OPTIONAL_KEYS );
71     }
72         
73         private OldCreateRemoveServerRef
74     getOldCreateRemoveServerRef()
75     {
76         final ServerRefConfigCR fc = (ServerRefConfigCR)getFactoryContainer();
77         final String JavaDoc name = Util.asAMX( fc ).getName();
78         
79         OldCreateRemoveServerRef result = null;
80         if ( fc instanceof ClusterConfig )
81         {
82             result = getOldConfigProxies().getOldClusterMBean( name );
83         }
84         else if ( fc instanceof LBConfig )
85         {
86             result = getOldConfigProxies().getOldLbConfig( name );
87         }
88         
89         return result;
90     }
91     
92         protected ObjectName JavaDoc
93     createOldChildConfig( final AttributeList JavaDoc translatedAttrs )
94     {
95         return getOldCreateRemoveServerRef().createServerRef(translatedAttrs);
96     }
97
98         public ObjectName JavaDoc
99     create(
100         final String JavaDoc referencedServerName,
101         final Map JavaDoc<String JavaDoc,String JavaDoc> optional)
102     {
103         final String JavaDoc[] requiredParams = new String JavaDoc[] {};
104
105         final Map JavaDoc<String JavaDoc,String JavaDoc> params =
106             initParams(referencedServerName, requiredParams, optional);
107
108         final ObjectName JavaDoc amxName = createNamedChild(referencedServerName, params );
109
110         return( amxName );
111     }
112
113         public ObjectName JavaDoc
114     create(
115         final String JavaDoc referencedServerName,
116         final String JavaDoc disableTimeoutInMinutes,
117         final boolean lbEnabled,
118         final boolean enabled)
119     {
120         final Map JavaDoc<String JavaDoc,String JavaDoc> optionalParams = new java.util.HashMap JavaDoc<String JavaDoc,String JavaDoc>();
121         optionalParams.put( ServerRefConfigCR.DISABLE_TIMEOUT_IN_MINUTES_KEY,disableTimeoutInMinutes);
122         optionalParams.put( ServerRefConfigCR.LB_ENABLED_KEY,Boolean.toString(lbEnabled));
123         optionalParams.put( ServerRefConfigCR.ENABLED_KEY,Boolean.toString(enabled));
124
125         return create(referencedServerName, optionalParams);
126     }
127
128     public void removeByName(final String JavaDoc referencedServerName)
129     {
130         getOldCreateRemoveServerRef().removeServerRefByRef(referencedServerName);
131     }
132 }
133
134
135
136
Popular Tags