KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > mbeans > custom > CustomMBeanConstants


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.admin.mbeans.custom;
25 import java.util.Collections JavaDoc;
26 import java.util.HashMap JavaDoc;
27 import java.util.HashSet JavaDoc;
28 import java.util.Map JavaDoc;
29 import java.util.Set JavaDoc;
30 import com.sun.enterprise.config.serverbeans.ServerTags;
31 import javax.management.ObjectName JavaDoc;
32
33 /** Class that holds the constant fields used by custom MBean deployment/registration code.
34  */

35 public class CustomMBeanConstants {
36     
37     private CustomMBeanConstants() {
38     }
39     /** Represents the key for the name of a custom MBean.
40      */

41     public static final String JavaDoc NAME_KEY = ServerTags.NAME;
42     /** Represents the key for the object-name of a custom MBean.
43      */

44     public static final String JavaDoc OBJECT_NAME_KEY = ServerTags.OBJECT_NAME;
45
46     /** Represents the key for the class-name of a custom MBean.
47      */

48     public static final String JavaDoc IMPL_CLASS_NAME_KEY = ServerTags.IMPL_CLASS_NAME;
49     
50     /** Represents the key for the object-type of the custom MBean.
51      */

52     public static final String JavaDoc OBJECT_TYPE_KEY = ServerTags.OBJECT_TYPE;
53     
54     /** Represents the key for server where the custom MBean is created.
55      */

56     public static final String JavaDoc SERVER_KEY = ServerTags.SERVER;
57     
58     /** Represents the key for enabled flag on the custom MBean.
59      */

60     public static final String JavaDoc ENABLED_KEY = ServerTags.ENABLED;
61     /** Represents the user-defined MBean.
62      */

63     public static final int USER_DEFINED = 0;
64     /** Represents a "system-all" MBean.
65      */

66     public static final int SYSTEM_ALL = 1;
67     /** Represents a "system-admin" MBean.
68      */

69     public static final int SYSTEM_ADMIN = 2;
70     
71     /** LocalStrings in this package
72      */

73     public static final String JavaDoc CMB_LOCAL = "com.sun.enterprise.admin.mbeans.custom.LocalStrings";
74     
75     /** LocalStrings in loading package
76      */

77     public static final String JavaDoc CMB_LOADING_LOCAL = "com.sun.enterprise.admin.mbeans.custom.loading.LocalStrings";
78
79     /** LocalStrings in ee package
80      */

81     public static final String JavaDoc CMB_EE_LOCAL = "com.sun.enterprise.ee.admin.mbeans.LocalStrings";
82     
83     /** LogStrings
84      */

85     public static final String JavaDoc CMB_LOG = "com.sun.logging.enterprise.system.tools.admin.LogStrings";
86     
87     public static final String JavaDoc CUSTOM_MBEAN_DOMAIN = "user";
88     private static final Set JavaDoc<Integer JavaDoc> iSet;
89     static {
90         iSet = new HashSet JavaDoc<Integer JavaDoc> ();
91         iSet.add(USER_DEFINED);
92         iSet.add(SYSTEM_ALL);
93         iSet.add(SYSTEM_ADMIN); //use autoboxing wherever possible
94
}
95     public static final Set JavaDoc<Integer JavaDoc> MBEAN_TYPES = Collections.unmodifiableSet(iSet);
96     
97     
98     /** Returns an unmodifiable Map that contains the given valid mapping for this class.
99      * Note that the valid keys are defined as the fields of this class.
100      * @see #OBJECT_NAME_KEY
101      * @see #NAME_KEY
102      * @see #IMPL_CLASS_NAME_KEY
103      */

104     public static final Map JavaDoc<String JavaDoc, String JavaDoc> unmodifiableMap(final String JavaDoc key, final String JavaDoc value) throws IllegalArgumentException JavaDoc {
105         final boolean vk = OBJECT_NAME_KEY.equals(key) || IMPL_CLASS_NAME_KEY.equals(key) || NAME_KEY.equals(key);
106         if (!vk)
107             throw new IllegalArgumentException JavaDoc(CMBStrings.get("InternalError", "invalid arg")); //TODO
108
if (value == null)
109             throw new IllegalArgumentException JavaDoc(CMBStrings.get("InternalError", "can't be null value")); //TODO
110
final Map JavaDoc<String JavaDoc, String JavaDoc> m = new HashMap JavaDoc<String JavaDoc, String JavaDoc> ();
111         m.put(key, value);
112         return ( Collections.unmodifiableMap(m) );
113     }
114 }
Popular Tags