KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > registry > spi > MonitoringRegistrationHelper


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 /* MonitoringRegistrationHelper.java
25  * $Id: MonitoringRegistrationHelper.java,v 1.8 2006/03/08 19:59:37 sirajg Exp $
26  * $Revision: 1.8 $
27  * $Date: 2006/03/08 19:59:37 $
28  * Indentation Information:
29  * 0. Please (try to) preserve these settings.
30  * 1. Tabs are preferred over spaces.
31  * 2. In vi/vim -
32  * :set tabstop=4 :set shiftwidth=4 :set softtabstop=4
33  * 3. In S1 Studio -
34  * 1. Tools->Options->Editor Settings->Java Editor->Tab Size = 4
35  * 2. Tools->Options->Indentation Engines->Java Indentation Engine->Expand Tabs to Spaces = False.
36  * 3. Tools->Options->Indentation Engines->Java Indentation Engine->Number of Spaces per Tab = 4.
37  */

38
39
40 package com.sun.enterprise.admin.monitor.registry.spi;
41
42 import com.sun.enterprise.admin.monitor.registry.*;
43 import com.sun.enterprise.admin.monitor.stats.*;
44 import javax.management.*;
45 import javax.management.j2ee.statistics.*;
46 import java.util.*;
47 import java.util.logging.Logger JavaDoc;
48 import com.sun.enterprise.admin.common.constant.AdminConstants; // for logger name
49
import com.sun.enterprise.util.i18n.StringManager;
50 // for config and dynamic reconfig
51
import com.sun.enterprise.admin.event.AdminEventListenerRegistry;
52 import com.sun.enterprise.admin.monitor.jndi.JndiMBeanManager;
53 import com.sun.enterprise.admin.monitor.registry.spi.reconfig.MonitoringConfigurationHandler;
54 import com.sun.enterprise.admin.monitor.registry.spi.reconfig.DynamicReconfigurator;
55 import com.sun.enterprise.admin.monitor.registry.spi.reconfig.MonitoringConfigChangeListener;
56 import com.sun.enterprise.server.stats.JVMStatsImpl;
57 /**
58  * Enables components to register their Stats implementation for monitoring.
59  * This implementation provides a way for a JSR77 Managed Component's monitoring
60  * statistics to be presented through JMX's API by means of a Dynamic MBean
61  * created by introspecting the Stats object and registered with the MBeanServer.
62  * Also provides ability to unregister and to check if a component is registered
63  * successfully.
64  * As this is a registration facilitator for all components, this is a Singleton
65  * @author Shreedhar Ganapathy
66  * @author Kedar Mhaswade
67  */

68 public class MonitoringRegistrationHelper implements MonitoringRegistry {
69     private static final Logger JavaDoc logger = Logger.getLogger(AdminConstants.kLoggerName);
70     private static final StringManager sm = StringManager.getManager(MonitoringRegistrationHelper.class);
71     private final MBeanServer mbeanserver;
72     Vector listeners = new Vector();
73     private final ValueListMap objTypeListeners;
74     private static MonitoringRegistrationHelper mrh = new MonitoringRegistrationHelper();
75     private final StatsHolder rootStatsHolder =
76         new StatsHolderImpl(MonitoredObjectType.ROOT.getTypeName(), MonitoredObjectType.ROOT);
77     
78     private MonitoringRegistrationHelper(){
79         mbeanserver = getMBeanServer();
80         objTypeListeners = new ValueListMap();
81         initialize(); //initializes the basic tree.
82
AdminEventListenerRegistry.addMonitoringLevelChangeEventListener(
83             new MonitoringConfigChangeListener(new DynamicReconfigurator(objTypeListeners)));
84     }
85     
86     /** Returns a created or new instance of MonitoringRegistrationHelper.
87      * Initializes MBeanServer to which a DynamicMBean will be registered for
88      * each component registering its Stats object.
89      */

90     public static MonitoringRegistrationHelper getInstance() {
91         return mrh;
92     }
93     
94     private MBeanServer getMBeanServer() {
95         MBeanServer server=null;
96         ArrayList servers = MBeanServerFactory.findMBeanServer(null);
97         if(!servers.isEmpty()){
98             server = (MBeanServer)servers.get(0);
99         }
100         else {
101             final String JavaDoc msg = sm.getString("gen.no_mbs");
102             throw new NullPointerException JavaDoc(msg);
103         }
104         return server;
105     }
106    
107     public void registerEJBCacheStats(EJBCacheStats cs, String JavaDoc ejb,
108     String JavaDoc module, String JavaDoc app, MonitoringLevelListener listener)
109     throws MonitoringRegistrationException {
110         StatsHolder currChild = null;
111         String JavaDoc dottedName = null;
112         final String JavaDoc name = MonitoredObjectType.BEAN_CACHE.getTypeName();
113
114         if (cs == null || module == null || ejb == null) // app can be null
115
throw new IllegalArgumentException JavaDoc("MRH:EjbCacheStats, module, ejb can't be null");
116         addMonitoringLevelListener(listener); //listener can be null
117
currChild = getEjb(app, module, ejb);
118         currChild = currChild.addChild(name, MonitoredObjectType.BEAN_CACHE);
119         currChild.setStats(cs);
120         currChild.setStatsClass(com.sun.enterprise.admin.monitor.stats.EJBCacheStats.class);
121         final ObjectName on = MonitoringObjectNames.getEjbCacheObjectName(ejb, module, app);
122         currChild.setObjectName(on);
123         currChild.setDottedName(DottedNameFactory.getEJBCacheDottedName(app, module,ejb));
124         if (shouldRegisterMBean(MonitoredObjectType.BEAN_CACHE))
125             currChild.registerMBean();
126     }
127
128     public void unregisterEJBCacheStats(String JavaDoc ejb, String JavaDoc module, String JavaDoc app)
129     throws MonitoringRegistrationException {
130
131         StatsHolder currChild = null;
132         StatsHolder cacheNode = null;
133         final String JavaDoc name = MonitoredObjectType.BEAN_CACHE.getTypeName();
134         currChild = getEjb(app, module, ejb);
135         assert (currChild != null) : "MRH:unregisterEJBCacheStats: method registerEJBCacheStats was never called";
136         cacheNode = currChild.getChild(name);
137         cacheNode.unregisterMBean();
138         currChild.removeChild(name);
139     }
140
141     
142     public void registerEJBPoolStats(EJBPoolStats ps, String JavaDoc ejb,
143     String JavaDoc module, String JavaDoc app, MonitoringLevelListener listener)
144     throws MonitoringRegistrationException {
145
146         StatsHolder currChild = null;
147         String JavaDoc dottedName = null;
148         final String JavaDoc name = MonitoredObjectType.BEAN_POOL.getTypeName();
149         
150         if (ps == null || module == null || ejb == null) // app can be null
151
throw new IllegalArgumentException JavaDoc("MRH:EjbPoolStats, module, ejb can't be null");
152         
153         addMonitoringLevelListener(listener); //listener can be null
154
currChild = getEjb(app, module, ejb);
155         currChild = currChild.addChild(name, MonitoredObjectType.BEAN_POOL);
156         currChild.setStats(ps);
157         currChild.setStatsClass(com.sun.enterprise.admin.monitor.stats.EJBPoolStats.class);
158         final ObjectName on = MonitoringObjectNames.getEjbPoolObjectName(ejb, module, app);
159         currChild.setObjectName(on);
160         currChild.setDottedName(DottedNameFactory.getEJBPoolDottedName(app, module,ejb));
161         if (shouldRegisterMBean(MonitoredObjectType.BEAN_POOL))
162             currChild.registerMBean();
163     }
164
165     public void unregisterEJBPoolStats(String JavaDoc ejb, String JavaDoc module, String JavaDoc app)
166     throws MonitoringRegistrationException {
167
168         StatsHolder currChild = null;
169         StatsHolder poolNode = null;
170         final String JavaDoc name = MonitoredObjectType.BEAN_POOL.getTypeName();
171         currChild = getEjb(app, module, ejb);
172         assert (currChild != null) : "MRH:unregisterEJBPoolStats: method registerEJBPoolStats was never called";
173         poolNode = currChild.getChild(name);
174         poolNode.unregisterMBean();
175         currChild.removeChild(name);
176     }
177
178     public void registerEJBMethodStats(EJBMethodStats ms, String JavaDoc method,
179     String JavaDoc ejb, String JavaDoc module, String JavaDoc app, MonitoringLevelListener listener)
180     throws MonitoringRegistrationException {
181
182         StatsHolder currChild = null;
183         String JavaDoc dottedName = null;
184         
185         if (ms == null || module == null || ejb == null) // app can be null
186
throw new IllegalArgumentException JavaDoc("MRH:EjbMethodStats, module, ejb can't be null");
187         
188         addMonitoringLevelListener(listener); //listener can be null
189
currChild = getEjbMethods(app, module, ejb);
190         currChild = currChild.addChild(method, MonitoredObjectType.BEAN_METHOD);
191         currChild.setStats(ms);
192         currChild.setStatsClass(com.sun.enterprise.admin.monitor.stats.EJBMethodStats.class);
193         final ObjectName on = MonitoringObjectNames.getEjbMethodObjectName(method, ejb, module, app);
194         currChild.setObjectName(on);
195         currChild.setDottedName(DottedNameFactory.getEJBMethodDottedName(app, module, ejb, method));
196         if (shouldRegisterMBean(MonitoredObjectType.BEAN_METHOD))
197             currChild.registerMBean();
198     }
199
200     public void unregisterEJBMethodStats(String JavaDoc method, String JavaDoc ejb,
201     String JavaDoc module, String JavaDoc app) throws MonitoringRegistrationException {
202
203         if ( method == null || ejb == null || module == null)
204             throw new IllegalArgumentException JavaDoc("MRH: unregister method called with null arguments");
205         StatsHolder currChild = null;
206         StatsHolder methodNode = null;
207         currChild = getEjbMethods(app, module, ejb);
208         assert (currChild != null) : "Serious: EjbMethodsNode is not created at all";
209         methodNode = currChild.getChild(method);
210         assert (methodNode != null) : "MRH:unregisterEJBMethodStats - methodNode null";
211         methodNode.unregisterMBean();
212         currChild.removeChild(method);
213     }
214     
215     private void registerAnyEjbStats(EJBStats es, MonitoredObjectType ejbType,
216     String JavaDoc ejb, String JavaDoc module, String JavaDoc app, MonitoringLevelListener listener)
217     throws MonitoringRegistrationException {
218         StatsHolder currChild = null;
219         String JavaDoc dottedName = null;
220         
221         if (es == null || module == null || ejb == null) // app can be null
222
throw new IllegalArgumentException JavaDoc("MRH:registerEntityBeanStats, module, ejb can't be null");
223         
224         addMonitoringLevelListener(listener); //listener can be null
225
currChild = getEjb(app, module, ejb);
226         assert (currChild != null) : "MRH:registerEntityBeanStats - Serious: EjbNode is null";
227         currChild.setStats(es);
228         this.setEjbStatsClass(currChild, ejbType);
229         currChild.setType(ejbType); // this is the real type
230

231         final ObjectName on = MonitoringObjectNames.getEjbObjectName(ejb, module, app);
232         currChild.setObjectName(on);
233         currChild.setDottedName(DottedNameFactory.getEJBDottedName(app, module, ejb));
234         if (shouldRegisterMBean(ejbType))
235             currChild.registerMBean();
236     }
237     private void setEjbStatsClass(StatsHolder s, MonitoredObjectType t) {
238         assert (t == MonitoredObjectType.ENTITY_BEAN ||
239                 t == MonitoredObjectType.STATEFUL_BEAN ||
240                 t == MonitoredObjectType.STATELESS_BEAN ||
241                 t == MonitoredObjectType.MESSAGE_DRIVEN_BEAN) : "Invalid Ejb Type: " + t.getTypeName();
242         if (t == MonitoredObjectType.ENTITY_BEAN)
243             s.setStatsClass(javax.management.j2ee.statistics.EntityBeanStats JavaDoc.class);
244         else if (t == MonitoredObjectType.STATEFUL_BEAN)
245             s.setStatsClass(javax.management.j2ee.statistics.StatefulSessionBeanStats JavaDoc.class);
246         else if (t == MonitoredObjectType.STATELESS_BEAN)
247             s.setStatsClass(javax.management.j2ee.statistics.StatelessSessionBeanStats JavaDoc.class);
248         else
249             s.setStatsClass(javax.management.j2ee.statistics.MessageDrivenBeanStats JavaDoc.class);
250     }
251     
252     private void unregisterAnyEjbStats(String JavaDoc ejb, String JavaDoc module, String JavaDoc app)
253     throws MonitoringRegistrationException {
254         if (module == null || ejb == null) //app can be null
255
throw new IllegalArgumentException JavaDoc("MRH: UnregisterEntityBeanStats, method and ejb name should be non-null");
256         final StatsHolder ejbRoot = getEjbRootNode(app, module);
257         assert (ejbRoot != null) : "MRH:unregisterEntityBeanStats: method registerEntityBeanStats was never called";
258         final StatsHolder ejbNode = ejbRoot.getChild(ejb);
259         assert (ejbNode != null) : "MRH:unregisterEntityBeanStats: null node received for ejb: " + ejb;
260         ejbNode.removeAllChildren();
261         ejbNode.unregisterMBean();
262         ejbRoot.removeChild(ejb);
263     }
264     
265     public void registerEntityBeanStats(EntityBeanStats es, String JavaDoc ejb,
266     String JavaDoc module, String JavaDoc app, MonitoringLevelListener listener)
267     throws MonitoringRegistrationException {
268         this.registerAnyEjbStats(es, MonitoredObjectType.ENTITY_BEAN, ejb, module, app, listener);
269     }
270     
271     public void unregisterEntityBeanStats(String JavaDoc ejb, String JavaDoc module,
272     String JavaDoc app) throws MonitoringRegistrationException {
273         this.unregisterAnyEjbStats(ejb, module, app);
274     }
275
276     public void registerStatefulSessionBeanStats(StatefulSessionBeanStats ss,
277     String JavaDoc ejb, String JavaDoc module, String JavaDoc app, MonitoringLevelListener listener)
278     throws MonitoringRegistrationException {
279         this.registerAnyEjbStats(ss, MonitoredObjectType.STATEFUL_BEAN, ejb, module, app, listener);
280     }
281
282     public void unregisterStatefulSessionBeanStats(String JavaDoc ejb, String JavaDoc module,
283     String JavaDoc app) throws MonitoringRegistrationException {
284         this.unregisterAnyEjbStats(ejb, module, app);
285     }
286     
287     public void registerStatelessSessionBeanStats(StatelessSessionBeanStats ss,
288     String JavaDoc ejb, String JavaDoc module, String JavaDoc app, MonitoringLevelListener listener)
289     throws MonitoringRegistrationException {
290         this.registerAnyEjbStats(ss, MonitoredObjectType.STATELESS_BEAN, ejb, module, app, listener);
291     }
292
293     public void unregisterStatelessSessionBeanStats(String JavaDoc ejb, String JavaDoc module,
294     String JavaDoc app) throws MonitoringRegistrationException {
295         this.unregisterAnyEjbStats(ejb, module, app);
296     }
297    
298     public void registerMessageDrivenBeanStats(MessageDrivenBeanStats ms,
299     String JavaDoc ejb, String JavaDoc module, String JavaDoc app, MonitoringLevelListener listener)
300     throws MonitoringRegistrationException {
301         this.registerAnyEjbStats(ms, MonitoredObjectType.MESSAGE_DRIVEN_BEAN, ejb, module, app, listener);
302     }
303     
304     public void unregisterMessageDrivenBeanStats(String JavaDoc ejb, String JavaDoc module,
305     String JavaDoc app) throws MonitoringRegistrationException {
306         this.unregisterAnyEjbStats(ejb, module, app);
307     }
308
309     private void registerConnectionPoolStats(ConnectionPoolStats ps, String JavaDoc name,
310     MonitoredObjectType type, MonitoringLevelListener listener)
311     throws MonitoringRegistrationException {
312         assert (type == MonitoredObjectType.JDBC_CONN_POOL || type == MonitoredObjectType.CONNECTOR_CONN_POOL) : "MRH:registerConnectionPool - type is invalid";
313         if (name == null || ps == null)
314             throw new IllegalArgumentException JavaDoc("MRH:registerConnectionPoolStats - null name");
315         final StatsHolder resourcesNode = rootStatsHolder.getChild(MonitoredObjectType.RESOURCES.getTypeName());
316         assert (resourcesNode != null) : "MRH: registerConnectionPoolStats - Resources top-level node not registered";
317         final StatsHolder added = resourcesNode.addChild(name, type);
318         assert (added != null) : "Connection Pool Addtion Error: " + name;
319         added.setStats(ps);
320         if (type == MonitoredObjectType.JDBC_CONN_POOL)
321             added.setStatsClass(com.sun.enterprise.admin.monitor.stats.JDBCConnectionPoolStats.class);
322         else
323             added.setStatsClass(com.sun.enterprise.admin.monitor.stats.ConnectorConnectionPoolStats.class);
324         final ObjectName on = MonitoringObjectNames.getConnectionPoolObjectName(name, type);
325         added.setObjectName(on);
326         added.setDottedName(DottedNameFactory.getConnectionPoolDottedName(name, type.getTypeName()));
327         if (shouldRegisterMBean(type))
328             added.registerMBean();
329     }
330     private void unregisterConnectionPoolStats(String JavaDoc name)
331     throws MonitoringRegistrationException {
332         if (name == null)
333             throw new IllegalArgumentException JavaDoc("MRH:unregisterConnectionPoolStats - null name");
334         final StatsHolder resourcesNode = rootStatsHolder.getChild(MonitoredObjectType.RESOURCES.getTypeName());
335         assert (resourcesNode != null) : "MRH: registerConnectionPoolStats - Resources top-level node not registered";
336         final StatsHolder pool = resourcesNode.getChild(name);
337         assert (pool != null) : "MRH:unregisterConnectionPoolStats - null node - Serious";
338         pool.unregisterMBean();
339         resourcesNode.removeChild(name);
340         //assert (pool == null) : "Now the reference should be null";
341
}
342     
343     public void registerJDBCConnectionPoolStats(com.sun.enterprise.admin.monitor.stats.JDBCConnectionPoolStats ps,
344     String JavaDoc name, MonitoringLevelListener listener) throws MonitoringRegistrationException {
345         this.registerConnectionPoolStats(ps, name, MonitoredObjectType.JDBC_CONN_POOL, listener);
346     }
347     
348     public void unregisterJDBCConnectionPoolStats(String JavaDoc name)
349     throws MonitoringRegistrationException {
350         this.unregisterConnectionPoolStats(name);
351     }
352
353     public void registerConnectorConnectionPoolStats(com.sun.enterprise.admin.monitor.stats.ConnectorConnectionPoolStats ps, String JavaDoc name, MonitoringLevelListener listener) throws MonitoringRegistrationException {
354         this.registerConnectionPoolStats(ps, name, MonitoredObjectType.CONNECTOR_CONN_POOL, listener);
355     }
356
357     public void unregisterConnectorConnectionPoolStats(String JavaDoc name) throws MonitoringRegistrationException {
358         this.unregisterConnectionPoolStats(name);
359     }
360     
361     public void registerOrbConnectionManagerStats(OrbConnectionManagerStats cms,
362     String JavaDoc name, MonitoringLevelListener listener)
363     throws MonitoringRegistrationException {
364         if (cms == null || name == null)
365             throw new IllegalArgumentException JavaDoc("MRH:registerOrbCMStats - null arguments");
366         final StatsHolder orb = rootStatsHolder.getChild(MonitoredObjectType.ORB.getTypeName());
367         final StatsHolder managers = orb.getChild(MonitoredObjectType.CONNECTION_MANAGERS.getTypeName());
368         assert (managers != null) : "MRH:registerOrbConnectionManagerStats ORB Node not created yet";
369         managers.setDottedName(DottedNameFactory.getConnectionManagersDottedName());
370         final StatsHolder added = managers.addChild(name, MonitoredObjectType.CONNECTION_MANAGER);
371         assert (added != null) : "Addition of Connection Manager failed: " + name;
372         added.setStats(cms);
373         added.setStatsClass(com.sun.enterprise.admin.monitor.stats.OrbConnectionManagerStats.class);
374         final ObjectName on = MonitoringObjectNames.getOrbConnectionManagerObjectName(name);
375         added.setObjectName(on);
376         added.setDottedName(DottedNameFactory.getOrbConnectionManagerDottedName(name));
377         if (shouldRegisterMBean(MonitoredObjectType.CONNECTION_MANAGER))
378             added.registerMBean();
379     }
380     
381     public void unregisterOrbConnectionManagerStats(String JavaDoc name)
382     throws MonitoringRegistrationException {
383         final StatsHolder orb = rootStatsHolder.getChild(MonitoredObjectType.ORB.getTypeName());
384         final StatsHolder managers = orb.getChild(MonitoredObjectType.CONNECTION_MANAGERS.getTypeName());
385         assert (managers != null) : "MRH:registerOrbConnectionManagerStats ORB Node not created yet";
386         final StatsHolder cm = managers.getChild(name);
387         assert ( cm != null) : "Connection Manager to be removed is null";
388         cm.unregisterMBean();
389         managers.removeChild(name);
390     }
391     
392     public void registerThreadPoolStats(ThreadPoolStats tps, String JavaDoc name,
393     MonitoringLevelListener listener) throws MonitoringRegistrationException {
394         if (tps == null || name == null)
395             throw new IllegalArgumentException JavaDoc("registerThreadPoolStats - null arguments");
396         final StatsHolder pools = rootStatsHolder.getChild(MonitoredObjectType.THREAD_POOLS.getTypeName());
397         assert (pools != null) : "ThreadPools Node not initialized";
398         final StatsHolder added = pools.addChild(name, MonitoredObjectType.THREAD_POOL);
399         assert (added != null) : "No matching thread pool: " + name;
400         added.setStats(tps);
401         added.setStatsClass(com.sun.enterprise.admin.monitor.stats.ThreadPoolStats.class);
402         final ObjectName on = MonitoringObjectNames.getThreadPoolObjectName(name);
403         added.setObjectName(on);
404         added.setDottedName(DottedNameFactory.getThreadPoolDottedName(name));
405         if (shouldRegisterMBean(MonitoredObjectType.THREAD_POOL))
406             added.registerMBean();
407     }
408     
409     public void unregisterThreadPoolStats(String JavaDoc name) throws MonitoringRegistrationException {
410         final StatsHolder tps = rootStatsHolder.getChild(MonitoredObjectType.THREAD_POOLS.getTypeName());
411         assert (tps != null) : "MRH:unregisterThreadPoolStats - null";
412         final StatsHolder tp = tps.getChild(name);
413         assert ( tp != null) : "Thread Pool to be removed is null";
414         tp.unregisterMBean();
415         tps.removeChild(name);
416     }
417
418     public void registerJTAStats(com.sun.enterprise.admin.monitor.stats.JTAStats js,
419     MonitoringLevelListener listener) throws MonitoringRegistrationException {
420         if (js == null)
421             throw new IllegalArgumentException JavaDoc("JTA - null stats provided");
422         final StatsHolder tsNode = rootStatsHolder.getChild(MonitoredObjectType.TRANSACTION_SERVICE.getTypeName());
423         assert (tsNode != null) : "MRH:registerJTAStats - Initialization failed";
424         tsNode.setStats(js);
425         tsNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.JTAStats.class);
426         if(listener != null)
427             registerMonitoringLevelListener(listener, MonitoredObjectType.TRANSACTION_SERVICE);
428         if (shouldRegisterMBean(MonitoredObjectType.TRANSACTION_SERVICE))
429             tsNode.registerMBean();
430     }
431     
432     public void unregisterJTAStats() throws MonitoringRegistrationException {
433         final String JavaDoc name = MonitoredObjectType.TRANSACTION_SERVICE.getTypeName();
434         final StatsHolder ts = rootStatsHolder.getChild(name);
435         assert (ts != null) : "Serious JTS is null";
436         ts.unregisterMBean();
437         rootStatsHolder.removeChild(name);
438     }
439     
440     public void registerJVMStats(JVMStats js, MonitoringLevelListener listener)
441     throws MonitoringRegistrationException {
442         if (js == null)
443             throw new IllegalArgumentException JavaDoc("JVM - null stats provided");
444         final StatsHolder vmNode = rootStatsHolder.getChild(MonitoredObjectType.JVM.getTypeName());
445         assert (vmNode != null) : "MRH:registerJVMStats - Initialization failed";
446         vmNode.setStats(js);
447         vmNode.setStatsClass(javax.management.j2ee.statistics.JVMStats JavaDoc.class);
448         vmNode.registerMBean();
449     }
450     
451     public void unregisterJVMStats() throws MonitoringRegistrationException {
452         final String JavaDoc name = MonitoredObjectType.JVM.getTypeName();
453         final StatsHolder js = rootStatsHolder.getChild(name);
454         assert (js != null) : "Serious JVM is null";
455         js.unregisterMBean();
456         rootStatsHolder.removeChild(name);
457     }
458     
459     public void registerHttpListenerStats(HTTPListenerStats hs, String JavaDoc ls,
460     String JavaDoc vs, MonitoringLevelListener listener) throws MonitoringRegistrationException {
461         if (hs == null || ls == null || vs == null)
462             throw new IllegalArgumentException JavaDoc("MRH:registerHttpListenerStats - Null argunments");
463         StatsHolder added = getRootVs(vs);
464         added = added.addChild(ls, MonitoredObjectType.HTTP_LISTENER);
465         assert (added != null) : "MRH: Listener is null - " + ls;
466         added.setObjectName(MonitoringObjectNames.getHttpListenerObjectName(vs, ls));
467         added.setDottedName(DottedNameFactory.getHttpListenerDottedName(ls, vs));
468         added.setStats(hs);
469         added.setStatsClass(com.sun.enterprise.admin.monitor.stats.HTTPListenerStats.class);
470         if (shouldRegisterMBean(MonitoredObjectType.HTTP_LISTENER))
471             added.registerMBean();
472     }
473
474     public void unregisterHttpListenerStats(String JavaDoc name, String JavaDoc vs)
475     throws MonitoringRegistrationException {
476         if (name == null || vs == null)
477             throw new IllegalArgumentException JavaDoc("Null args");
478         final StatsHolder vsNode = getRootVs(vs);
479         final StatsHolder ls = vsNode.getChild(name);
480         assert (ls != null) : "Unexpected this http listener should be non null : vs = " + vs + " ls = " + name;
481         ls.unregisterMBean();
482         vsNode.removeChild(name);
483     }
484     
485     public void registerServletStats(
486             com.sun.enterprise.admin.monitor.stats.ServletStats ss,
487             String JavaDoc app,
488             String JavaDoc module,
489             String JavaDoc ctxRoot,
490             String JavaDoc vs,
491             String JavaDoc servlet,
492         MonitoringLevelListener listener)
493                 throws MonitoringRegistrationException {
494
495         if ( ss == null || module == null || ctxRoot == null
496                     || vs == null || servlet == null) {
497         throw new IllegalArgumentException JavaDoc("Null arguments");
498         }
499
500         final StatsHolder sRootNode = getServletRootNode(app, module, ctxRoot, vs);
501         final StatsHolder sNode = sRootNode.addChild(servlet, MonitoredObjectType.SERVLET);
502         assert (sNode != null) : "Added Servlet Node is not null";
503         sNode.setStats(ss);
504         sNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.ServletStats.class);
505         sNode.setObjectName(MonitoringObjectNames.getServletObjectName(app, ctxRoot, vs, servlet));
506         sNode.setDottedName(DottedNameFactory.getServletDottedName(app, module, vs, servlet));
507
508         if (shouldRegisterMBean(MonitoredObjectType.SERVLET)) {
509             sNode.registerMBean();
510         }
511     }
512
513     public void unregisterServletStats(String JavaDoc app,
514                                        String JavaDoc module,
515                                        String JavaDoc ctxRoot,
516                                        String JavaDoc vs,
517                                        String JavaDoc servlet)
518         throws MonitoringRegistrationException {
519
520         final StatsHolder sRootNode = getServletRootNode(app, module, ctxRoot, vs);
521         final StatsHolder tmp = sRootNode.getChild(servlet);
522         assert (tmp != null) : "Registration of this servlet was not called before: " + servlet;
523         tmp.unregisterMBean();
524         sRootNode.removeChild(servlet);
525     }
526
527     /*
528      * Registers the given WebModule stats.
529      *
530      * @param stats The web module statistics related to the web module
531      * deployment on the given virtual server
532      * @param appName The app to which the web module belongs
533      * @param webModuleName The web module name
534      * @param ctxRoot The context root at which the web module has been
535      * deployed
536      * @param vs The id of the virtual server on which the web module has been
537      * deployed
538      * @param listener Monitoring listener
539      */

540     public void registerWebModuleStats(
541                 com.sun.enterprise.admin.monitor.stats.WebModuleStats stats,
542                 String JavaDoc appName,
543                 String JavaDoc webModuleName,
544                 String JavaDoc ctxRoot,
545                 String JavaDoc vs,
546                 MonitoringLevelListener listener)
547             throws MonitoringRegistrationException {
548
549         if (stats == null || webModuleName == null
550                 || ctxRoot == null || vs == null) {
551             throw new IllegalArgumentException JavaDoc("Null arguments");
552         }
553
554         StatsHolder sNode = getServletRootNode(appName, webModuleName,
555                                                ctxRoot, vs);
556         sNode.setStats(stats);
557         Class JavaDoc beanMethods =
558                 com.sun.enterprise.admin.monitor.stats.WebModuleStats.class;
559         Class JavaDoc[] interfaces = stats.getClass().getInterfaces();
560         for (int i=0; interfaces != null && i<interfaces.length; i++) {
561             if (beanMethods.isAssignableFrom(interfaces[i])) {
562                 // Register under more specialized (e.g., EE) interface
563
beanMethods = interfaces[i];
564                 break;
565             }
566         }
567         sNode.setStatsClass(beanMethods);
568
569         if (shouldRegisterMBean(MonitoredObjectType.WEBMODULE)) {
570             sNode.registerMBean();
571         }
572     }
573
574     /*
575      * Unregisters the WebModuleStats associated with the web module whose name
576      * is given by <code>webModuleName</code> and that is part of the
577      * application named <code>appName</code> and is deployed on the virtual
578      * server <code>vs</code>.
579      *
580      * @param appName The app to which the web module belongs
581      * @param webModuleName The web module name
582      * @param ctxRoot The context root at which the web module has been
583      * deployed
584      * @param vs The id of the virtual server on which the web module has been
585      * deployed
586      */

587     public void unregisterWebModuleStats(String JavaDoc appName,
588                                          String JavaDoc webModuleName,
589                                          String JavaDoc ctxRoot,
590                                          String JavaDoc vs)
591         throws MonitoringRegistrationException {
592
593         final StatsHolder sNode = getServletRootNode(appName, webModuleName,
594                                                      ctxRoot, vs);
595         sNode.unregisterMBean();
596         final StatsHolder parent = (null == appName
597                                     ? rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName())
598                                     : rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName()).getChild(appName));
599         if (null != parent){
600             final StatsHolder webModule = parent.getChild(webModuleName);
601             if (null != webModule){
602                 webModule.unregisterMBean();
603                 parent.removeChild(webModuleName);
604             }
605         }
606     }
607
608                 
609             
610
611     /**
612      * Gets the WebModuleStats associated with the web module whose name
613      * is given by <code>webModuleName</code> and that is part of the
614      * application named <code>appName</code> and is deployed on the virtual
615      * server <code>vs</code>.
616      *
617      * @param appName Name of the J2EE Application to which
618      * the web module belongs, or null if the web module is stand-alone
619      * @param webModuleName The name of the web module from which to retrieve
620      * the stats
621      * @param ctxRoot The context root at which the web module has been
622      * deployed
623      * @param vs The id of the virtual-server on which the web module has
624      * been deployed
625      *
626      * @return The desired WebModuleStats, or null
627      */

628     public WebModuleStats getWebModuleStats(String JavaDoc appName,
629                                             String JavaDoc webModuleName,
630                                             String JavaDoc ctxRoot,
631                                             String JavaDoc vs) {
632         WebModuleStats stats = null;
633
634         StatsHolder sNode = getServletRootNode(appName, webModuleName,
635                                                ctxRoot, vs);
636         if (sNode != null) {
637             stats = (WebModuleStats) sNode.getStats();
638         }
639
640         return stats;
641         
642     }
643
644     /*
645      * Returns the node in the monitoring tree that represents the virtual
646      * server (with the given id) to which the web module with the given name
647      * has been deployed.
648      *
649      * The returned node represents the parent node to which the web module's
650      * servlet nodes will be attached (as children).
651      *
652      * @param app The app to which the web module belongs
653      * @param module The web module name
654      * @param ctxRoot The context root at which the web module has been
655      * deployed
656      * @param vs The id of the virtual server on which the web module has been
657      * deployed
658      *
659      * @return The node in the monitoring tree that represents the virtual
660      * server to which the web module has been deployed
661      */

662     private StatsHolder getServletRootNode(
663             String JavaDoc app, String JavaDoc module, String JavaDoc ctxRoot, String JavaDoc vs) {
664
665         StatsHolder tmp = rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName()); //applications
666
if (app != null) {
667             tmp = tmp.addChild(app, MonitoredObjectType.APPLICATION);
668             tmp.setObjectName(MonitoringObjectNames.getApplicationObjectName(app));
669             tmp.setDottedName(DottedNameFactory.getAppDottedName(app));
670             tmp.registerMBean();
671             tmp = tmp.addChild(module, MonitoredObjectType.WEBMODULE);
672             tmp.setDottedName(DottedNameFactory.getAppModuleDottedName(app,module));
673             logger.finest("Added - MRH:getWebRootNode for ejb-jar module in j2ee-app: " + app + ":" + module);
674     } else {
675             tmp = tmp.addChild(module, MonitoredObjectType.STANDALONE_WEBMODULE);
676             tmp.setDottedName(DottedNameFactory.getStandAloneWebModuleDottedName(module));
677             logger.finest("Added MRH:getWebRootNode for standalone web module: " + module);
678     }
679         tmp.setObjectName(MonitoringObjectNames.getWebModuleObjectName(app, ctxRoot, vs));
680         tmp.registerMBean();
681         logger.finest("MRH:getWebRootNode: name = " + tmp.getName());
682         tmp = tmp.addChild(vs, MonitoredObjectType.VIRTUAL_SERVER);
683         tmp.setObjectName(MonitoringObjectNames.getVirtualServerObjectName(app, ctxRoot, vs));
684         tmp.setDottedName(DottedNameFactory.getWebAppsVirtualServerDottedName(app, module, vs));
685         return ( tmp );
686     }
687
688     private StatsHolder getEjbRootNode(String JavaDoc app, String JavaDoc module) {
689         StatsHolder tmp = rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName()); //applications
690
if (app != null) {
691             tmp = tmp.addChild(app, MonitoredObjectType.APPLICATION);
692             tmp.setObjectName(MonitoringObjectNames.getApplicationObjectName(app));
693             tmp.setDottedName(DottedNameFactory.getAppDottedName(app));
694             tmp.registerMBean();
695             tmp = tmp.addChild(module, MonitoredObjectType.EJBMODULE);
696             tmp.setDottedName(DottedNameFactory.getAppModuleDottedName(app, module));
697             logger.finest("Added - MRH:getEjbRootNode for ejb-jar module in j2ee-app: " + app + ":" + module);
698         }
699         else {
700             tmp = tmp.addChild(module, MonitoredObjectType.STANDALONE_EJBMODULE);
701             tmp.setDottedName(DottedNameFactory.getStandAloneEJBModuleDottedName(module));
702             logger.finest("Added MRH:getEjbRootNode for standalone ejb-jar module: " + module);
703         }
704         tmp.setObjectName(MonitoringObjectNames.getEjbModuleObjectName(app, module));
705         tmp.registerMBean();
706         logger.finest("MRH:getEjbRootNode: name = " + tmp.getName());
707         return ( tmp );
708     }
709
710     private StatsHolder getWebServiceEndpointForWeb(String JavaDoc app,
711             String JavaDoc module, String JavaDoc ctxRoot, String JavaDoc vs, String JavaDoc endpoint) {
712         final StatsHolder sRoot = getServletRootNode(app, module, ctxRoot, vs);
713         assert (sRoot != null) : "MRH:getWebService, unexpectedly sRoot is null: "
714             + app + ":" + module;
715         final StatsHolder wsNode = sRoot.addChild(endpoint,
716             MonitoredObjectType.WEBSERVICE_ENDPOINT); // type not final yet
717
assert (wsNode != null) : "Web Service node should not be null: " +
718             endpoint;
719         return ( wsNode );
720     }
721
722     private StatsHolder getWebServiceEndpointForEjb(String JavaDoc app, String JavaDoc module,
723     String JavaDoc endpoint) {
724         final StatsHolder ejbRoot = getEjbRootNode(app, module);
725         assert (ejbRoot != null) : "MRH:getEjb, unexpectedly ejbRoot is null: "
726             + app + ":" + module;
727         final StatsHolder wsNode = ejbRoot.addChild(endpoint,
728             MonitoredObjectType.WEBSERVICE_ENDPOINT); // type not final yet
729
assert (wsNode != null) : "Web Service node should not be null: " +
730             endpoint;
731         return ( wsNode );
732     }
733
734     private StatsHolder getEjb(String JavaDoc app, String JavaDoc module, String JavaDoc ejb) {
735         final StatsHolder ejbRoot = getEjbRootNode(app, module);
736         assert (ejbRoot != null) : "MRH:getEjb, unexpectedly ejbRoot is null: " + app + ":" + module;
737         final StatsHolder ejbNode = ejbRoot.addChild(ejb, MonitoredObjectType.EJB); // type not final yet
738
assert (ejbNode != null) : "Ejb node should not be null: " + ejb;
739         return ( ejbNode );
740     }
741     
742     private StatsHolder getEjbMethods(String JavaDoc app, String JavaDoc module, String JavaDoc ejb) {
743         final StatsHolder ejbNode = getEjb(app, module, ejb);
744         assert (ejbNode != null) : "MRH:getEjbMethods, unexpectedly ejb node is null: " + app + ":" + module + ":" + ejb;
745         final String JavaDoc methods = MonitoredObjectType.BEAN_METHODS.getTypeName();
746         final StatsHolder added = ejbNode.addChild(methods, MonitoredObjectType.BEAN_METHODS);
747         added.setObjectName(MonitoringObjectNames.getEjbMethodsObjectName(app, module, ejb));
748         added.setDottedName(DottedNameFactory.getEJBMethodsDottedName(app, module, ejb));
749         added.registerMBean();
750         return ( added );
751     }
752
753     private StatsHolder getRootVs(String JavaDoc vs) {
754         final StatsHolder https = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
755         assert (https != null) : "MRH:registerHttpListener HTTP Service is not initialized - Serious";
756         https.setDottedName(DottedNameFactory.getHttpServiceDottedName());
757         StatsHolder added = https.addChild(vs, MonitoredObjectType.VIRTUAL_SERVER);
758         assert (added != null) : "MRH: VS is null: " + vs;
759         added.setObjectName(MonitoringObjectNames.getVirtualServerObjectName(vs));
760         added.setDottedName(DottedNameFactory.getHttpSvcVirtualServerDottedName(vs));
761         added.registerMBean();
762         return ( added );
763     }
764     
765     /* START
766      * Here are some tree-walking methods to walk the StatsHolder tree. I am
767      * unfortunately using them somewhere else also, because it is better that the code
768      * is at one place. Also, these methods are NOT in the interface MonitoringRegistry
769      * and hence calling classes have to cast the class.
770      */

771     
772     public Collection getThreadPoolNodes() {
773         final StatsHolder tps = rootStatsHolder.getChild(MonitoredObjectType.THREAD_POOLS.getTypeName());
774         return ( tps.getAllChildren() );
775     }
776     public Collection getOrbNodes() {
777         //currently ALL connection managers are returned.
778
StatsHolder tmp = rootStatsHolder.getChild(MonitoredObjectType.ORB.getTypeName());
779         tmp = tmp.getChild(MonitoredObjectType.CONNECTION_MANAGERS.getTypeName()); //connection-managers
780
return ( tmp.getAllChildren() );
781     }
782
783     public Collection getHttpServiceNodes() {
784         //currently ALL http listeners are returned
785
final ArrayList all = new ArrayList();
786         final Collection vss = getVsNodes();
787         // Need to add the child nodes first, before adding the
788
// grandchildren
789
all.addAll(vss);
790         // also need to add the http-service node itself.
791
// all.add(rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()));
792

793         final Iterator it = vss.iterator();
794         while (it.hasNext()) {
795             final StatsHolder vs = (StatsHolder) it.next();
796             all.addAll(vs.getAllChildren());
797         }
798         return ( all );
799     }
800     private Collection getVsNodes() {
801         final StatsHolder https = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
802         return ( https.getAllChildren() );
803     }
804     
805     public Collection getTransactionServiceNodes() {
806         //singleton transaction-service node is returned
807
final ArrayList all = new ArrayList();
808         all.add(rootStatsHolder.getChild(MonitoredObjectType.TRANSACTION_SERVICE.getTypeName()));
809         return ( all );
810     }
811     
812     public Collection getConnectionPoolNodes() {
813         final StatsHolder res = rootStatsHolder.getChild(MonitoredObjectType.RESOURCES.getTypeName());
814         return ( res.getAllChildren() );
815     }
816         
817     
818     public Collection getWebContainerNodes() {
819         //All servlet nodes are returned
820
final ArrayList all = new ArrayList();
821         
822         final StatsHolder appsNode = rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName());
823         final Collection apps = appsNode.getAllChildren();
824         final Iterator it = apps.iterator();
825         while (it.hasNext()) {
826             final StatsHolder appOrStandaloneModule = (StatsHolder) it.next();
827             if (appOrStandaloneModule.getType() == MonitoredObjectType.APPLICATION) {
828                 final Collection modulesInApp = appOrStandaloneModule.getAllChildren();
829                 final Iterator ii = modulesInApp.iterator();
830                 while (ii.hasNext()) {
831                     final StatsHolder embedded = (StatsHolder) ii.next();
832                     if (embedded.getType() == MonitoredObjectType.WEBMODULE) {
833                         all.addAll(getWebModuleNodes(embedded));
834                     }
835                 }
836             }
837             else if (appOrStandaloneModule.getType() == MonitoredObjectType.STANDALONE_WEBMODULE) {
838                 final StatsHolder standaloneWebModule = appOrStandaloneModule;
839                 all.addAll(getWebModuleNodes(standaloneWebModule));
840             }
841         }
842         return ( all );
843     }
844     
845     private Collection getWebModuleNodes(StatsHolder node) {
846         final ArrayList nodes = new ArrayList();
847         assert (node.getType() == MonitoredObjectType.WEBMODULE ||
848                 node.getType() == MonitoredObjectType.STANDALONE_WEBMODULE);
849         final Collection vss = node.getAllChildren();
850         final Iterator it = vss.iterator();
851         while (it.hasNext()) {
852             final StatsHolder vs = (StatsHolder) it.next();
853                         // Add node corresponding to virtual server on which
854
// web module has been deployed
855
nodes.add(vs);
856                         // Add servlet nodes
857
nodes.addAll(vs.getAllChildren());
858         }
859         return ( nodes );
860     }
861     
862     public Collection getEjbContainerNodes(boolean includeMethods) {
863         //all Ejbs, cache, pool and method nodes are returned
864
final Collection all = new ArrayList();
865         final StatsHolder appsNode = rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName());
866         final Collection apps = appsNode.getAllChildren();
867         final Iterator it = apps.iterator();
868         while (it.hasNext()) {
869             final StatsHolder appOrStandaloneModule = (StatsHolder) it.next();
870             if (appOrStandaloneModule.getType() == MonitoredObjectType.APPLICATION) {
871                 final Collection modulesInApp = appOrStandaloneModule.getAllChildren();
872                 final Iterator ii = modulesInApp.iterator();
873                 while (ii.hasNext()) {
874                     final StatsHolder embedded = (StatsHolder) ii.next();
875                     if (embedded.getType() == MonitoredObjectType.EJBMODULE) {
876                         all.addAll(getEjbNodesInEjbModule(embedded, includeMethods));
877                     }
878                 }
879             }
880             else if (appOrStandaloneModule.getType() == MonitoredObjectType.STANDALONE_EJBMODULE) {
881                 final StatsHolder standaloneEjbModule = appOrStandaloneModule;
882                 all.addAll(getEjbNodesInEjbModule(standaloneEjbModule, includeMethods));
883             }
884         }
885         return ( all );
886     }
887     
888     private Collection getEjbNodesInEjbModule(StatsHolder node, boolean includeMethods) {
889         final ArrayList ejbNodes = new ArrayList();
890         assert (node.getType() == MonitoredObjectType.EJBMODULE ||
891                 node.getType() == MonitoredObjectType.STANDALONE_EJBMODULE);
892         final Collection ejbs = node.getAllChildren();
893         ejbNodes.addAll(ejbs); // added all the ejbs in all the web modules
894
// now for each ejb node
895
final Iterator it = ejbs.iterator();
896         while (it.hasNext()) {
897             final StatsHolder ejb = (StatsHolder) it.next();
898             ejbNodes.addAll(ejb.getAllChildren()); //EJB_METHODS node will also be added here.
899
final StatsHolder methodsNode = ejb.getChild(MonitoredObjectType.BEAN_METHODS.getTypeName());
900             if(includeMethods) {
901             if (methodsNode != null) // required because this may be null, when there are no ejbs registered to begin with
902
ejbNodes.addAll(getEjbMethodNodes(methodsNode));
903         }
904             else {
905                 ejbNodes.remove(methodsNode);
906             }
907         }
908         return ( ejbNodes );
909     }
910     
911     private Collection getEjbMethodNodes(StatsHolder methodsNode) {
912         assert (methodsNode.getType() == MonitoredObjectType.BEAN_METHODS);
913         return ( methodsNode.getAllChildren() );
914     }
915     
916     public Collection getEjbMethodNodes() {
917         // get all the subtype nodes for the ejb container
918
final ArrayList ejbNodes = new ArrayList();
919         final ArrayList ejbMethodNodes = new ArrayList();
920         ejbNodes.addAll(getEjbContainerNodes(true));
921         final Iterator it = ejbNodes.iterator();
922         while (it.hasNext()) {
923             StatsHolder ejbNode = (StatsHolder) it.next();
924             if((ejbNode.getType() == MonitoredObjectType.BEAN_METHODS) ||
925                (ejbNode.getType() == MonitoredObjectType.BEAN_METHOD))
926                 ejbMethodNodes.add(ejbNode);
927         }
928         return ejbMethodNodes;
929     }
930     
931     /* END
932      * Here are some tree-walking methods to walk the StatsHolder tree. I am
933      * unfortunately using them somewhere else also, because it is better that the code
934      * is at one place. Also, these methods are NOT in the interface MonitoringRegistry
935      * and hence calling classes have to to ClassCast.
936      */

937     private void addMonitoringLevelListener(MonitoringLevelListener listener){
938         if(listener != null)
939             listeners.add(listener);
940     }
941
942     /**
943      * this method is intended to be called by the different subsystems to register
944      * their MonitoringLevelListener
945      */

946     public void registerMonitoringLevelListener(MonitoringLevelListener listener,
947     MonitoredObjectType objType) {
948         if (listener != null && objType != null) {
949             //retain the listener reference for dynamic reconfiguration
950
objTypeListeners.put(objType, listener);
951             // now give the immediate callback with the "current" monitoring level for this type.
952
final MonitoringLevel level = MonitoringConfigurationHandler.getLevel(objType);
953             //listener.changeLevel(level, level, objType);
954
}
955     }
956     
957     public void unregisterMonitoringLevelListener(MonitoringLevelListener listener) {
958         if (listener != null) {
959             objTypeListeners.remove(listener);
960         }
961     }
962     
963     /** Method to initialize the root hierarchy */
964     private void initialize() {
965         initializeRoot();
966         initializeJvm();
967         initializeApplications();
968         initializeThreadPools();
969         initializeOrb();
970         initializeTransactionService();
971         initializeHttpService();
972         initializeResources();
973         initializeConnectorService();
974         initializeJmsService();
975                 initializeJndi();
976         //((StatsHolderImpl)rootStatsHolder).write();
977
}
978     
979     private void initializeRoot() {
980         rootStatsHolder.setObjectName(MonitoringObjectNames.getRootObjectName());
981         rootStatsHolder.setDottedName(DottedNameFactory.getRootDottedName());
982         rootStatsHolder.registerMBean();
983     }
984     private void initializeJvm() {
985         final StatsHolder jvmNode = rootStatsHolder.addChild(MonitoredObjectType.JVM.getTypeName(), MonitoredObjectType.JVM);
986         assert (jvmNode != null) : "Initialization Error in jvmNodeCreation";
987         jvmNode.setObjectName(MonitoringObjectNames.getJvmObjectName());
988         jvmNode.setDottedName(DottedNameFactory.getJVMDottedName());
989         try {
990             this.registerJVMStats(new JVMStatsImpl(), null);
991             logger.finest("Registering the JVM stats in RegistryHelper only");
992         }
993         catch (Exception JavaDoc cause) {
994             throw new RuntimeException JavaDoc(cause);
995         }
996         
997            initializeJvmMonitoring(rootStatsHolder);
998     }
999     private void initializeApplications() {
1000        final StatsHolder appsNode = rootStatsHolder.addChild(MonitoredObjectType.APPLICATIONS.getTypeName(), MonitoredObjectType.APPLICATIONS);
1001        assert (appsNode != null) : "Initialization Error in appsNodeCreation";
1002        appsNode.setObjectName(MonitoringObjectNames.getApplicationsObjectName());
1003        appsNode.setDottedName(DottedNameFactory.getApplicationsDottedName());
1004        appsNode.registerMBean();
1005    }
1006    private void initializeThreadPools() {
1007        final StatsHolder tpsNode = rootStatsHolder.addChild(MonitoredObjectType.THREAD_POOLS.getTypeName(), MonitoredObjectType.THREAD_POOLS);
1008        assert (tpsNode != null) : "Initialization Error in tpsNodeCreation";
1009        tpsNode.setObjectName(MonitoringObjectNames.getThreadPoolsObjectName());
1010        tpsNode.setDottedName(DottedNameFactory.getThreadPoolsDottedName());
1011        tpsNode.registerMBean();
1012    }
1013    private void initializeOrb() {
1014        final StatsHolder orbNode = rootStatsHolder.addChild(MonitoredObjectType.ORB.getTypeName(), MonitoredObjectType.ORB);
1015        assert (orbNode != null) : "Initialization Error in orbNodeCreation";
1016        orbNode.setObjectName(MonitoringObjectNames.getOrbObjectName());
1017        orbNode.setDottedName(DottedNameFactory.getOrbDottedName());
1018        orbNode.registerMBean();
1019        final StatsHolder cmsNode = orbNode.addChild(MonitoredObjectType.CONNECTION_MANAGERS.getTypeName(), MonitoredObjectType.CONNECTION_MANAGERS);
1020        assert (cmsNode != null) : "Initialization Error in Connection Managers Creation";
1021        cmsNode.setObjectName(MonitoringObjectNames.getConnectionManagersObjectName());
1022        cmsNode.setDottedName(DottedNameFactory.getConnectionManagersDottedName());
1023        cmsNode.registerMBean();
1024    }
1025    private void initializeTransactionService() {
1026        final StatsHolder tsNode = rootStatsHolder.addChild(MonitoredObjectType.TRANSACTION_SERVICE.getTypeName(), MonitoredObjectType.TRANSACTION_SERVICE);
1027        assert (tsNode != null) : "Initialization Error in Transaction Service";
1028        tsNode.setObjectName(MonitoringObjectNames.getTransactionServiceObjectName());
1029        tsNode.setDottedName(DottedNameFactory.getTransactionServiceDottedName());
1030    }
1031    private void initializeHttpService() {
1032        final StatsHolder hsNode = rootStatsHolder.addChild(MonitoredObjectType.HTTP_SERVICE.getTypeName(), MonitoredObjectType.HTTP_SERVICE);
1033        assert (hsNode != null) : "Initialization Error in HttpServiceCreation";
1034        hsNode.setObjectName(MonitoringObjectNames.getHttpServiceObjectName());
1035        hsNode.setDottedName(DottedNameFactory.getHttpServiceDottedName());
1036        hsNode.registerMBean();
1037    }
1038    private void initializeResources() {
1039        final StatsHolder resNode = rootStatsHolder.addChild(MonitoredObjectType.RESOURCES.getTypeName(), MonitoredObjectType.RESOURCES);
1040        assert (resNode != null) : "Initialization Error in Resources";
1041        resNode.setObjectName(MonitoringObjectNames.getResourcesObjectName());
1042        resNode.setDottedName(DottedNameFactory.getResourcesDottedName());
1043        resNode.registerMBean();
1044    }
1045
1046        private void initializeJndi() {
1047                //if (shouldRegisterMBean(MonitoredObjectType.JNDI)) {
1048
JndiMBeanManager mgr = new JndiMBeanManager();
1049                    mgr.registerMBean(MonitoringObjectNames.getJndiObjectName());
1050                //}
1051
}
1052
1053    private void initializeJvmMonitoring(StatsHolder rootNode) {
1054        
1055        final String JavaDoc JMM_CLASS =
1056        "com.sun.enterprise.admin.monitor.registry.spi.JVMMonitoringManager";
1057        final String JavaDoc METHOD = "getInstance";
1058        final String JavaDoc REG_METHOD = "registerStats";
1059        try {
1060            final Class JavaDoc c = Class.forName(JMM_CLASS);
1061            final java.lang.reflect.Method JavaDoc m = c.getMethod(METHOD);
1062            final Object JavaDoc jmm = m.invoke(c);
1063            registerMonitoringLevelListener((MonitoringLevelListener)jmm, MonitoredObjectType.JVM);
1064            final java.lang.reflect.Method JavaDoc m1 =
1065                          c.getMethod(REG_METHOD, new Class JavaDoc[]{com.sun.enterprise.admin.monitor.registry.StatsHolder.class});
1066            m1.invoke(jmm, new Object JavaDoc[]{rootStatsHolder});
1067            //jmm.registerStats(rootStatsHolder);
1068
}
1069        catch(Throwable JavaDoc t) {
1070            logger.finest("Exception in the initialization of JVM 1.5 Monitoring");
1071            throw new RuntimeException JavaDoc(t);
1072        }
1073    }
1074    
1075    private boolean shouldRegisterMBean(MonitoredObjectType type) {
1076        return ( MonitoringConfigurationHandler.shouldRegisterMBean(type) );
1077        }
1078
1079    // connector & jms service related changes BEGIN
1080
/**
1081     * This creates a connector-service node in the hierarchy, which contains
1082     * all the connector modules.
1083     */

1084    private void initializeConnectorService() {
1085        final StatsHolder adaptorsNode = rootStatsHolder.addChild(
1086                                        MonitoredObjectType.CONNECTOR_SERVICE.getTypeName(),
1087                                        MonitoredObjectType.CONNECTOR_SERVICE);
1088        assert (adaptorsNode != null) : "connector-service node not created";
1089        adaptorsNode.setObjectName(MonitoringObjectNames.getConnectorServiceObjectName());
1090        adaptorsNode.setDottedName(DottedNameFactory.getConnectorServiceDottedName());
1091        adaptorsNode.registerMBean();
1092    }
1093    
1094    /**
1095     * This creates a jms-service node in the hierarchy, which contains
1096     * all the connector modules.
1097     */

1098
1099    private void initializeJmsService() {
1100        final StatsHolder adaptorsNode = rootStatsHolder.addChild(
1101                                        MonitoredObjectType.JMS_SERVICE.getTypeName(),
1102                                        MonitoredObjectType.JMS_SERVICE);
1103        assert (adaptorsNode != null) : "jms-service node not created";
1104        adaptorsNode.setObjectName(MonitoringObjectNames.getJmsServiceObjectName());
1105        adaptorsNode.setDottedName(DottedNameFactory.getJmsServiceDottedName());
1106        adaptorsNode.registerMBean();
1107    }
1108
1109    /**
1110     * returns the resource adapter root node, whether it is part of the application
1111     * or standalone.
1112     */

1113    private StatsHolder getConnectorRootNode(String JavaDoc j2eeAppName, String JavaDoc moduleName) {
1114        
1115        // if the connector-module is embedded in a j2eeApp, then the node for the
1116
// connector-module should be called j2eeAppName#moduleName
1117
StatsHolder tmp = rootStatsHolder.getChild(MonitoredObjectType.CONNECTOR_SERVICE.getTypeName());
1118        assert (tmp != null) : "connector-service node not created";
1119        if (j2eeAppName != null)
1120            tmp = tmp.addChild(j2eeAppName +"#" + moduleName, MonitoredObjectType.CONNECTOR_MODULE);
1121        else
1122            tmp = tmp.addChild(moduleName, MonitoredObjectType.STANDALONE_CONNECTOR_MODULE);
1123        
1124        logger.finest("Added - MRH:getConnectorRootNode for connector-module in j2ee-app: " + j2eeAppName + ":" + moduleName);
1125        tmp.setDottedName(DottedNameFactory.getConnectorModuleDottedName(j2eeAppName, moduleName));
1126        tmp.setObjectName(MonitoringObjectNames.getConnectorModuleObjectName(j2eeAppName, moduleName));
1127        tmp.registerMBean();
1128        logger.finest("MRH:getConnectorRootNode: name = " + tmp.getName());
1129        return ( tmp );
1130    }
1131    
1132   // this signature is being preserved for backward compatibility
1133
public void registerConnectorWorkMgmtStats(
1134           com.sun.enterprise.admin.monitor.stats.ConnectorWorkMgmtStats stats,
1135           String JavaDoc j2eeAppName,
1136           String JavaDoc moduleName,
1137           MonitoringLevelListener listener)
1138           throws MonitoringRegistrationException {
1139        
1140        registerConnectorWorkMgmtStats(stats, j2eeAppName, moduleName, false, listener);
1141               
1142    }
1143   
1144 
1145    public void registerConnectorWorkMgmtStats(
1146           com.sun.enterprise.admin.monitor.stats.ConnectorWorkMgmtStats stats,
1147           String JavaDoc j2eeAppName,
1148           String JavaDoc moduleName,
1149           boolean isJms,
1150           MonitoringLevelListener listener) throws MonitoringRegistrationException {
1151      
1152        StatsHolder adapterNode = null;
1153        // for registering the work management stats for jms-service, the j2eeAppName and
1154
// moduleName are not needed
1155
if(isJms) {
1156            if(stats == null)
1157                throw new IllegalArgumentException JavaDoc("Invalid Arguments for ConnectorWorkManagementStats registration");
1158            adapterNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName());
1159        }
1160        else {
1161            if((stats == null)||(moduleName == null)||(moduleName.equals("")))
1162                throw new IllegalArgumentException JavaDoc("Invalid Arguments for ConnectorWorkManagementStats registration");
1163            adapterNode = getConnectorRootNode(j2eeAppName, moduleName);
1164        }
1165                    
1166        assert(adapterNode != null):"connector node is null";
1167        adapterNode = adapterNode.addChild(MonitoredObjectType.CONNECTOR_WORKMGMT.getTypeName(),
1168                                           MonitoredObjectType.CONNECTOR_WORKMGMT);
1169        adapterNode.setStats(stats);
1170        adapterNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.ConnectorWorkMgmtStats.class);
1171        adapterNode.setDottedName(DottedNameFactory.getConnectorWorkMgmtDottedName(j2eeAppName, moduleName, isJms));
1172        adapterNode.setObjectName(MonitoringObjectNames.getConnectorWorkMgmtObjectName(j2eeAppName, moduleName, isJms));
1173        adapterNode.registerMBean();
1174        if (shouldRegisterMBean(MonitoredObjectType.CONNECTOR_WORKMGMT))
1175            adapterNode.registerMBean();
1176    }
1177    
1178    // Connector WorkMgmt Unregistration
1179

1180    // this signature is being preserved for backward compatibility
1181
public void unregisterConnectorWorkMgmtStats(String JavaDoc j2eeAppName, String JavaDoc moduleName)
1182           throws MonitoringRegistrationException {
1183        unregisterConnectorWorkMgmtStats(j2eeAppName, moduleName, false);
1184    }
1185    
1186    public void unregisterConnectorWorkMgmtStats(String JavaDoc j2eeAppName, String JavaDoc moduleName, boolean isJms)
1187           throws MonitoringRegistrationException {
1188        
1189        StatsHolder connectorNode = null;
1190        if(isJms) {
1191            connectorNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName());
1192        }
1193        else {
1194            if((j2eeAppName == null) || (moduleName == null)||(j2eeAppName.equals(""))||(moduleName.equals("")))
1195                throw new IllegalArgumentException JavaDoc("Invalid Arguments for ConnectorWorkManagementStats unregistration");
1196            connectorNode = getConnectorRootNode(j2eeAppName, moduleName);
1197        }
1198        assert(connectorNode != null): "connector node not initialized";
1199        StatsHolder workmgmtNode = connectorNode.getChild(MonitoredObjectType.CONNECTOR_WORKMGMT.getTypeName());
1200        assert(workmgmtNode != null): "Connector Work Management node not initialized";
1201        workmgmtNode.unregisterMBean();
1202        connectorNode.removeChild(MonitoredObjectType.CONNECTOR_WORKMGMT.getTypeName());
1203    }
1204    
1205    
1206    public void registerConnectionFactoryStats(com.sun.enterprise.admin.monitor.stats.ConnectionFactoryStats stats,
1207                                               String JavaDoc factoryName,
1208                                               MonitoringLevelListener listener)
1209                                               throws MonitoringRegistrationException {
1210
1211        if((stats == null) || (factoryName == null))
1212            throw new IllegalArgumentException JavaDoc("Invalid arguments for registraion of ConnectionFactory Stats");
1213        StatsHolder cfNode = getConnectionFactoriesNode();
1214        assert(cfNode != null): "connection-factories node not initialized correctly";
1215        cfNode = cfNode.addChild(factoryName, MonitoredObjectType.CONNECTION_FACTORY);
1216        cfNode.setStats(stats);
1217        cfNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.ConnectionFactoryStats.class);
1218        cfNode.setDottedName(DottedNameFactory.getConnectionFactoryDottedName(factoryName));
1219        cfNode.setObjectName(MonitoringObjectNames.getConnectionFactoryObjectName(factoryName));
1220        if(shouldRegisterMBean(MonitoredObjectType.CONNECTION_FACTORY))
1221            cfNode.registerMBean();
1222    }
1223    
1224    private StatsHolder getConnectionFactoriesNode() {
1225        
1226        StatsHolder tmpNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName());
1227        assert(tmpNode != null): "jms-service node initialized correctly";
1228        tmpNode = tmpNode.addChild(MonitoredObjectType.CONNECTION_FACTORIES.getTypeName(), MonitoredObjectType.CONNECTION_FACTORIES);
1229        tmpNode.setDottedName(DottedNameFactory.getConnectionFactoriesDottedName());
1230        tmpNode.setObjectName(MonitoringObjectNames.getConnectionFactoriesObjectName());
1231        tmpNode.registerMBean();
1232        return tmpNode;
1233    }
1234   
1235    public void unregisterConnectionFactoryStats(String JavaDoc factoryName) throws MonitoringRegistrationException {
1236        
1237        if(factoryName == null)
1238            throw new IllegalArgumentException JavaDoc("Invalid arguments for the unregistration of ConnectionFactory Stats");
1239        StatsHolder tmpNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName());
1240        assert(tmpNode != null): "jms-service node not initialized correctly";
1241        tmpNode = tmpNode.getChild(MonitoredObjectType.CONNECTION_FACTORIES.getTypeName());
1242        assert(tmpNode != null): "connection-factories node not initialized correctly";
1243        StatsHolder cfNode = tmpNode.getChild(factoryName);
1244        assert(cfNode != null): "connection-factory node not initialized correctly";
1245        cfNode.unregisterMBean();
1246        tmpNode.removeChild(factoryName);
1247    }
1248    
1249    public void registerConnectorConnectionPoolStats(com.sun.enterprise.admin.monitor.stats.ConnectorConnectionPoolStats stats,
1250                                                     String JavaDoc poolName,
1251                                                     String JavaDoc j2eeAppName,
1252                                                     String JavaDoc moduleName,
1253                                                     MonitoringLevelListener listener)
1254                                                     throws MonitoringRegistrationException {
1255        if((stats == null)||(j2eeAppName == null)||(moduleName == null)||(poolName == null))
1256            throw new IllegalArgumentException JavaDoc("Invalid arguments for the registration of connection-pool stats");
1257        
1258        StatsHolder poolsNode = getConnectionPoolsNode(j2eeAppName, moduleName);
1259        assert(poolsNode != null): "connection-pools node not initialized correctly";
1260        StatsHolder poolNode = poolsNode.addChild(poolName, MonitoredObjectType.CONNECTOR_CONN_POOL);
1261        poolNode.setStats(stats);
1262        poolNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.ConnectorConnectionPoolStats.class);
1263        poolNode.setDottedName(DottedNameFactory.getConnectionPoolDottedName(poolName, j2eeAppName, moduleName));
1264        poolNode.setObjectName(MonitoringObjectNames.getConnectionPoolObjectName(poolName, j2eeAppName, moduleName));
1265        if(shouldRegisterMBean(MonitoredObjectType.CONNECTOR_CONN_POOL))
1266            poolNode.registerMBean();
1267    }
1268    
1269    private StatsHolder getConnectionPoolsNode(String JavaDoc j2eeAppName, String JavaDoc moduleName) {
1270        
1271        StatsHolder connNode = getConnectorRootNode(j2eeAppName, moduleName);
1272        assert(connNode != null): "connector node initialized correctly";
1273        connNode = connNode.addChild(MonitoredObjectType.CONNECTION_POOLS.getTypeName(), MonitoredObjectType.CONNECTION_POOLS);
1274        connNode.setDottedName(DottedNameFactory.getConnectionPoolsDottedName(j2eeAppName, moduleName));
1275        connNode.setObjectName(MonitoringObjectNames.getConnectionPoolsObjectName(j2eeAppName, moduleName));
1276        connNode.registerMBean();
1277        return connNode;
1278    }
1279    
1280    public void unregisterConnectorConnectionPoolStats(String JavaDoc poolName,
1281                                                       String JavaDoc j2eeAppName,
1282                                                       String JavaDoc moduleName)
1283                                                       throws MonitoringRegistrationException {
1284     
1285        StatsHolder poolsNode = getConnectionPoolsNode(j2eeAppName, moduleName);
1286        assert(poolsNode != null): "connection-pools node not initialized";
1287        StatsHolder poolNode = poolsNode.getChild(poolName);
1288        assert(poolNode != null): "connection-pool node not initialized";
1289        poolNode.unregisterMBean();
1290        poolsNode.removeChild(poolName);
1291    }
1292    
1293    /**
1294     * This will return all the nodes related to the connector-connection-pool,
1295     * connector-service, jms-service
1296     */

1297    
1298    public Collection getConnectorRelatedNodes() {
1299        Collection c = getConnectionPoolNodes(MonitoredObjectType.CONNECTOR_CONN_POOL);
1300        c.addAll(getConnectorServiceChildren());
1301        c.addAll(getJmsServiceChildren());
1302        return c;
1303    }
1304    
1305    /**
1306     * Return the collection of all the connection-pool nodes and the
1307     * work-management nodes registered under the connector service
1308     */

1309    private Collection getConnectorServiceChildren() {
1310       
1311        StatsHolder connservNode = rootStatsHolder.getChild(MonitoredObjectType.CONNECTOR_SERVICE.getTypeName());
1312        assert(connservNode != null): "connector-service node is null";
1313        // get the children of the connector-service
1314
ArrayList c = new ArrayList();
1315        Collection cNodes = connservNode.getAllChildren();
1316        c.addAll(cNodes);
1317        // now c should contain, all the connector nodes
1318
Iterator iter = cNodes.iterator();
1319        while(iter.hasNext()) {
1320            StatsHolder connectorNode = (StatsHolder) iter.next();
1321            c.addAll(connectorNode.getAllChildren()); // adds the connection-pools & work-mgmt nodes
1322
StatsHolder poolsNode = connectorNode.getChild(MonitoredObjectType.CONNECTION_POOLS.getTypeName());
1323            c.addAll(poolsNode.getAllChildren());
1324        }
1325        return c;
1326    }
1327    
1328    private Collection getJmsServiceChildren() {
1329        
1330        StatsHolder jmsservNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName());
1331        assert(jmsservNode != null): "jms-service node is null";
1332        // get the children of the connector-service
1333
ArrayList c = new ArrayList();
1334        Collection jmsNodes = jmsservNode.getAllChildren();
1335        c.addAll(jmsNodes);
1336        // now c should contain, connection-factories & work-mgmt nodes
1337
Iterator it = jmsNodes.iterator();
1338        while(it.hasNext()) {
1339            StatsHolder childNode = (StatsHolder) it.next();
1340            Collection c1 = childNode.getAllChildren();
1341            if(c1 != null)
1342                c.addAll(c1);
1343        }
1344        return c;
1345    }
1346    
1347    public Collection getConnectionPoolNodes(MonitoredObjectType t) {
1348        
1349        StatsHolder resNode = rootStatsHolder.getChild(MonitoredObjectType.RESOURCES.getTypeName());
1350        Collection c = resNode.getAllChildren();
1351        Iterator iter = c.iterator();
1352        ArrayList poolNodes = new ArrayList();
1353        while(iter.hasNext()) {
1354            StatsHolder tmp = (StatsHolder)iter.next();
1355            if(tmp.getType() == t)
1356                poolNodes.add(tmp);
1357        }
1358        return poolNodes;
1359    }
1360    
1361    // connector & jms service related changes END
1362

1363    
1364    // PWC related changes BEGIN
1365
// Registration of PWCConnectionQueueStats
1366
public void registerPWCConnectionQueueStats(com.sun.enterprise.admin.monitor.stats.PWCConnectionQueueStats stats,
1367                                                MonitoringLevelListener listener) throws MonitoringRegistrationException {
1368        
1369        if(stats == null)
1370            throw new IllegalArgumentException JavaDoc("PWCConnectionQueueStats is null");
1371        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1372        assert(httpsvcNode != null): "HttpService is not initialized correctly";
1373        httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.CONNECTION_QUEUE.getTypeName(), MonitoredObjectType.CONNECTION_QUEUE);
1374        httpsvcNode.setStats(stats);
1375        httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCConnectionQueueStats.class);
1376        httpsvcNode.setDottedName(DottedNameFactory.getConnectionQueueDottedName());
1377        httpsvcNode.setObjectName(MonitoringObjectNames.getConnectionQueueObjectName());
1378        if(shouldRegisterMBean(MonitoredObjectType.CONNECTION_QUEUE))
1379            httpsvcNode.registerMBean();
1380    }
1381    
1382    // Unregistration of PWCConnectionQueueStats
1383
public void unregisterPWCConnectionQueueStats() throws MonitoringRegistrationException {
1384        
1385        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1386        assert(httpsvcNode != null): "http-service node is null";
1387        StatsHolder targetNode = httpsvcNode.getChild(MonitoredObjectType.CONNECTION_QUEUE.getTypeName());
1388        assert(targetNode != null): "connection-queue node is null";
1389        targetNode.unregisterMBean();
1390        //httpsvcNode.removeChild(MonitoredObjectType.CONNECTION_QUEUE.getTypeName());
1391
}
1392
1393    // Registration of PWCDnsStats
1394
public void registerPWCDnsStats(
1395           com.sun.enterprise.admin.monitor.stats.PWCDnsStats stats,
1396           MonitoringLevelListener listener) throws MonitoringRegistrationException {
1397        
1398        if(stats == null)
1399            throw new IllegalArgumentException JavaDoc("PWCDnsStats is null");
1400        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1401        assert(httpsvcNode != null): "HttpService is not initialized correctly";
1402        httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.DNS.getTypeName(), MonitoredObjectType.DNS);
1403        httpsvcNode.setStats(stats);
1404        httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCDnsStats.class);
1405        httpsvcNode.setDottedName(DottedNameFactory.getDnsDottedName());
1406        httpsvcNode.setObjectName(MonitoringObjectNames.getDnsObjectName());
1407        if(shouldRegisterMBean(MonitoredObjectType.DNS))
1408            httpsvcNode.registerMBean();
1409    }
1410    
1411    // Unregistration of PWCDnsStats
1412
public void unregisterPWCDnsStats() throws MonitoringRegistrationException {
1413        
1414        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1415        assert(httpsvcNode != null): "http-service node is null";
1416        StatsHolder dnsNode = httpsvcNode.getChild(MonitoredObjectType.DNS.getTypeName());
1417        assert(dnsNode != null): "dns node is null";
1418        dnsNode.unregisterMBean();
1419        //httpsvcNode.removeChild(MonitoredObjectType.DNS.getTypeName());
1420
}
1421    
1422    // Registration of PWCFileCacheStats
1423
public void registerPWCFileCacheStats(
1424           com.sun.enterprise.admin.monitor.stats.PWCFileCacheStats stats,
1425           MonitoringLevelListener listener) throws MonitoringRegistrationException {
1426        
1427        if(stats == null)
1428            throw new IllegalArgumentException JavaDoc("PWCFileCacheStats is null");
1429        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1430        assert(httpsvcNode != null): "HttpService is not initialized correctly";
1431        httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.FILE_CACHE.getTypeName(), MonitoredObjectType.FILE_CACHE);
1432        httpsvcNode.setStats(stats);
1433        httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCFileCacheStats.class);
1434        httpsvcNode.setDottedName(DottedNameFactory.getFileCacheDottedName());
1435        httpsvcNode.setObjectName(MonitoringObjectNames.getFileCacheObjectName());
1436        if(shouldRegisterMBean(MonitoredObjectType.FILE_CACHE))
1437            httpsvcNode.registerMBean();
1438    }
1439    
1440    // Unregistration of PWCFileCacheStats
1441
public void unregisterPWCFileCacheStats() throws MonitoringRegistrationException {
1442        
1443        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1444        assert(httpsvcNode != null): "http-service node is null";
1445        StatsHolder fcNode = httpsvcNode.getChild(MonitoredObjectType.FILE_CACHE.getTypeName());
1446        assert(fcNode != null): "file-cache node is null";
1447        fcNode.unregisterMBean();
1448        //httpsvcNode.removeChild(MonitoredObjectType.FILE_CACHE.getTypeName());
1449
}
1450    
1451    // Registration of PWCHttpServiceStats
1452
public void registerPWCHttpServiceStats(
1453           com.sun.enterprise.admin.monitor.stats.PWCHttpServiceStats stats,
1454           MonitoringLevelListener listener) throws MonitoringRegistrationException {
1455        
1456        if(stats == null)
1457            throw new IllegalArgumentException JavaDoc("PWCHttpServiceStats is null");
1458        // the MBean for http-service gets registered in the initializeHttpService(), we need
1459
// it preserved for PE case.
1460
// To make this work in the SE/EE case, we will need unregister the PE MBean and re-register
1461
// it with Stats if the monitoring on http-service is enabled, else we just set the Stats
1462
StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1463        assert(httpsvcNode != null): "HttpService is not initialized correctly";
1464        httpsvcNode.setStats(stats);
1465        httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCHttpServiceStats.class);
1466        if(shouldRegisterMBean(MonitoredObjectType.HTTP_SERVICE)) {
1467            httpsvcNode.unregisterMBean();
1468            httpsvcNode.registerMBean();
1469        }
1470    }
1471    
1472    // Unregistration of PWCHttpServiceStats
1473
public void unregisterPWCHttpServiceStats() throws MonitoringRegistrationException {
1474        
1475        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1476        assert(httpsvcNode != null): "http-service node is null";
1477        httpsvcNode.unregisterMBean();
1478        httpsvcNode.setStats(null);
1479        // hack to recreate the http-service node.
1480
// won't accept null as a value for StatsClass
1481
httpsvcNode.setStatsClass(javax.management.j2ee.statistics.Stats JavaDoc.class);
1482        httpsvcNode.registerMBean();
1483    }
1484    
1485    // Registration of PWCKeepAliveStats
1486
public void registerPWCKeepAliveStats(
1487           com.sun.enterprise.admin.monitor.stats.PWCKeepAliveStats stats,
1488           MonitoringLevelListener listener) throws MonitoringRegistrationException {
1489        
1490        if(stats == null)
1491            throw new IllegalArgumentException JavaDoc("PWCHttpServiceStats is null");
1492        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1493        assert(httpsvcNode != null): "HttpService is not initialized correctly";
1494        httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.KEEP_ALIVE.getTypeName(), MonitoredObjectType.KEEP_ALIVE);
1495        httpsvcNode.setStats(stats);
1496        httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCKeepAliveStats.class);
1497        httpsvcNode.setDottedName(DottedNameFactory.getKeepAliveDottedName());
1498        httpsvcNode.setObjectName(MonitoringObjectNames.getKeepAliveObjectName());
1499        if(shouldRegisterMBean(MonitoredObjectType.KEEP_ALIVE))
1500            httpsvcNode.registerMBean();
1501    }
1502    // Unregistration of PWCKeepAliveStats
1503
public void unregisterPWCKeepAliveStats() throws MonitoringRegistrationException {
1504        
1505        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1506        assert(httpsvcNode != null): "http-service node is null";
1507        StatsHolder kaNode = httpsvcNode.getChild(MonitoredObjectType.KEEP_ALIVE.getTypeName());
1508        assert(kaNode != null): "keep-alive node is null";
1509        kaNode.unregisterMBean();
1510        //httpsvcNode.removeChild(MonitoredObjectType.KEEP_ALIVE.getTypeName());
1511
}
1512    
1513    // Registration of PWCRequestStats
1514
public void registerPWCRequestStats(
1515           com.sun.enterprise.admin.monitor.stats.PWCRequestStats stats,
1516           String JavaDoc vsId,
1517           MonitoringLevelListener listener) throws MonitoringRegistrationException {
1518               
1519        if((stats == null) || (vsId == null) || (vsId.equals("")))
1520            throw new IllegalArgumentException JavaDoc("Invalid arguments for registration of request stats");
1521        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1522        assert(httpsvcNode != null): "http-service node is null";
1523        StatsHolder vsNode = httpsvcNode.getChild(vsId);
1524        assert(vsNode != null): "virtual-server is not initialized correctly";
1525        vsNode = vsNode.addChild(MonitoredObjectType.REQUEST.getTypeName(), MonitoredObjectType.REQUEST);
1526        vsNode.setStats(stats);
1527        vsNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCRequestStats.class);
1528        vsNode.setDottedName(DottedNameFactory.getRequestDottedName(vsId));
1529        vsNode.setObjectName(MonitoringObjectNames.getRequestObjectName(vsId));
1530        if(shouldRegisterMBean(MonitoredObjectType.REQUEST))
1531            vsNode.registerMBean();
1532    }
1533    
1534    // Unregistration of PWCRequestStats
1535
public void unregisterPWCRequestStats(String JavaDoc vsId) throws MonitoringRegistrationException {
1536        
1537        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1538        assert(httpsvcNode != null): "http-service node is null";
1539        StatsHolder vsNode = httpsvcNode.getChild(vsId);
1540        assert(vsNode != null): "virtual-server node is null";
1541        StatsHolder requestNode = vsNode.getChild(MonitoredObjectType.REQUEST.getTypeName());
1542        assert(requestNode != null): "request node is null";
1543        requestNode.unregisterMBean();
1544        //vsNode.removeChild(MonitoredObjectType.REQUEST.getTypeName());
1545
}
1546    
1547    // Registration of PWCThreadPoolStats
1548
public void registerPWCThreadPoolStats(
1549           com.sun.enterprise.admin.monitor.stats.PWCThreadPoolStats stats,
1550           MonitoringLevelListener listener) throws MonitoringRegistrationException {
1551        
1552        if(stats == null)
1553            throw new IllegalArgumentException JavaDoc("PWCThreadPoolStats is null");
1554        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1555        assert(httpsvcNode != null): "HttpService is not initialized correctly";
1556        httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.PWC_THREAD_POOL.getTypeName(), MonitoredObjectType.PWC_THREAD_POOL);
1557        httpsvcNode.setStats(stats);
1558        httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCThreadPoolStats.class);
1559        httpsvcNode.setDottedName(DottedNameFactory.getPWCThreadPoolDottedName());
1560        httpsvcNode.setObjectName(MonitoringObjectNames.getPWCThreadPoolObjectName());
1561        if(shouldRegisterMBean(MonitoredObjectType.PWC_THREAD_POOL))
1562            httpsvcNode.registerMBean();
1563    }
1564    
1565    // Unregistration of PWCThreadPoolStats
1566
public void unregisterPWCThreadPoolStats() throws MonitoringRegistrationException {
1567        
1568        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1569        assert(httpsvcNode != null): "http-service node is null";
1570        StatsHolder tpNode = httpsvcNode.getChild(MonitoredObjectType.PWC_THREAD_POOL.getTypeName());
1571        assert(tpNode != null): "pwc-thread-pool node is null";
1572        tpNode.unregisterMBean();
1573        //httpsvcNode.removeChild(MonitoredObjectType.PWC_THREAD_POOL.getTypeName());
1574
}
1575    
1576    // Registration of PWCVirtualServerStats
1577
public void registerPWCVirtualServerStats(
1578           com.sun.enterprise.admin.monitor.stats.PWCVirtualServerStats stats,
1579           String JavaDoc vsId,
1580           MonitoringLevelListener listener) throws MonitoringRegistrationException {
1581               
1582        if((stats == null) || (vsId == null) || (vsId.equals("")))
1583            throw new IllegalArgumentException JavaDoc("Invalid arguments for registration of vs stats");
1584        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1585        assert(httpsvcNode != null): "HttpService is not initialized correctly";
1586        httpsvcNode = httpsvcNode.addChild(vsId, MonitoredObjectType.VIRTUAL_SERVER);
1587        httpsvcNode.setStats(stats);
1588        httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCVirtualServerStats.class);
1589        httpsvcNode.setDottedName(DottedNameFactory.getHttpSvcVirtualServerDottedName(vsId));
1590        httpsvcNode.setObjectName(MonitoringObjectNames.getVirtualServerObjectName(vsId));
1591        if(shouldRegisterMBean(MonitoredObjectType.VIRTUAL_SERVER))
1592            httpsvcNode.registerMBean();
1593    }
1594
1595    // Unregistration of PWCVirtualServerStats
1596
public void unregisterPWCVirtualServerStats(String JavaDoc vsId) throws MonitoringRegistrationException {
1597        
1598        StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName());
1599        assert(httpsvcNode != null): "http-service node is null";
1600        StatsHolder vsNode = httpsvcNode.getChild(vsId);
1601        assert(vsNode != null): "virtual-server node is null";
1602        // need to remove all the children of virtual-server, before it is removed
1603
Collection c = vsNode.getAllChildren();
1604        Iterator iter = c.iterator();
1605        while(iter.hasNext()) {
1606            StatsHolder childNode = (StatsHolder)iter.next();
1607            childNode.unregisterMBean();
1608            //vsNode.removeChild(childNode.getName());
1609
}
1610        // now unregister the vsNode itself
1611
vsNode.unregisterMBean();
1612        //httpsvcNode.removeChild(vsId);
1613
}
1614    // PWC related changes END
1615

1616    // Sessionstore Monitoring BEGIN
1617
public void registerStatefulSessionStoreStats(StatefulSessionStoreStats stats,
1618                                                  String JavaDoc ejbName,
1619                                                  String JavaDoc moduleName,
1620                                                  String JavaDoc j2eeAppName,
1621                                                  MonitoringLevelListener listener)
1622                                                  throws MonitoringRegistrationException {
1623        
1624        if((stats == null) || (ejbName == null) || (moduleName == null))
1625            throw new IllegalArgumentException JavaDoc("Invalid arguments for registration of StatefulSessionStore stats");
1626        
1627        StatsHolder ejbNode = getEjb(j2eeAppName, moduleName, ejbName);
1628        assert(ejbNode != null): "EJB node is not initialized correctly";
1629        ejbNode = ejbNode.addChild(MonitoredObjectType.SESSION_STORE.getTypeName(), MonitoredObjectType.SESSION_STORE);
1630        ejbNode.setStats(stats);
1631        if(stats instanceof com.sun.enterprise.admin.monitor.stats.HAStatefulSessionStoreStats)
1632            ejbNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.HAStatefulSessionStoreStats.class);
1633        else
1634            ejbNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.StatefulSessionStoreStats.class);
1635        ejbNode.setDottedName(DottedNameFactory.getStatefulSessionStoreDottedName(ejbName, moduleName, j2eeAppName));
1636        ejbNode.setObjectName(MonitoringObjectNames.getStatefulSessionStoreObjectName(ejbName, moduleName, j2eeAppName));
1637        addMonitoringLevelListener(listener); //listener can be null
1638
if(shouldRegisterMBean(MonitoredObjectType.SESSION_STORE))
1639            ejbNode.registerMBean();
1640    }
1641    
1642    public void unregisterStatefulSessionStoreStats(String JavaDoc ejbName,
1643                                                    String JavaDoc moduleName,
1644                                                    String JavaDoc j2eeAppName)
1645                                                    throws MonitoringRegistrationException {
1646                                                        
1647        if((ejbName == null)|| (moduleName == null))
1648            throw new IllegalArgumentException JavaDoc("Invalid arguments for the unregistration of StatefulSessionStore stats");
1649        
1650        StatsHolder ejbNode = getEjb(j2eeAppName, moduleName, ejbName);
1651        assert(ejbNode != null): "EJB node is not initialized correctly";
1652        StatsHolder storeNode = ejbNode.getChild(MonitoredObjectType.SESSION_STORE.getTypeName());
1653        assert(storeNode != null): "SessionStore node is not initialized correctly";
1654        storeNode.unregisterMBean();
1655        ejbNode.removeChild(MonitoredObjectType.SESSION_STORE.getTypeName());
1656    }
1657    // Sessionstore Monitoring END
1658

1659    // Timer monitoring BEGIN
1660
public void registerTimerStats(TimerServiceStats stats,
1661                                   String JavaDoc ejbName,
1662                                   String JavaDoc moduleName,
1663                                   String JavaDoc j2eeAppName,
1664                                   MonitoringLevelListener listener)
1665                                   throws MonitoringRegistrationException {
1666        
1667        if((stats == null) || (ejbName == null) || (moduleName == null))
1668            throw new IllegalArgumentException JavaDoc("Invalid arguments for registration of Timer stats");
1669        
1670        StatsHolder ejbNode = getEjb(j2eeAppName, moduleName, ejbName);
1671        assert(ejbNode != null): "EJB node is not initialized correctly";
1672        ejbNode = ejbNode.addChild(MonitoredObjectType.TIMERS.getTypeName(), MonitoredObjectType.TIMERS);
1673        ejbNode.setStats(stats);
1674        ejbNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.TimerServiceStats.class);
1675        ejbNode.setDottedName(DottedNameFactory.getTimerDottedName(ejbName, moduleName, j2eeAppName));
1676        ejbNode.setObjectName(MonitoringObjectNames.getTimerObjectName(ejbName, moduleName, j2eeAppName));
1677        addMonitoringLevelListener(listener); //listener can be null
1678
if(shouldRegisterMBean(MonitoredObjectType.TIMERS))
1679            ejbNode.registerMBean();
1680    }
1681    
1682    public void unregisterTimerStats(String JavaDoc ejbName,
1683                                     String JavaDoc moduleName,
1684                                     String JavaDoc j2eeAppName)
1685                                     throws MonitoringRegistrationException {
1686        
1687        if((ejbName == null)|| (moduleName == null))
1688            throw new IllegalArgumentException JavaDoc("Invalid arguments for the unregistration of Timer stats");
1689        
1690        StatsHolder ejbNode = getEjb(j2eeAppName, moduleName, ejbName);
1691        assert(ejbNode != null): "EJB node is not initialized correctly";
1692        StatsHolder timerNode = ejbNode.getChild(MonitoredObjectType.TIMERS.getTypeName());
1693        assert(timerNode != null): "Timer node is not initialized correctly";
1694        timerNode.unregisterMBean();
1695        ejbNode.removeChild(MonitoredObjectType.TIMERS.getTypeName());
1696    }
1697        
1698    // Timer monitoring END
1699

1700    // Web Services Monitoring BEGIN
1701

1702    public void registerWSAggregateStatsForWeb(Stats stats,
1703                                   String JavaDoc endpointName,
1704                                   String JavaDoc moduleName,
1705                                   String JavaDoc ctxRoot,
1706                                   String JavaDoc j2eeAppName,
1707                                   String JavaDoc vs,
1708                                   MonitoringLevelListener listener)
1709                                   throws MonitoringRegistrationException {
1710        
1711        if((stats == null) || (endpointName == null) || (moduleName == null))
1712            throw new IllegalArgumentException JavaDoc(
1713                "Invalid arguments for registration of WS aggregate stats");
1714        
1715        StatsHolder wsNode = getWebServiceEndpointForWeb(j2eeAppName,
1716            moduleName, ctxRoot, vs, endpointName);
1717        assert(wsNode != null): "Web Service node is not initialized correctly";
1718        wsNode = wsNode.addChild(MonitoredObjectType.WEBSERVICE_ENDPOINT.
1719                getTypeName(), MonitoredObjectType.WEBSERVICE_ENDPOINT);
1720        wsNode.setStats(stats);
1721        wsNode.setStatsClassName("com.sun.appserv.management.monitor.statistics.WebServiceEndpointAggregateStats");
1722        wsNode.setDottedName( DottedNameFactory.
1723            getWebServiceAggregateStatsInWebDottedName(
1724                                endpointName, moduleName, j2eeAppName));
1725        wsNode.setObjectName(
1726            MonitoringObjectNames.getWebServiceObjectNameForWeb(
1727                    endpointName, j2eeAppName, ctxRoot, vs ));
1728        addMonitoringLevelListener(listener); //listener can be null
1729
if(shouldRegisterMBean(MonitoredObjectType.WEBSERVICE_ENDPOINT))
1730            wsNode.registerMBean();
1731    }
1732    
1733    public void unregisterWSAggregateStatsForWeb(String JavaDoc endpointName,
1734                                     String JavaDoc moduleName,
1735                                     String JavaDoc ctxRoot,
1736                                     String JavaDoc j2eeAppName,
1737                                     String JavaDoc vs)
1738                                     throws MonitoringRegistrationException {
1739        
1740        if((endpointName == null)|| (moduleName == null))
1741            throw new IllegalArgumentException JavaDoc(
1742            "Invalid arguments for the unregistration of Web Service stats");
1743        
1744        StatsHolder wsNode = getWebServiceEndpointForWeb(j2eeAppName,
1745            moduleName, ctxRoot, vs, endpointName);
1746        assert(wsNode != null): "Web Service node is not initialized correctly";
1747        StatsHolder endpointNode =
1748        wsNode.getChild(MonitoredObjectType.WEBSERVICE_ENDPOINT.getTypeName());
1749        assert(endpointNode != null):
1750                "Endpoint node is not initialized correctly";
1751        endpointNode.unregisterMBean();
1752        wsNode.removeChild(MonitoredObjectType.WEBSERVICE_ENDPOINT.
1753            getTypeName());
1754    }
1755
1756    public void registerWSAggregateStatsForEjb(Stats stats,
1757                                   String JavaDoc endpointName,
1758                                   String JavaDoc moduleName,
1759                                   String JavaDoc j2eeAppName,
1760                                   MonitoringLevelListener listener)
1761                                   throws MonitoringRegistrationException {
1762        
1763        if((stats == null) || (endpointName == null) || (moduleName == null))
1764            throw new IllegalArgumentException JavaDoc(
1765                "Invalid arguments for registration of WS aggregate stats");
1766        
1767        StatsHolder wsNode = getWebServiceEndpointForEjb(j2eeAppName,moduleName,
1768            endpointName);
1769        assert(wsNode != null): "Web Service node is not initialized correctly";
1770        wsNode = wsNode.addChild(MonitoredObjectType.WEBSERVICE_ENDPOINT.
1771                getTypeName(), MonitoredObjectType.WEBSERVICE_ENDPOINT);
1772        wsNode.setStats(stats);
1773        wsNode.setStatsClassName("com.sun.appserv.management.monitor.statistics.WebServiceEndpointAggregateStats");
1774        wsNode.setDottedName( DottedNameFactory.
1775            getWebServiceAggregateStatsInEjbDottedName(
1776                                endpointName, moduleName, j2eeAppName));
1777        wsNode.setObjectName(
1778            MonitoringObjectNames.getWebServiceObjectNameForEjb(
1779                    endpointName, moduleName, j2eeAppName));
1780        addMonitoringLevelListener(listener); //listener can be null
1781
if(shouldRegisterMBean(MonitoredObjectType.WEBSERVICE_ENDPOINT))
1782            wsNode.registerMBean();
1783    }
1784    
1785    public void unregisterWSAggregateStatsForEjb(String JavaDoc endpointName,
1786                                     String JavaDoc moduleName,
1787                                     String JavaDoc j2eeAppName)
1788                                     throws MonitoringRegistrationException {
1789        
1790        if((endpointName == null)|| (moduleName == null))
1791            throw new IllegalArgumentException JavaDoc(
1792            "Invalid arguments for the unregistration of Web Service stats");
1793        
1794        StatsHolder wsNode = getWebServiceEndpointForEjb(j2eeAppName,moduleName, endpointName);
1795
1796        assert(wsNode != null): "Web Service node is not initialized correctly";
1797        StatsHolder endpointNode =
1798        wsNode.getChild(MonitoredObjectType.WEBSERVICE_ENDPOINT.getTypeName());
1799        assert(endpointNode != null):
1800                "Endpoint node is not initialized correctly";
1801        endpointNode.unregisterMBean();
1802        wsNode.removeChild(MonitoredObjectType.WEBSERVICE_ENDPOINT.
1803            getTypeName());
1804    }
1805
1806    // Web Services Monitoring END
1807

1808    // utility methods for JVM 1.5 monitoring
1809
public Collection getJvmNodes(boolean threadInfo) {
1810
1811        final Collection all = new ArrayList();
1812        final StatsHolder jvmNode = rootStatsHolder.getChild(MonitoredObjectType.JVM.getTypeName());
1813        final Collection systemNodes = jvmNode.getAllChildren();
1814        if(systemNodes != null) {
1815            final Iterator it = systemNodes.iterator();
1816            while (it.hasNext()) {
1817                StatsHolder childNode = (StatsHolder)it.next();
1818                all.add(childNode);
1819                //if the node is a garbage-collectors node add its children too
1820
if(childNode.getType() == MonitoredObjectType.JVM_GCS)
1821                    all.addAll(childNode.getAllChildren());
1822                // Add the threadinfo nodes, only if applicable
1823
if((childNode.getType() == MonitoredObjectType.JVM_THREAD) && threadInfo)
1824                    all.addAll(childNode.getAllChildren());
1825            }
1826        }
1827        return all;
1828    }
1829    
1830    public Collection getJvmThreadInfoNodes() {
1831        
1832        final Collection all = new ArrayList();
1833        final StatsHolder jvmNode = rootStatsHolder.getChild(MonitoredObjectType.JVM.getTypeName());
1834        final StatsHolder threadNode = jvmNode.getChild(MonitoredObjectType.JVM_THREAD.getTypeName());
1835        if(threadNode != null)
1836            all.addAll(threadNode.getAllChildren());
1837        
1838        return all;
1839    }
1840    
1841    public StatsHolder getRootStatsHolder() {
1842        return rootStatsHolder;
1843    }
1844}
1845
Popular Tags