Java MBean getMBeanAttribute(final MBeanServerConnection connection, final String nameString, final String attributeName)

Here you can find the source of getMBeanAttribute(final MBeanServerConnection connection, final String nameString, final String attributeName)

Description

get M Bean Attribute

License

Apache License

Declaration

public static MBeanAttributeInfo getMBeanAttribute(final MBeanServerConnection connection,
            final String nameString, final String attributeName) 

Method Source Code


//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;
    }
}

Related

  1. getCompatibleData(Object object, MBeanParameterInfo beanParameterInfo)
  2. getDescription(MBeanFeatureInfo element)
  3. getDynamicMBean(String mbeanName)
  4. getJmxNameInternal(final Class mBeanClass, final String name)
  5. getMatchingObjectNames(CharSequence wildcardEq, CharSequence wildcardWc, MBeanServerConnection conn)
  6. getMBeanAttributeMap(MBeanServerConnection server, ObjectName objectName, String delimeter, String... attributeNames)
  7. getMBeanAttributes(final MBeanServer mBeanServer, final String objectNameString)
  8. getMBeanAttributeValue(final MBeanServerConnection connection, final ObjectName objName, final String attributeName)
  9. getMBeanConnections(final Map connectors)