Here you can find the source of getMBeanAttribute(final MBeanServerConnection connection, final String nameString, final String attributeName)
public static MBeanAttributeInfo getMBeanAttribute(final MBeanServerConnection connection, final String nameString, final String attributeName)
//package com.java2s; //License from project: Apache License import java.io.IOException; import javax.management.InstanceNotFoundException; import javax.management.IntrospectionException; import javax.management.MBeanAttributeInfo; import javax.management.MBeanInfo; import javax.management.MBeanServerConnection; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.management.ReflectionException; public class Main { public static MBeanAttributeInfo getMBeanAttribute(final MBeanServerConnection connection, final String nameString, final String attributeName) { MBeanAttributeInfo attribute = null; ObjectName objectName;/*w ww. j a v a 2 s. c om*/ try { objectName = new ObjectName(nameString); MBeanInfo mBeanInfo; mBeanInfo = connection.getMBeanInfo(objectName); final MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes(); for (final MBeanAttributeInfo thisAttribute : attributes) { if (thisAttribute.getName().equals(attributeName)) { attribute = thisAttribute; break; } } } catch (final InstanceNotFoundException e) { e.printStackTrace(); } catch (final IntrospectionException e) { e.printStackTrace(); } catch (final ReflectionException e) { e.printStackTrace(); } catch (final IOException e) { e.printStackTrace(); } catch (final MalformedObjectNameException e) { e.printStackTrace(); } catch (final NullPointerException e) { e.printStackTrace(); } return attribute; } }