Here you can find the source of getMBeanAttributes(final MBeanServer mBeanServer, final String objectNameString)
@SuppressWarnings("unchecked") public static Map<String, MBeanAttributeInfo[]> getMBeanAttributes(final MBeanServer mBeanServer, final String objectNameString)
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.util.Map; import java.util.Set; import java.util.TreeMap; import javax.management.InstanceNotFoundException; import javax.management.IntrospectionException; import javax.management.MBeanAttributeInfo; import javax.management.MBeanInfo; import javax.management.MBeanServer; import javax.management.MBeanServerConnection; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.management.ReflectionException; public class Main { @SuppressWarnings("unchecked") public static Map<String, MBeanAttributeInfo[]> getMBeanAttributes(final MBeanServer mBeanServer, final String objectNameString) { Map<String, MBeanAttributeInfo[]> attributesMap = null; Set<ObjectName> objectNames; try {/*from w w w .j a v a2s. com*/ objectNames = mBeanServer.queryNames(new ObjectName(objectNameString), null); attributesMap = new TreeMap<>(); for (final ObjectName objectName : objectNames) { MBeanInfo mBeanInfo; mBeanInfo = mBeanServer.getMBeanInfo(objectName); final MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes(); attributesMap.put(objectName.getCanonicalName(), attributes); } } catch (final InstanceNotFoundException e) { e.printStackTrace(); } catch (final IntrospectionException e) { e.printStackTrace(); } catch (final ReflectionException e) { e.printStackTrace(); } catch (final MalformedObjectNameException e) { e.printStackTrace(); } catch (final NullPointerException e) { e.printStackTrace(); } return attributesMap; } @SuppressWarnings("unchecked") public static Map<String, MBeanAttributeInfo[]> getMBeanAttributes(final MBeanServerConnection connection, final String objectNameString) { Map<String, MBeanAttributeInfo[]> attributesMap = null; Set<ObjectName> objectNames; try { objectNames = connection.queryNames(new ObjectName(objectNameString), null); attributesMap = new TreeMap<>(); for (final ObjectName objectName : objectNames) { MBeanInfo mBeanInfo; mBeanInfo = connection.getMBeanInfo(objectName); final MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes(); attributesMap.put(objectName.getCanonicalName(), attributes); } } catch (final InstanceNotFoundException e) { e.printStackTrace(); } catch (final IntrospectionException e) { e.printStackTrace(); } catch (final ReflectionException e) { e.printStackTrace(); } catch (final MalformedObjectNameException e) { e.printStackTrace(); } catch (final NullPointerException e) { e.printStackTrace(); } catch (final IOException e) { e.printStackTrace(); } return attributesMap; } }