KickJava   Java API By Example, From Geeks To Geeks.

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


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  * $Header: /cvs/glassfish/admin/mbeanapi-impl/src/java/com/sun/enterprise/management/config/HealthCheckerConfigFactory.java,v 1.7 2006/03/09 20:30:38 llc Exp $
26  * $Revision: 1.7 $
27  * $Date: 2006/03/09 20:30:38 $
28  */

29 package com.sun.enterprise.management.config;
30
31 import java.util.Set JavaDoc;
32 import java.util.HashSet JavaDoc;
33 import java.util.Iterator JavaDoc;
34 import java.util.Map JavaDoc;
35 import java.util.HashMap JavaDoc;
36 import java.util.Properties JavaDoc;
37 import java.util.Collections JavaDoc;
38
39 import static com.sun.appserv.management.base.XTypes.SERVER_REF_CONFIG;
40 import static com.sun.appserv.management.base.XTypes.CLUSTER_REF_CONFIG;
41 import javax.management.Attribute JavaDoc;
42 import javax.management.AttributeList JavaDoc;
43 import javax.management.ObjectName JavaDoc;
44
45 import com.sun.appserv.management.util.misc.GSetUtil;
46 import static com.sun.appserv.management.config.HealthCheckerConfigKeys.*;
47
48 final class HealthCheckerConfigFactory extends ConfigFactory {
49
50     public HealthCheckerConfigFactory(final ConfigFactoryCallback callbacks) {
51         super( callbacks );
52     }
53
54     private final Set JavaDoc<String JavaDoc> LEGAL_OPTIONAL_KEYS =
55         GSetUtil.newUnmodifiableStringSet(
56             URL_KEY,
57             INTERVAL_IN_SECONDS_KEY,
58             TIMEOUT_IN_SECONDS_KEY);
59
60     protected Set JavaDoc<String JavaDoc> getLegalOptionalCreateKeys() {
61         return(LEGAL_OPTIONAL_KEYS);
62     }
63
64     protected ObjectName JavaDoc createOldChildConfig(final AttributeList JavaDoc translatedAttrs) {
65         final String JavaDoc containerName = getFactoryContainer().getName();
66         if (getFactoryContainer().getJ2EEType().equals(CLUSTER_REF_CONFIG)) {
67             return getOldConfigProxies().getOldClusterRefMBean(
68                 containerName).createHealthChecker(translatedAttrs);
69         } else if (getFactoryContainer().getJ2EEType().equals(SERVER_REF_CONFIG)) {
70             return getOldConfigProxies().getOldServerRefMBean(
71                 containerName).createHealthChecker(translatedAttrs);
72         }
73         return null;
74     }
75
76     public ObjectName JavaDoc create(String JavaDoc url, String JavaDoc intervalInSeconds, String JavaDoc timeoutInSeconds)
77     {
78         Map JavaDoc<String JavaDoc,String JavaDoc> optional = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
79         optional.put(URL_KEY, url);
80         optional.put(INTERVAL_IN_SECONDS_KEY, intervalInSeconds);
81         optional.put(TIMEOUT_IN_SECONDS_KEY, timeoutInSeconds);
82         
83         final Map JavaDoc<String JavaDoc,String JavaDoc> params = initParams(optional);
84         final ObjectName JavaDoc amxName = createChild(params);
85         return amxName;
86     }
87
88     public void remove(String JavaDoc name) {
89         final String JavaDoc containerName = getFactoryContainer().getName();
90         if (getFactoryContainer().getJ2EEType().equals(CLUSTER_REF_CONFIG)) {
91             getOldConfigProxies().getOldClusterRefMBean(containerName).removeHealthChecker();
92         } else if (getFactoryContainer().getJ2EEType().equals(SERVER_REF_CONFIG)) {
93             getOldConfigProxies().getOldServerRefMBean(containerName).removeHealthChecker();
94         }
95     }
96 }
Popular Tags