Here you can find the source of getMBeanAttributeValue(final MBeanServerConnection connection, final ObjectName objName, final String attributeName)
public static Object getMBeanAttributeValue(final MBeanServerConnection connection, final ObjectName objName, final String attributeName)
//package com.java2s; //License from project: Apache License import java.io.IOException; import javax.management.AttributeNotFoundException; import javax.management.InstanceNotFoundException; import javax.management.MBeanException; import javax.management.MBeanServerConnection; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.management.ReflectionException; public class Main { public static Object getMBeanAttributeValue(final MBeanServerConnection connection, final ObjectName objName, final String attributeName) { Object attributeValue = "Unavailable"; try {/*from w ww . j av a 2 s .c o m*/ attributeValue = connection.getAttribute(objName, attributeName); } catch (final AttributeNotFoundException e) { // e.printStackTrace(); } catch (final MBeanException e) { // e.printStackTrace(); } catch (final InstanceNotFoundException e) { // e.printStackTrace(); } catch (final ReflectionException e) { // e.printStackTrace(); } catch (final IOException e) { // e.printStackTrace(); } catch (final NullPointerException e) { // e.printStackTrace(); } catch (final Exception e) { // e.printStackTrace(); } return attributeValue; } public static Object getMBeanAttributeValue(final MBeanServerConnection connection, final String nameString, final String attributeName) { Object attributeValue = null; ObjectName objName; try { objName = new ObjectName(nameString); attributeValue = getMBeanAttributeValue(connection, objName, attributeName); } catch (final MalformedObjectNameException e) { e.printStackTrace(); } catch (final NullPointerException e) { e.printStackTrace(); } return attributeValue; } }