1 23 24 package com.sun.enterprise.admin.server.core.jmx.tester; 25 26 import java.io.*; 27 import javax.management.NotCompliantMBeanException ; 28 import com.sun.enterprise.admin.util.Debug; 29 import com.sun.enterprise.admin.server.core.jmx.MBeanIntrospector; 30 31 public class MBeanIntrospectorTester 32 { 33 public static void main(String [] args) throws Exception 34 { 35 BufferedReader reader = new BufferedReader(new FileReader(args[0])); 36 String str; 37 long begin = System.currentTimeMillis(); 38 while ((str = reader.readLine()) != null) 39 { 40 str = str.trim(); 41 if (isPrimitive(str)) 42 { 43 try 44 { 45 checkPrimitive(str); 46 Debug.println("Test failed : " + str); 47 } 48 catch (NotCompliantMBeanException e) 49 { 50 } 51 } 52 else 53 { 54 try 55 { 56 checkNonPrimitive(str); 57 } 58 catch (NotCompliantMBeanException e) 59 { 60 Debug.println("Not Compliant : " + str); 61 } 62 } 63 } 64 long end = System.currentTimeMillis(); 65 reader.close(); 67 } 68 69 private static boolean isPrimitive(String str) 70 { 71 return (str.equals("int") || 72 str.equals("boolean") || 73 str.equals("short") || 74 str.equals("byte") || 75 str.equals("char") || 76 str.equals("float") || 77 str.equals("long") || 78 str.equals("double")); 79 } 80 81 private static void checkPrimitive(String str) 82 throws NotCompliantMBeanException 83 { 84 Class c = null; 85 if (str.equals("int")) { c = int.class; } 86 else if (str.equals("boolean")) { c = boolean.class; } 87 else if (str.equals("short")) { c = short.class; } 88 else if (str.equals("byte")) { c = byte.class; } 89 else if (str.equals("char")) { c = char.class; } 90 else if (str.equals("float")) { c = float.class; } 91 else if (str.equals("long")) { c = long.class; } 92 else if (str.equals("double")) { c = double.class; } 93 94 new MBeanIntrospector(c); 95 } 96 97 private static void checkNonPrimitive(String str) 98 throws ClassNotFoundException , NotCompliantMBeanException 99 { 100 Class c = Class.forName(str); 101 MBeanIntrospector intr = new MBeanIntrospector(c); 102 String msg = " Type = "; 103 msg += intr.isStandardMBean() ? "isStandard" : 104 intr.isDynamicMBean() ? "isDynamic" : "Don't know"; 105 Debug.println(str + msg); 106 Debug.println("Management interface = " + 107 intr.getMBeanInterfaceClass().getName()); 108 } 109 } | Popular Tags |