Beispiel #1
0
 /** List all MBeans and their attributes. */
 public static void listMBeans(MBeanServerConnection server) throws IOException {
   final Set names = server.queryNames(null, null);
   for (final Iterator i = names.iterator(); i.hasNext(); ) {
     ObjectName name = (ObjectName) i.next();
     System.out.println("Got MBean: " + name);
     try {
       MBeanInfo info = server.getMBeanInfo((ObjectName) name);
       MBeanAttributeInfo[] attrs = info.getAttributes();
       if (attrs == null) continue;
       for (int j = 0; j < attrs.length; j++) {
         if (attrs[j].isReadable()) {
           try {
             Object o = server.getAttribute(name, attrs[j].getName());
             System.out.println("\t\t" + attrs[j].getName() + " = " + o);
           } catch (Exception x) {
             System.err.println("JmxClient failed to get " + attrs[j].getName());
             x.printStackTrace(System.err);
           }
         }
       }
     } catch (Exception x) {
       System.err.println("JmxClient failed to get MBeanInfo: " + x);
       x.printStackTrace(System.err);
     }
   }
 }
 private static void checkPlatformMBeans() throws Exception {
   MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
   Set<ObjectName> mbeanNames = mbs.queryNames(null, null);
   for (ObjectName name : mbeanNames) {
     if (!mbs.isInstanceOf(name, NotificationBroadcaster.class.getName())) {
       System.out.println(name + ": not a NotificationBroadcaster");
     } else {
       MBeanInfo mbi = mbs.getMBeanInfo(name);
       check(name.toString(), mbi.getNotifications());
     }
   }
 }
 public ExoticMBeanInfo(MBeanInfo mbi) {
   super(
       mbi.getClassName(),
       mbi.getDescription(),
       mbi.getAttributes(),
       mbi.getConstructors(),
       mbi.getOperations(),
       mbi.getNotifications());
 }