KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > support > TypeInfos


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28  
29 /*
30  */

31
32 package com.sun.enterprise.management.support;
33
34 import java.util.Set JavaDoc;
35 import java.util.List JavaDoc;
36 import java.util.ArrayList JavaDoc;
37 import java.util.Map JavaDoc;
38 import java.util.HashMap JavaDoc;
39 import java.util.Collections JavaDoc;
40 import java.util.Iterator JavaDoc;
41
42 import javax.management.ObjectName JavaDoc;
43
44 import com.sun.appserv.management.util.misc.ListUtil;
45 import com.sun.appserv.management.util.misc.GSetUtil;
46 import com.sun.appserv.management.util.jmx.JMXUtil;
47 import com.sun.appserv.management.util.stringifier.SmartStringifier;
48 import com.sun.appserv.management.base.XTypes;
49 import static com.sun.appserv.management.base.XTypes.*;
50 import com.sun.appserv.management.base.Util;
51 import com.sun.appserv.management.j2ee.J2EETypes;
52
53 /**
54     Information mapping a j2eeType to other necessary information.
55  */

56 public final class TypeInfos
57 {
58     private static TypeInfos INSTANCE;
59     
60     private final Map JavaDoc<String JavaDoc,TypeInfo> mTypeToInfoMap;
61     
62         private
63     TypeInfos( )
64         throws ClassNotFoundException JavaDoc
65     {
66         mTypeToInfoMap = new HashMap JavaDoc<String JavaDoc,TypeInfo>();
67         
68         initMap( );
69     }
70     
71         public static synchronized TypeInfos
72     getInstance()
73     {
74         try
75         {
76             if ( INSTANCE == null )
77             {
78                 INSTANCE = new TypeInfos( );
79             }
80         }
81         catch( ClassNotFoundException JavaDoc e )
82         {
83             e.printStackTrace();
84             assert( false );
85             throw new RuntimeException JavaDoc( e );
86         }
87         catch( Throwable JavaDoc t )
88         {
89             t.printStackTrace();
90             assert( false );
91             throw new RuntimeException JavaDoc( t );
92         }
93         
94
95         return( INSTANCE );
96     }
97     
98         private void
99     add(
100         final TypeData typeData )
101         throws ClassNotFoundException JavaDoc
102     {
103         final String JavaDoc j2eeType = typeData.getJ2EEType();
104         
105         final TypeInfo info = new TypeInfo( typeData );
106         
107         mTypeToInfoMap.put( j2eeType, info );
108     }
109     
110     
111         private void
112     initData()
113         throws ClassNotFoundException JavaDoc
114     {
115         final Object JavaDoc[] data = DATA;
116     
117         for( int i = 0; i < data.length; ++i )
118         {
119             final TypeData typeData = (TypeData)data[ i ];
120             
121             assert( ! mTypeToInfoMap.containsKey( typeData.getJ2EEType() )) :
122                 "init(): type already exists: " + typeData.getJ2EEType();
123             add( typeData );
124         }
125     }
126     
127     
128     private static final class MiscChild extends TypeData
129     {
130         public MiscChild(
131             final String JavaDoc j2eeType,
132             final String JavaDoc parentJ2EEType )
133         {
134             super( j2eeType, parentJ2EEType );
135         }
136         
137         public MiscChild(
138             final String JavaDoc j2eeType,
139             final Set JavaDoc<String JavaDoc> legalParentJ2EETypes )
140         {
141             super( j2eeType, legalParentJ2EETypes );
142         }
143         
144         public MiscChild(
145             final String JavaDoc j2eeType,
146             final Set JavaDoc<String JavaDoc> legalParentJ2EETypes,
147             final String JavaDoc containedByJ2EEType )
148         {
149             super( j2eeType, legalParentJ2EETypes, containedByJ2EEType );
150         }
151     }
152     
153     private static final class Containee extends TypeData
154     {
155         public Containee(
156             final String JavaDoc j2eeType,
157             final String JavaDoc containerType )
158         {
159             super( j2eeType, null, containerType );
160         }
161     }
162     
163     private static final class MixedChild extends TypeData
164     {
165         public MixedChild(
166             final String JavaDoc j2eeType,
167             final Set JavaDoc<String JavaDoc> legalParentJ2EETypes )
168         {
169             super( j2eeType, legalParentJ2EETypes );
170         }
171     }
172     
173     private static final class DomainRootChild extends TypeData
174     {
175         public DomainRootChild( final String JavaDoc j2eeType )
176         {
177             super( j2eeType, null, DOMAIN_ROOT );
178         }
179     }
180     
181     private static class DomainConfigChild extends TypeData
182     {
183         public DomainConfigChild( final String JavaDoc j2eeType )
184         {
185             super( j2eeType, null, DOMAIN_CONFIG );
186         }
187     }
188     
189     private static final class ConfigConfigChild extends TypeData
190     {
191         public ConfigConfigChild( final String JavaDoc j2eeType )
192         {
193             super( j2eeType, CONFIG_CONFIG );
194         }
195     }
196     
197     private static final class ConfigResource extends TypeData
198     {
199         public ConfigResource( final String JavaDoc j2eeType )
200         {
201             super( j2eeType, null, DOMAIN_CONFIG );
202         }
203     }
204     
205     private static final class ResourceConfigMgr extends TypeData
206     {
207         public ResourceConfigMgr( final String JavaDoc j2eeType )
208         {
209             super( j2eeType, null, DOMAIN_CONFIG );
210         }
211     }
212     
213     private static final class SecurityServiceChild extends TypeData
214     {
215         public SecurityServiceChild( final String JavaDoc j2eeType )
216         {
217             super( j2eeType, SECURITY_SERVICE_CONFIG );
218         }
219     }
220     
221     private static final class HTTPServiceChild extends TypeData
222     {
223         public HTTPServiceChild( final String JavaDoc j2eeType )
224         {
225             super( j2eeType, HTTP_SERVICE_CONFIG );
226         }
227     }
228     
229     private static final class LBConfigChild extends TypeData
230     {
231         public LBConfigChild( final String JavaDoc j2eeType )
232         {
233             super( j2eeType, LB_CONFIG );
234         }
235     }
236         
237         private static final class IIOPServiceChild extends TypeData
238     {
239         public IIOPServiceChild( final String JavaDoc j2eeType )
240         {
241             super( j2eeType, IIOP_SERVICE_CONFIG );
242         }
243     }
244     
245     private static final class AdminServiceConfigChild extends TypeData
246     {
247         public AdminServiceConfigChild( final String JavaDoc j2eeType )
248         {
249             super( j2eeType, ADMIN_SERVICE_CONFIG );
250         }
251     }
252     
253     private static final class J2EEServerChild extends TypeData
254     {
255         public J2EEServerChild( final String JavaDoc j2eeType )
256         {
257             super( j2eeType, J2EETypes.J2EE_SERVER );
258         }
259     }
260     
261     private static final class J2EEDomainChild extends TypeData
262     {
263         public J2EEDomainChild( final String JavaDoc j2eeType )
264         {
265             super( j2eeType, null, J2EETypes.J2EE_DOMAIN );
266         }
267     }
268     
269     private static final class ServerRootMonitorChild extends TypeData
270     {
271         public ServerRootMonitorChild( final String JavaDoc j2eeType )
272         {
273             super( j2eeType, SERVER_ROOT_MONITOR );
274         }
275     }
276     
277     private static final class LoadBalancerMonitorChild extends TypeData
278     {
279         public LoadBalancerMonitorChild ( final String JavaDoc j2eeType )
280         {
281             super( j2eeType, XTypes.LOAD_BALANCER_MONITOR );
282         }
283     }
284         
285     private static final class LoadBalancerClusterMonitorChild extends TypeData
286     {
287         public LoadBalancerClusterMonitorChild ( final String JavaDoc j2eeType )
288         {
289             super( j2eeType, XTypes.LOAD_BALANCER_CLUSTER_MONITOR );
290         }
291     }
292
293     private static final class LoadBalancerServerMonitorChild extends TypeData
294     {
295         public LoadBalancerServerMonitorChild ( final String JavaDoc j2eeType )
296         {
297             super( j2eeType, XTypes.LOAD_BALANCER_SERVER_MONITOR );
298         }
299     }
300
301     private static final class LoadBalancerApplicationMonitorChild extends TypeData
302     {
303         public LoadBalancerApplicationMonitorChild ( final String JavaDoc j2eeType )
304         {
305             super( j2eeType, XTypes.LOAD_BALANCER_APPLICATION_MONITOR );
306         }
307     }
308         
309         private static final class HTTPServiceMonitorChild extends TypeData
310     {
311         public HTTPServiceMonitorChild( final String JavaDoc j2eeType )
312         {
313             super( j2eeType, HTTP_SERVICE_MONITOR );
314         }
315     }
316     
317     private static final class EJBModuleChild extends TypeData
318     {
319         public EJBModuleChild( final String JavaDoc j2eeType)
320         {
321             super( j2eeType, J2EETypes.EJB_MODULE );
322         }
323     }
324
325     private static final Set JavaDoc<String JavaDoc> CLUSTER_OR_SERVER_CONFIG =
326         GSetUtil.newUnmodifiableStringSet( CLUSTER_CONFIG,
327             STANDALONE_SERVER_CONFIG, CLUSTERED_SERVER_CONFIG );
328         
329 /**
330     Data relating a j2eeType to its legal parent type(s).
331  */

332 private static TypeData[] DATA = new TypeData[]
333 {
334 new MiscChild( DOMAIN_ROOT, null, null ),
335
336 new DomainRootChild( SYSTEM_INFO ),
337 new DomainRootChild( UPLOAD_DOWNLOAD_MGR ),
338 new DomainRootChild( DOMAIN_CONFIG ),
339 new DomainRootChild( NOTIFICATION_SERVICE_MGR ),
340 new DomainRootChild( DEPLOYMENT_MGR ),
341 new DomainRootChild( QUERY_MGR ),
342 new DomainRootChild( WEB_SERVICE_MGR ),
343 new DomainRootChild( BULK_ACCESS ),
344 new DomainRootChild( SAMPLE ),
345 new DomainRootChild( CONFIG_DOTTED_NAMES ),
346 new DomainRootChild( MONITORING_DOTTED_NAMES ),
347 new DomainRootChild( NOTIFICATION_EMITTER_SERVICE ),
348
349 new DomainRootChild( LOAD_BALANCER ),
350 new MiscChild( NOTIFICATION_SERVICE, NOTIFICATION_SERVICE_MGR),
351
352 new DomainConfigChild( CONFIG_CONFIG ),
353 new DomainConfigChild( WEB_MODULE_CONFIG ),
354 new DomainConfigChild( EJB_MODULE_CONFIG ),
355 new DomainConfigChild( J2EE_APPLICATION_CONFIG ),
356 new DomainConfigChild( RAR_MODULE_CONFIG ),
357 new DomainConfigChild( APP_CLIENT_MODULE_CONFIG ),
358
359 new DomainConfigChild( NODE_AGENT_CONFIG ),
360 new DomainConfigChild( RESOURCE_ADAPTER_CONFIG ),
361 new DomainConfigChild( LIFECYCLE_MODULE_CONFIG ),
362
363 new DomainConfigChild( LOAD_BALANCER_CONFIG ),
364 new DomainConfigChild( LB_CONFIG ),
365 new DomainConfigChild( CLUSTER_CONFIG ),
366 new DomainConfigChild( STANDALONE_SERVER_CONFIG ),
367 new DomainConfigChild( CONNECTOR_MODULE_CONFIG ),
368 new DomainConfigChild( CUSTOM_MBEAN_CONFIG ),
369
370 new DomainConfigChild( CLUSTERED_SERVER_CONFIG ),
371
372
373 new ConfigConfigChild( MANAGEMENT_RULES_CONFIG ),
374 new MiscChild( MANAGEMENT_RULE_CONFIG, MANAGEMENT_RULES_CONFIG),
375 new MiscChild( EVENT_CONFIG, MANAGEMENT_RULE_CONFIG),
376 new MiscChild( ACTION_CONFIG, MANAGEMENT_RULE_CONFIG),
377
378 //new ConfigConfigChild( ALERT_SERVICE_CONFIG ),
379
//new MiscChild( ALERT_SUBSCRIPTION_CONFIG, ALERT_SERVICE_CONFIG ),
380
//new MiscChild( FILTER_CONFIG, ALERT_SUBSCRIPTION_CONFIG ),
381
//new MiscChild( LISTENER_CONFIG, ALERT_SUBSCRIPTION_CONFIG ),
382

383 new MiscChild( SECURITY_MAP_CONFIG, CONNECTOR_CONNECTION_POOL_CONFIG ),
384 new MiscChild( BACKEND_PRINCIPAL_CONFIG, SECURITY_MAP_CONFIG ),
385
386 new MixedChild( WEB_SERVICE_ENDPOINT_CONFIG,
387     GSetUtil.newUnmodifiableStringSet( J2EE_APPLICATION_CONFIG, EJB_MODULE_CONFIG,
388         WEB_MODULE_CONFIG ) ),
389 new MiscChild( REGISTRY_LOCATION_CONFIG, WEB_SERVICE_ENDPOINT_CONFIG ),
390 new MiscChild( TRANSFORMATION_RULE_CONFIG, WEB_SERVICE_ENDPOINT_CONFIG ),
391
392
393 new ConfigResource( CONNECTOR_CONNECTION_POOL_CONFIG ),
394 new ConfigResource( CUSTOM_RESOURCE_CONFIG ),
395 new ConfigResource( JDBC_RESOURCE_CONFIG ),
396 new ConfigResource( JNDI_RESOURCE_CONFIG ),
397 new ConfigResource( PERSISTENCE_MANAGER_FACTORY_RESOURCE_CONFIG ),
398 new ConfigResource( MAIL_RESOURCE_CONFIG ),
399 new ConfigResource( JDBC_CONNECTION_POOL_CONFIG ),
400 new ConfigResource( ADMIN_OBJECT_RESOURCE_CONFIG ),
401 new ConfigResource( CONNECTOR_RESOURCE_CONFIG ),
402
403
404 new AdminServiceConfigChild( DAS_CONFIG ),
405
406 new MixedChild( JMX_CONNECTOR_CONFIG,
407             GSetUtil.newUnmodifiableStringSet( ADMIN_SERVICE_CONFIG,
408                                 NODE_AGENT_CONFIG ) ),
409 //new AdminServiceConfigChild( JMX_CONNECTOR_CONFIG ),
410

411 new SecurityServiceChild( AUDIT_MODULE_CONFIG ),
412 new MixedChild( AUTH_REALM_CONFIG,
413     GSetUtil.newUnmodifiableStringSet( SECURITY_SERVICE_CONFIG, NODE_AGENT_CONFIG )
414     ),
415     
416 new SecurityServiceChild( JACC_PROVIDER_CONFIG ),
417 new SecurityServiceChild( MESSAGE_SECURITY_CONFIG ),
418
419 new ConfigConfigChild( ADMIN_SERVICE_CONFIG ),
420 new ConfigConfigChild( AVAILABILITY_SERVICE_CONFIG ),
421 new ConfigConfigChild( EJB_CONTAINER_CONFIG ),
422 new ConfigConfigChild( HTTP_SERVICE_CONFIG ),
423 new ConfigConfigChild( IIOP_SERVICE_CONFIG ),
424 new ConfigConfigChild( JAVA_CONFIG ),
425
426 new MixedChild( LOG_SERVICE_CONFIG,
427     GSetUtil.newUnmodifiableStringSet( CONFIG_CONFIG, NODE_AGENT_CONFIG )
428     ),
429
430 new ConfigConfigChild( MDB_CONTAINER_CONFIG ),
431 new ConfigConfigChild( MONITORING_SERVICE_CONFIG ),
432 new ConfigConfigChild( SECURITY_SERVICE_CONFIG ),
433 new ConfigConfigChild( CONNECTOR_SERVICE_CONFIG ),
434 new ConfigConfigChild( WEB_CONTAINER_CONFIG ),
435 new ConfigConfigChild( TRANSACTION_SERVICE_CONFIG ),
436 new ConfigConfigChild( JMS_SERVICE_CONFIG ),
437 new ConfigConfigChild( THREAD_POOL_CONFIG ),
438 new ConfigConfigChild( GROUP_MANAGEMENT_SERVICE_CONFIG ),
439 new ConfigConfigChild( DIAGNOSTIC_SERVICE_CONFIG ),
440
441
442 new HTTPServiceChild( HTTP_LISTENER_CONFIG ),
443 new HTTPServiceChild( ACCESS_LOG_CONFIG ),
444 new HTTPServiceChild( KEEP_ALIVE_CONFIG ),
445 new HTTPServiceChild( REQUEST_PROCESSING_CONFIG ),
446 new HTTPServiceChild( CONNECTION_POOL_CONFIG ),
447 new HTTPServiceChild( HTTP_PROTOCOL_CONFIG ),
448 new HTTPServiceChild( HTTP_FILE_CACHE_CONFIG ),
449 new HTTPServiceChild( VIRTUAL_SERVER_CONFIG ),
450
451 new IIOPServiceChild( IIOP_LISTENER_CONFIG ),
452 new IIOPServiceChild( ORB_CONFIG ),
453 new LBConfigChild(CLUSTER_REF_CONFIG),
454 new MiscChild( PROFILER_CONFIG, JAVA_CONFIG ),
455
456 new MiscChild( JMS_HOST_CONFIG, JMS_SERVICE_CONFIG ),
457
458 new MiscChild( HTTP_ACCESS_LOG_CONFIG, VIRTUAL_SERVER_CONFIG ),
459
460 //new MiscChild( LB_CLUSTER_REF_CONFIG, LB_CONFIG ),
461

462 new MiscChild( MODULE_LOG_LEVELS_CONFIG, LOG_SERVICE_CONFIG ),
463 new MiscChild( MODULE_MONITORING_LEVELS_CONFIG, MONITORING_SERVICE_CONFIG ),
464
465 new MiscChild( SESSION_CONFIG, WEB_CONTAINER_CONFIG ),
466 new MiscChild( SESSION_MANAGER_CONFIG, SESSION_CONFIG ),
467 new MiscChild( SESSION_PROPERTIES_CONFIG, SESSION_CONFIG ),
468
469 new MiscChild( MANAGER_PROPERTIES_CONFIG, SESSION_MANAGER_CONFIG ),
470 new MiscChild( STORE_PROPERTIES_CONFIG, SESSION_MANAGER_CONFIG ),
471     
472 new MiscChild( EJB_TIMER_SERVICE_CONFIG, EJB_CONTAINER_CONFIG ),
473 new MiscChild( EJB_CONTAINER_AVAILABILITY_CONFIG, AVAILABILITY_SERVICE_CONFIG ),
474 new MiscChild( WEB_CONTAINER_AVAILABILITY_CONFIG, AVAILABILITY_SERVICE_CONFIG ),
475 new MiscChild( JMS_AVAILABILITY_CONFIG, AVAILABILITY_SERVICE_CONFIG ),
476
477 new MixedChild( DEPLOYED_ITEM_REF_CONFIG, CLUSTER_OR_SERVER_CONFIG ),
478 new MixedChild( RESOURCE_REF_CONFIG, CLUSTER_OR_SERVER_CONFIG ),
479
480 new MixedChild( SSL_CONFIG,
481         GSetUtil.newUnmodifiableStringSet( IIOP_LISTENER_CONFIG,
482                                 IIOP_SERVICE_CONFIG,
483                                 HTTP_LISTENER_CONFIG,
484                                 JMX_CONNECTOR_CONFIG ) ),
485
486 new MixedChild( HEALTH_CHECKER_CONFIG,
487             GSetUtil.newUnmodifiableStringSet( SERVER_REF_CONFIG, CLUSTER_REF_CONFIG ) ),
488
489 new MixedChild( SERVER_REF_CONFIG,
490                 GSetUtil.newUnmodifiableStringSet( CLUSTER_CONFIG, LB_CONFIG ) ),
491 //new MiscChild( CLUSTER_REF_CONFIG, LB_CONFIG ),
492

493         
494 new MiscChild( PROVIDER_CONFIG, MESSAGE_SECURITY_CONFIG ),
495 new MiscChild( REQUEST_POLICY_CONFIG, PROVIDER_CONFIG ),
496 new MiscChild( RESPONSE_POLICY_CONFIG, PROVIDER_CONFIG ),
497             
498 //--------------------------------------------------------------------------------
499
// JSR 77 types
500
new DomainRootChild( J2EETypes.J2EE_DOMAIN ),
501
502 new J2EEDomainChild( J2EETypes.J2EE_CLUSTER ),
503 //new J2EEDomainChild( J2EETypes.J2EE_STANDALONE_SERVER ),
504
new J2EEDomainChild( J2EETypes.J2EE_SERVER ),
505
506 new J2EEServerChild( J2EETypes.JVM ),
507 new J2EEServerChild( J2EETypes.J2EE_APPLICATION ),
508 new J2EEServerChild( J2EETypes.JDBC_DRIVER ),
509 new J2EEServerChild( J2EETypes.JDBC_RESOURCE ),
510 new J2EEServerChild( J2EETypes.JMS_RESOURCE ),
511 new J2EEServerChild( J2EETypes.JNDI_RESOURCE ),
512 new J2EEServerChild( J2EETypes.JTA_RESOURCE ),
513 new J2EEServerChild( J2EETypes.RESOURCE_ADAPTER_MODULE ),
514 new J2EEServerChild( J2EETypes.RMI_IIOP_RESOURCE ),
515 new J2EEServerChild( J2EETypes.URL_RESOURCE ),
516 new J2EEServerChild( J2EETypes.JAVA_MAIL_RESOURCE ),
517 new J2EEServerChild( J2EETypes.JCA_RESOURCE ),
518
519 new MiscChild( J2EETypes.APP_CLIENT_MODULE, J2EETypes.J2EE_APPLICATION ),
520 new MiscChild( J2EETypes.EJB_MODULE, J2EETypes.J2EE_APPLICATION ),
521 new MiscChild( J2EETypes.WEB_MODULE, J2EETypes.J2EE_APPLICATION ),
522 new MiscChild( J2EETypes.RESOURCE_ADAPTER, J2EETypes.RESOURCE_ADAPTER_MODULE ),
523
524 new EJBModuleChild( J2EETypes.ENTITY_BEAN ),
525 new EJBModuleChild( J2EETypes.STATEFUL_SESSION_BEAN ),
526 new EJBModuleChild( J2EETypes.MESSAGE_DRIVEN_BEAN ),
527 new EJBModuleChild( J2EETypes.STATELESS_SESSION_BEAN ),
528
529 new MiscChild( J2EETypes.JCA_CONNECTION_FACTORY, J2EETypes.JCA_RESOURCE ),
530 new MiscChild( J2EETypes.JCA_MANAGED_CONNECTION_FACTORY, J2EETypes.JCA_RESOURCE ),
531 new MiscChild( J2EETypes.JDBC_DATA_SOURCE, J2EETypes.JDBC_RESOURCE ),
532
533 new MiscChild( J2EETypes.SERVLET, J2EETypes.WEB_MODULE ),
534
535 new MixedChild( J2EETypes.WEB_SERVICE_ENDPOINT, GSetUtil.newUnmodifiableStringSet(J2EETypes.WEB_MODULE
536 ,J2EETypes.EJB_MODULE) ),
537
538 // JMX monitoring
539
new DomainRootChild( JMX_MONITOR_MGR ),
540 new DomainRootChild( JMX_COUNTER_MONITOR ),
541 new DomainRootChild( JMX_GAUGE_MONITOR ),
542 new DomainRootChild( JMX_STRING_MONITOR ),
543
544 //-----------------
545
// Monitoring types
546
//-----------------
547
new DomainRootChild( MONITORING_ROOT ),
548 new Containee( SERVER_ROOT_MONITOR, MONITORING_ROOT ),
549
550 new ServerRootMonitorChild( JVM_MONITOR ),
551 new ServerRootMonitorChild( CALL_FLOW_MONITOR ),
552 new ServerRootMonitorChild( TRANSACTION_SERVICE_MONITOR ),
553 new ServerRootMonitorChild( HTTP_SERVICE_MONITOR ),
554 new ServerRootMonitorChild( JDBC_CONNECTION_POOL_MONITOR ),
555 new ServerRootMonitorChild( APPLICATION_MONITOR ),
556 new ServerRootMonitorChild( LOGGING ),
557
558 // ------------------------------------------
559
// load balancer monitoring mbeans hierarchy:
560
// ------------------------------------------
561
// monitoring root 1 --> M load balancer monitors
562
// load balancer monitor 1 --> N load balancer cluster monitors
563
// load balancer cluster monitor 1 --> P load balancer server monitors
564
// load balancer server monitor 1 --> Q load balancer application monitors
565
// load balancer server monitor 1 --> R load balancer context root monitors
566
new Containee( XTypes.LOAD_BALANCER_MONITOR, XTypes.MONITORING_ROOT ),
567 new LoadBalancerMonitorChild( XTypes.LOAD_BALANCER_CLUSTER_MONITOR ),
568 new LoadBalancerClusterMonitorChild( XTypes.LOAD_BALANCER_SERVER_MONITOR ),
569 new LoadBalancerServerMonitorChild( XTypes.LOAD_BALANCER_APPLICATION_MONITOR ),
570 new LoadBalancerApplicationMonitorChild( XTypes.LOAD_BALANCER_CONTEXT_ROOT_MONITOR ),
571
572 //new MiscChild( WEB_MODULE_MONITOR, APPLICATION_MONITOR ),
573
new MiscChild( WEB_MODULE_VIRTUAL_SERVER_MONITOR, APPLICATION_MONITOR ),
574 new MiscChild( SERVLET_MONITOR, WEB_MODULE_VIRTUAL_SERVER_MONITOR ),
575 new MiscChild( WEBSERVICE_ENDPOINT_MONITOR, GSetUtil.newUnmodifiableStringSet(
576 WEB_MODULE_VIRTUAL_SERVER_MONITOR , EJB_MODULE_MONITOR)),
577
578 new MiscChild( EJB_MODULE_MONITOR, APPLICATION_MONITOR ),
579 new MiscChild( STATELESS_SESSION_BEAN_MONITOR, EJB_MODULE_MONITOR ),
580 new MiscChild( STATEFUL_SESSION_BEAN_MONITOR, EJB_MODULE_MONITOR ),
581 new MiscChild( ENTITY_BEAN_MONITOR, EJB_MODULE_MONITOR ),
582 new MiscChild( MESSAGE_DRIVEN_BEAN_MONITOR, EJB_MODULE_MONITOR ),
583  
584 new MiscChild( BEAN_POOL_MONITOR,
585     GSetUtil.newUnmodifiableStringSet( ENTITY_BEAN_MONITOR, STATEFUL_SESSION_BEAN_MONITOR, STATELESS_SESSION_BEAN_MONITOR) ),
586     
587 new MiscChild( BEAN_CACHE_MONITOR,
588     GSetUtil.newUnmodifiableStringSet( ENTITY_BEAN_MONITOR, MESSAGE_DRIVEN_BEAN_MONITOR,
589         STATEFUL_SESSION_BEAN_MONITOR, STATELESS_SESSION_BEAN_MONITOR) ),
590
591 new MiscChild( BEAN_METHOD_MONITOR,
592     GSetUtil.newUnmodifiableStringSet( ENTITY_BEAN_MONITOR, STATEFUL_SESSION_BEAN_MONITOR,
593         STATELESS_SESSION_BEAN_MONITOR, MESSAGE_DRIVEN_BEAN_MONITOR) ),
594     
595             
596
597 new ServerRootMonitorChild( CONNECTOR_CONNECTION_POOL_MONITOR ),
598            
599
600 new ServerRootMonitorChild( THREAD_POOL_MONITOR ),
601 new ServerRootMonitorChild( CONNECTION_MANAGER_MONITOR ),
602
603 new MiscChild( HTTP_SERVICE_VIRTUAL_SERVER_MONITOR,HTTP_SERVICE_MONITOR ),
604 new HTTPServiceMonitorChild( HTTP_LISTENER_MONITOR ),
605 new HTTPServiceMonitorChild( FILE_CACHE_MONITOR ),
606 new HTTPServiceMonitorChild( KEEP_ALIVE_MONITOR ),
607 new HTTPServiceMonitorChild( CONNECTION_QUEUE_MONITOR ),
608
609 };
610
611     
612         private void
613     initParentsForChildType( final TypeInfo info )
614     {
615         if ( info.isSubType() )
616         {
617             final Set JavaDoc possibleParents = info.getLegalParentJ2EETypes();
618             
619             final Iterator JavaDoc parentTypeIter = possibleParents.iterator();
620             while ( parentTypeIter.hasNext() )
621             {
622                 final String JavaDoc parentJ2EEType = (String JavaDoc)parentTypeIter.next();
623                 final TypeInfo parentInfo = getInfo( parentJ2EEType );
624                 
625                 parentInfo.addChildJ2EEType( info.getJ2EEType() );
626             }
627         }
628     }
629     
630         private void
631     initChildAndContaineeTypes()
632     {
633         final Set JavaDoc<String JavaDoc> keys = getJ2EETypes();
634         
635         for( final String JavaDoc childJ2EEType : keys )
636         {
637             final TypeInfo info = getInfo( childJ2EEType );
638         
639             if ( info.isSubType() )
640             {
641                 initParentsForChildType( info );
642             }
643             else // may be contained in something
644
{
645                 final String JavaDoc containedByJ2EEType = info.getContainedByJ2EEType();
646                 
647                 if ( containedByJ2EEType != null )
648                 {
649                     final TypeInfo parentInfo = getInfo( containedByJ2EEType );
650                     parentInfo.addContaineeJ2EEType( childJ2EEType );
651                 }
652             }
653         }
654     }
655     
656     /**
657         Initialize a mapping of j2eeTypes to TypeInfo
658      */

659         private void
660     initMap()
661         throws ClassNotFoundException JavaDoc
662     {
663         initData();
664         
665         initChildAndContaineeTypes();
666     }
667
668
669         public TypeInfo
670     getInfo( final String JavaDoc j2eeType )
671     {
672         if ( j2eeType == null )
673         {
674             throw new IllegalArgumentException JavaDoc( "null" );
675         }
676         
677         final TypeInfo info = (TypeInfo)mTypeToInfoMap.get( j2eeType );
678         
679         if ( info == null )
680         {
681             throw new IllegalArgumentException JavaDoc( j2eeType );
682         }
683         
684         return( info );
685     }
686     
687     /**
688         Return the keys by which all TypeInfos are mapped.
689      */

690         public Set JavaDoc<String JavaDoc>
691     getJ2EETypes()
692     {
693         return( mTypeToInfoMap.keySet( ) );
694     }
695     
696         public String JavaDoc
697     toString()
698     {
699         final StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
700         
701         final Set JavaDoc<String JavaDoc> keys = getJ2EETypes();
702         for( final String JavaDoc j2eeType : keys )
703         {
704             final TypeInfo info = getInfo( j2eeType );
705             
706             buf.append( info.toString() );
707             buf.append( "\n" );
708         }
709         
710         return( buf.toString() );
711     }
712     
713     /**
714         Get the contained-by chain for the specified j2eeType. Calling
715         this is only legal for j2eeTypes for which Type.isSubType() is false.
716         
717         @param j2eeType
718      */

719         public String JavaDoc[]
720     getContaineeByChain( final String JavaDoc j2eeType )
721     {
722         TypeInfo info = getInfo( j2eeType );
723         if ( info.isSubType() )
724         {
725             throw new IllegalArgumentException JavaDoc( "j2eeType is a subtype: " + j2eeType );
726         }
727         
728         final List JavaDoc<String JavaDoc> list = new ArrayList JavaDoc<String JavaDoc>();
729         String JavaDoc containedByType = null;
730         while ( (containedByType = info.getContainedByJ2EEType()) != null )
731         {
732             list.add( containedByType );
733             info = getInfo( containedByType );
734         }
735         
736         Collections.reverse( list );
737         return( ListUtil.toStringArray( list ) );
738     }
739     
740     /**
741         Get the j2eeType chain for the specified ObjectName. The last element
742         is the same as the j2eeType of the ObjectName supplied; preceeding
743         types, if present, are its parent types.
744         
745         @param objectName the ObjectName to examine
746      */

747         public String JavaDoc[]
748     getJ2EETypeChain( final ObjectName JavaDoc objectName)
749     {
750         final String JavaDoc j2eeType = Util.getJ2EEType( objectName );
751         if ( j2eeType == null )
752         {
753             throw new IllegalArgumentException JavaDoc( objectName.toString() );
754         }
755         
756         TypeInfo info = getInfo( j2eeType );
757         if ( info == null )
758         {
759             throw new IllegalArgumentException JavaDoc( "uknown j2eeType: " + j2eeType );
760         }
761         
762         final List JavaDoc<String JavaDoc> list = new ArrayList JavaDoc<String JavaDoc>();
763         list.add( j2eeType );
764         while ( info.isSubType() )
765         {
766             final Set JavaDoc<String JavaDoc> possibleParentTypes = info.getLegalParentJ2EETypes();
767             
768             String JavaDoc parentJ2EEType = null;
769             if ( possibleParentTypes.size() == 1 )
770             {
771                 parentJ2EEType = GSetUtil.getSingleton( possibleParentTypes );
772             }
773             else
774             {
775                 parentJ2EEType = JMXUtil.findKey( possibleParentTypes, objectName );
776             }
777             
778             if ( parentJ2EEType == null )
779             {
780                 throw new IllegalArgumentException JavaDoc(
781                 "MBean: " + objectName +
782                 " does not have any of the possible parent keys: {" +
783                 toString( possibleParentTypes ) + "}" );
784             }
785             
786             list.add( parentJ2EEType );
787             
788             info = getInfo( parentJ2EEType );
789         }
790         
791         // list is in reverse order; child, parent, parent's parent, etc. Reverse it
792
// so that child is last
793
Collections.reverse( list );
794         
795         return( ListUtil.toStringArray( list ) );
796     }
797     
798         private String JavaDoc
799     toString( final Object JavaDoc o )
800     {
801         return( SmartStringifier.toString( o ) );
802     }
803 }
804
805
806
807
808
809
810
811
Popular Tags