KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > registry > MonitoredObjectType


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  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28
29 /*
30  * MonitoredObjectType.java
31  *
32  * Created on August 18, 2003, 3:02 PM
33  */

34
35 package com.sun.enterprise.admin.monitor.registry;
36 //import com.sun.enterprise.config.serverbeans.*;
37
import java.util.HashMap JavaDoc;
38
39 /**
40  * MonitoredObjectType represents the type of a monitored object. Many of
41  * monitored objects have same properties, even while they monitor different
42  * user objects. For example - application and standalone ejb module are both
43  * nothing more than containers of other objects -- application contains web
44  * module and ejb modules, whereas standalone ejb module contains beans of
45  * various types. This object facilitates use of same GenericMonitorMBean
46  * as MBean for both of them, but still distinguishes them.
47  * @see com.iplanet.ias.admin.monitor.GenericMonitorMBean
48  * @author Originally authored by Abhijit Kumar
49  * @author Copied from S1AS 7.0 source and modified by Shreedhar Ganapathy
50  */

51 public class MonitoredObjectType {
52
53     /**
54      * A map to store all objects of type MonitoredObjectType using their string
55      * representation as key.
56      */

57     private static final HashMap JavaDoc objectMap = new HashMap JavaDoc();
58
59     /** ROOT MonitoredObject - singleton */
60     public static final MonitoredObjectType ROOT = new MonitoredObjectType("root", true);
61     /** Parent of all applications and modules and other children - singleton */
62     public static final MonitoredObjectType APPLICATIONS = new MonitoredObjectType("applications", true);
63     /** MonitoredObjectType for any deployed application - multiple */
64     public static final MonitoredObjectType APPLICATION = new MonitoredObjectType("application");
65     /** An ejb module within an application - multiple */
66     public static final MonitoredObjectType EJBMODULE = new MonitoredObjectType("ejb-module");
67     /** A web module within an application - multiple */
68     public static final MonitoredObjectType WEBMODULE = new MonitoredObjectType("web-module");
69     /** A standalone ejb module - multiple */
70     public static final MonitoredObjectType STANDALONE_EJBMODULE = new MonitoredObjectType("standalone-ejb-module");
71     /** A standalone web module - multiple */
72     public static final MonitoredObjectType STANDALONE_WEBMODULE = new MonitoredObjectType("standalone-web-module");
73     /** A stateless session bean - multiple */
74     public static final MonitoredObjectType STATELESS_BEAN = new MonitoredObjectType("stateless-session-bean");
75     /** A stateful session bean - multiple */
76     public static final MonitoredObjectType STATEFUL_BEAN = new MonitoredObjectType("stateful-session-bean");
77     /** A entity session bean - multiple */
78     public static final MonitoredObjectType ENTITY_BEAN = new MonitoredObjectType("entity-bean");
79     /** A message driven bean - multiple */
80     public static final MonitoredObjectType MESSAGE_DRIVEN_BEAN = new MonitoredObjectType("message-driven-bean");
81     /** An ejb pool - one per ejb */
82     public static final MonitoredObjectType BEAN_POOL = new MonitoredObjectType("bean-pool", true);
83     /** An ejb cache - one per ejb */
84     public static final MonitoredObjectType BEAN_CACHE = new MonitoredObjectType("bean-cache", true);
85     /* An ejb method - multiple */
86     public static final MonitoredObjectType BEAN_METHOD = new MonitoredObjectType("bean-method");
87     /* All ejb methods - one per ejb */
88     public static final MonitoredObjectType BEAN_METHODS = new MonitoredObjectType("bean-methods", true);
89     /** A servlet - multiple */
90     public static final MonitoredObjectType SERVLET = new MonitoredObjectType("servlet");
91     /** Http Service node - singleton */
92     public static final MonitoredObjectType HTTP_SERVICE = new MonitoredObjectType("http-service", true);
93     /** Virtual server - multiple */
94     public static final MonitoredObjectType VIRTUAL_SERVER = new MonitoredObjectType("virtual-server");
95     /** webmodule-virtualserver, fix for 6172666*/
96     public static final MonitoredObjectType WEBAPP_VIRTUAL_SERVER = new MonitoredObjectType("webmodule-virtual-server");
97     /** Http Listener - multiple */
98     public static final MonitoredObjectType HTTP_LISTENER = new MonitoredObjectType("http-listener");
99     /** JVM - singleton */
100     public static final MonitoredObjectType JVM = new MonitoredObjectType("jvm", true);
101     /** Transaction service - singleton */
102     public static final MonitoredObjectType TRANSACTION_SERVICE = new MonitoredObjectType("transaction-service", true);
103     /** Thread pools - singleton */
104     public static final MonitoredObjectType THREAD_POOLS = new MonitoredObjectType("thread-pools", true);
105     /** A named thead pool - multiple */
106     public static final MonitoredObjectType THREAD_POOL = new MonitoredObjectType("thread-pool");
107     /** ORB - singleton */
108     public static final MonitoredObjectType ORB = new MonitoredObjectType("orb", true);
109     /** Connection Managers - singleton */
110     public static final MonitoredObjectType CONNECTION_MANAGERS = new MonitoredObjectType("connection-managers", true);
111     /** A Connection Manager for orb - multiple */
112     public static final MonitoredObjectType CONNECTION_MANAGER = new MonitoredObjectType("connection-manager", true);
113     /** All the monitorable resources - singleton*/
114     public static final MonitoredObjectType RESOURCES = new MonitoredObjectType("resources", true);
115     /** A monitorable jdbc connection pool - multiple */
116     public static final MonitoredObjectType JDBC_CONN_POOL = new MonitoredObjectType("jdbc-connection-pool");
117     /** A monitorable connector connection pool - multiple */
118     public static final MonitoredObjectType CONNECTOR_CONN_POOL = new MonitoredObjectType("connector-connection-pool");
119     
120     /** Any EJB -- not used in hierarchy -- mainly for notification */
121     public static final MonitoredObjectType EJB = new MonitoredObjectType("ejb");
122     /** Any Web Container Element -- not used in hierarchy -- mainly for notification */
123     public static final MonitoredObjectType WEB_COMPONENT = new MonitoredObjectType("web-component");
124         
125         /** Jndi monitoring */
126     public static final MonitoredObjectType JNDI = new MonitoredObjectType("jndi", true);
127     
128     // for connector monitoring
129
public static final MonitoredObjectType CONNECTOR_SERVICE = new MonitoredObjectType("connector-service", true);
130     public static final MonitoredObjectType CONNECTOR_MODULE = new MonitoredObjectType("connector-module");
131     public static final MonitoredObjectType STANDALONE_CONNECTOR_MODULE = new MonitoredObjectType("standalone-connector-module");
132     public static final MonitoredObjectType CONNECTOR_WORKMGMT = new MonitoredObjectType("work-management", true);
133     public static final MonitoredObjectType JMS_SERVICE = new MonitoredObjectType("jms-service", true);
134     public static final MonitoredObjectType CONNECTION_FACTORIES = new MonitoredObjectType("connection-factories", true);
135     public static final MonitoredObjectType CONNECTION_FACTORY = new MonitoredObjectType("connection-factory");
136     public static final MonitoredObjectType CONNECTION_POOLS = new MonitoredObjectType("connection-pools", true);
137     // for PWC Monitoring
138
public static final MonitoredObjectType CONNECTION_QUEUE = new MonitoredObjectType("connection-queue", true);
139     public static final MonitoredObjectType DNS = new MonitoredObjectType("dns", true);
140     public static final MonitoredObjectType KEEP_ALIVE = new MonitoredObjectType("keep-alive", true);
141     public static final MonitoredObjectType PWC_THREAD_POOL = new MonitoredObjectType("pwc-thread-pool", true);
142     public static final MonitoredObjectType FILE_CACHE = new MonitoredObjectType("file-cache", true);
143     public static final MonitoredObjectType REQUEST = new MonitoredObjectType("request", true);
144     
145     // for StatefulSessionStore Monitoring
146
public static final MonitoredObjectType SESSION_STORE = new MonitoredObjectType("stateful-session-store", true);
147     
148     // for Timer Monitoring
149
public static final MonitoredObjectType TIMERS = new MonitoredObjectType("timers", true);
150     
151     // for JVM1.5 Monitoring
152
public static final MonitoredObjectType JVM_COMPILATION = new MonitoredObjectType("compilation-system", true);
153     public static final MonitoredObjectType JVM_CLASSLOADING = new MonitoredObjectType("class-loading-system", true);
154     public static final MonitoredObjectType JVM_OS = new MonitoredObjectType("operating-system", true);
155     public static final MonitoredObjectType JVM_RUNTIME = new MonitoredObjectType("runtime", true);
156     public static final MonitoredObjectType JVM_GCS = new MonitoredObjectType("garbage-collectors", true);
157     public static final MonitoredObjectType JVM_GC = new MonitoredObjectType("garbage-collector");
158     public static final MonitoredObjectType JVM_MEMORY = new MonitoredObjectType("memory", true);
159     public static final MonitoredObjectType JVM_THREAD = new MonitoredObjectType("thread-system", true);
160     public static final MonitoredObjectType JVM_THREAD_INFO = new MonitoredObjectType("threadinfo");
161    
162         
163     /** A web service endpoint with in an ejb or web module - multiple */
164     public static final MonitoredObjectType WEBSERVICE_ENDPOINT =
165         new MonitoredObjectType("webservice-endpoint");
166
167     /**
168      * value of this object as a string
169      */

170     private String JavaDoc typeName;
171
172     /**
173      * Denotes whether this type allows more than one instance at any level.
174      */

175     private boolean isSingleton;
176
177     /**
178      * Creates a new instance of MonitoredObjectType using specified string type
179      * @param type string representing the name of monitored object type
180      */

181     private MonitoredObjectType(String JavaDoc type) {
182         this(type, false);
183     }
184
185     /**
186      * Creates a new instance of MonitoredObjectType using specified string type
187      * and specified flag for singleton
188      * @param type string representing the name of monitored object type
189      * @param isSingleton denotes whether this type of monitored object has
190      * only one instance (in its context)
191      */

192     private MonitoredObjectType(String JavaDoc type, boolean isSingleton) {
193         this.typeName = type;
194         this.isSingleton = isSingleton;
195         objectMap.put(this.typeName, this);
196     }
197
198     /**
199      * Get type of this "MonitoredObjectType" as string
200      * @return Monitored object type as string
201      */

202     public String JavaDoc getTypeName() {
203         return typeName;
204     }
205
206     /**
207      * Is instance of this type of MonitorMBean singleton. For example, there
208      * can only be one pool for every stateless session bean, so a
209      * MonitoredObjectType of type MonitoredObjectType.BEAN_POOL is a singleton.
210      * @return true if this type of object can have atmost one instance within
211      * its context, false otherwise.
212      */

213     public boolean isSingleton() {
214         return isSingleton;
215     }
216
217     /**
218      * A string representation. The return value of this method is
219      * same as that of method getTypeName.
220      * @return A string representation of this MonitoredObjectType
221      */

222     public String JavaDoc toString() {
223         return typeName;
224     }
225     /**
226      * Get a MonitoredObjectType instance for the specified string type.
227      * @param typeName string representing MonitoredObjectType
228      * @throws IllegalArgumentException if the specified type name is not
229      * known.
230      */

231     public static MonitoredObjectType getMonitoredObjectType(String JavaDoc typeName) {
232         MonitoredObjectType type = getMonitoredObjectTypeOrNull(typeName);
233         if (type == null) {
234             //String msg = localStrings.getString( "admin.monitor.unknown_type_name", typeName );
235
String JavaDoc msg = "admin.monitor.unknown_type_name:"+typeName;
236             throw new IllegalArgumentException JavaDoc( msg );
237         }
238         return type;
239     }
240
241     /**
242      * Get a MonitoredObjectType instance for the specified string type. If the
243      * specified type is not known, the method returns null.
244      * @param typeName string representing MonitoredObjectType
245      */

246     static MonitoredObjectType getMonitoredObjectTypeOrNull(String JavaDoc typeName) {
247         MonitoredObjectType type = null;
248         if (objectMap != null && typeName != null) {
249             type = (MonitoredObjectType)objectMap.get(typeName);
250         }
251         return type;
252     }
253
254     /**
255      * List of monitored object types for ejb container - actually unsafe :(
256      */

257     public static final MonitoredObjectType[] EJB_TYPES =
258     new MonitoredObjectType[] {
259         MonitoredObjectType.EJB, //general ejb-type
260
MonitoredObjectType.EJBMODULE,
261         MonitoredObjectType.STANDALONE_EJBMODULE,
262         MonitoredObjectType.STATELESS_BEAN,
263         MonitoredObjectType.STATEFUL_BEAN,
264         MonitoredObjectType.ENTITY_BEAN,
265         MonitoredObjectType.BEAN_POOL,
266         MonitoredObjectType.BEAN_CACHE,
267         MonitoredObjectType.BEAN_METHOD,
268         MonitoredObjectType.SESSION_STORE,
269         MonitoredObjectType.TIMERS};
270
271     /**
272      * List of monitored object types for orb - actually unsafe :(
273      */

274     public static final MonitoredObjectType[] ORB_TYPES =
275     new MonitoredObjectType[] {
276         MonitoredObjectType.ORB,
277         MonitoredObjectType.CONNECTION_MANAGER,
278         MonitoredObjectType.CONNECTION_MANAGERS};
279
280     /**
281      * List of MonitoredObjectTypes for Http Service - actually unsafe :( - should be unmodifiable array list
282      */

283     public static final MonitoredObjectType[] HTTP_SERVICE_TYPES =
284     new MonitoredObjectType[] {
285         MonitoredObjectType.HTTP_SERVICE,
286         MonitoredObjectType.HTTP_LISTENER,
287         MonitoredObjectType.VIRTUAL_SERVER};
288 }
289
Popular Tags