KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > server > core > mbean > test > PrintMBeanDescriptionUtil


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

23
24 package com.sun.enterprise.admin.server.core.mbean.test;
25
26 import javax.management.*;
27 //import com.sun.enterprise.admin.server.core.mbean.meta.*;
28
import com.sun.enterprise.admin.util.*;
29 import com.sun.enterprise.admin.server.core.mbean.config.*;
30 import com.sun.enterprise.admin.server.core.jmx.*;
31
32 public class PrintMBeanDescriptionUtil
33 {
34     
35     /**
36      * Creates new MBeanInfoTester
37      */

38     
39     public PrintMBeanDescriptionUtil()
40     {
41     }
42     
43     /**
44      * @param args the command line arguments
45      */

46     
47     public static void main(String JavaDoc args[])
48     {
49         new PrintMBeanDescriptionUtil().test(args);
50     }
51     
52     private void printPropertyEntries(DynamicMBean mbean)
53     {
54         print("\n#**************************************************************");
55         String JavaDoc name = mbean.getClass().getName();
56         name = name.substring(name.lastIndexOf('.')+1);
57         print("# Text Descriptions for MBean: "+name);
58         print("#**************************************************************");
59         printDescr(mbean.getMBeanInfo());
60     }
61     public void test(String JavaDoc args[])
62     {
63         try
64         {
65             MBeanServer mbs = SunoneInterceptor.getMBeanServerInstance();
66             printPropertyEntries(new GenericConfigurator());
67 // printPropertyEntries(new JCAAdminHandler());
68
printPropertyEntries(new JMSAdminHandler("ias1"));
69             printPropertyEntries(new ManagedCustomResource("ias1","any"));
70             printPropertyEntries(new ManagedEjbContainer("ias1"));
71 // printPropertyEntries(new ManagedHTTPConnectionGroup("ias1","any","any"));
72
printPropertyEntries(new ManagedHTTPListener("ias1","any"));
73             printPropertyEntries(new ManagedHTTPService("ias1"));
74             printPropertyEntries(new ManagedJDBCConnectionPool("ias1","any"));
75             printPropertyEntries(new ManagedJDBCResource("ias1","any"));
76             printPropertyEntries(new ManagedJMSResource("ias1","any"));
77             printPropertyEntries(new ManagedJNDIResource("ias1","any"));
78             printPropertyEntries(new ManagedJVM("ias1"));
79             printPropertyEntries(new ManagedJavaMailResource("ias1","any"));
80             printPropertyEntries(new ManagedLogService("ias1"));
81             printPropertyEntries(new ManagedMdbContainer("ias1"));
82             printPropertyEntries(new ManagedORBComponent("ias1"));
83             printPropertyEntries(new ManagedORBListener("ias1","any"));
84             printPropertyEntries(new ManagedPMFactoryResource("ias1","any"));
85             printPropertyEntries(new ManagedSecurityService("ias1"));
86             printPropertyEntries(new ManagedServerInstance("ias1",new HostAndPort("any",1), false));
87             printPropertyEntries(new ManagedStandaloneConnectorModule("ias1","any"));
88             printPropertyEntries(new ManagedStandaloneJ2EEEjbJarModule("ias1","any"));
89             printPropertyEntries(new ManagedStandaloneJ2EEWebModule("ias1","any"));
90             printPropertyEntries(new ManagedTransactionService("ias1"));
91             printPropertyEntries(new ManagedWebContainer("ias1"));
92             printPropertyEntries(new ServerController());
93         }
94         catch(Throwable JavaDoc e)
95         {
96             print(e.getMessage());
97             e.printStackTrace();
98         }
99     }
100
101     private void printDescr(MBeanInfo info)
102     {
103         printDescr(info.getDescription());
104         printDescr(info.getAttributes());
105         printDescr(info.getConstructors());
106         printDescr(info.getNotifications());
107         printDescr(info.getOperations());
108     }
109     
110     //*****************************************************************************************
111
private void printDescr(MBeanAttributeInfo info)
112     {
113         printDescr(info.getDescription());
114     }
115     
116     //*****************************************************************************************
117
private void printDescr(MBeanConstructorInfo info)
118     {
119         printDescr(info.getDescription());
120         printDescr(info.getSignature());
121     }
122     
123     //*****************************************************************************************
124
private void printDescr(MBeanNotificationInfo info)
125     {
126         printDescr(info.getDescription());
127         printDescr(info.getNotifTypes());
128     }
129     //*****************************************************************************************
130
private void printDescr(MBeanOperationInfo info)
131     {
132         printDescr(info.getDescription());
133         printDescr(info.getSignature());
134     }
135     //*****************************************************************************************
136
private void printDescr(MBeanParameterInfo info)
137     {
138         printDescr(info.getDescription());
139     }
140     
141     //*****************************************************************************************
142
private void printDescr(String JavaDoc descr)
143     {
144         if(descr!=null && descr.length()>0)
145             print(descr+" = "+descr);
146     }
147     
148     //*****************************************************************************************
149
private void printDescr(Object JavaDoc[] infos)
150     {
151         for(int i=0; i<infos.length; i++)
152             if(infos[i] instanceof MBeanAttributeInfo)
153                 printDescr((MBeanAttributeInfo)infos[i]);
154             else
155                 if(infos[i] instanceof MBeanConstructorInfo)
156                     printDescr((MBeanConstructorInfo)infos[i]);
157                 else
158                     if(infos[i] instanceof MBeanNotificationInfo)
159                         printDescr((MBeanNotificationInfo)infos[i]);
160                     else
161                         if(infos[i] instanceof MBeanOperationInfo)
162                             printDescr((MBeanOperationInfo)infos[i]);
163                         else
164                             if(infos[i] instanceof MBeanParameterInfo)
165                                 printDescr((MBeanParameterInfo)infos[i]);
166     }
167     
168     //*****************************************************************************************
169
private void print(String JavaDoc str)
170     {
171         System.out.println(str);
172     }
173 }
174
Popular Tags