KickJava   Java API By Example, From Geeks To Geeks.

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


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
30 public class MBeanEasyConfigTester
31 {
32
33     /**
34          Creates new MBeanInfoTester
35     */

36     
37     public MBeanEasyConfigTester()
38     {
39   }
40
41     /**
42         @param args the command line arguments
43     */

44     
45     public static void main (String JavaDoc args[])
46     {
47         new MBeanEasyConfigTester().test();
48   }
49
50     public void test()
51     {
52         try
53         {
54             printInfo((new EasyConfigTestMBean()).getMBeanInfo());
55         }
56         catch(Exception JavaDoc e)
57         {
58             
59             e.printStackTrace();
60         }
61     }
62     private void printInfo(MBeanInfo info)
63     {
64        print("************** MBeanInfo ******************");
65        print("ClassName="+info.getClassName());
66        print("Description="+info.getDescription());
67        printInfo(info.getAttributes());
68        printInfo(info.getConstructors());
69        printInfo(info.getNotifications());
70        printInfo(info.getOperations());
71     }
72
73     //*****************************************************************************************
74
private void printInfo(MBeanAttributeInfo info)
75     {
76       print(" ************** MBeanAttributeInfo ******************");
77       print(" name="+info.getName());
78       print(" description="+info.getDescription());
79       print(" type="+info.getType());
80       print(" isReadable="+info.isReadable());
81       print(" isWritable="+info.isWritable());
82       print(" isIs="+info.isIs());
83     }
84
85     //*****************************************************************************************
86
private void printInfo(MBeanConstructorInfo info)
87     {
88       print(" ************** MBeanConstructorInfo ******************");
89       print(" name="+info.getName());
90       print(" description="+info.getDescription());
91       printInfo(info.getSignature());
92     }
93
94     //*****************************************************************************************
95
private void printInfo(MBeanNotificationInfo info)
96     {
97       print(" ************** MBeanNotificationInfo ******************");
98       print(" name="+info.getName());
99       print(" description="+info.getDescription());
100       printInfo(info.getNotifTypes());
101     }
102     //*****************************************************************************************
103
private void printInfo(MBeanOperationInfo info)
104     {
105       print(" ************** MBeanOperationInfo ******************");
106       print(" name="+info.getName());
107       print(" description="+info.getDescription());
108       String JavaDoc str = "???";
109       switch(info.getImpact())
110         {
111           case MBeanOperationInfo.UNKNOWN:
112              str = "UNKNOWN";
113              break;
114           case MBeanOperationInfo.ACTION:
115              str = "ACTION";
116              break;
117           case MBeanOperationInfo.INFO:
118              str = "INFO";
119              break;
120           case MBeanOperationInfo.ACTION_INFO:
121              str = "ACTION_INFO";
122              break;
123         }
124       print(" returnType="+info.getReturnType());
125     print(" impact="+str);
126       printInfo(info.getSignature());
127     }
128     //*****************************************************************************************
129
private void printInfo(MBeanParameterInfo info)
130     {
131       print(" ************** MBeanParameterInfo ******************");
132       print(" name="+info.getName());
133       print(" description="+info.getDescription());
134       print(" type="+info.getType());
135     }
136
137
138     //*****************************************************************************************
139
private void printInfo(Object JavaDoc[] infos)
140     {
141       for(int i=0; i<infos.length; i++)
142         if(infos[i] instanceof MBeanAttributeInfo)
143         printInfo((MBeanAttributeInfo)infos[i]);
144         else
145           if(infos[i] instanceof MBeanConstructorInfo)
146             printInfo((MBeanConstructorInfo)infos[i]);
147           else
148             if(infos[i] instanceof MBeanNotificationInfo)
149               printInfo((MBeanNotificationInfo)infos[i]);
150             else
151               if(infos[i] instanceof MBeanOperationInfo)
152                 printInfo((MBeanOperationInfo)infos[i]);
153               else
154               if(infos[i] instanceof MBeanParameterInfo)
155                 printInfo((MBeanParameterInfo)infos[i]);
156               else
157                 print(" "+infos[i]); //notif types?
158
}
159   
160     //*****************************************************************************************
161
private void print(String JavaDoc str)
162   {
163     System.out.println(str);
164   }
165 }
Popular Tags