Java MBean getMBeanAttributeValue(final MBeanServerConnection connection, final ObjectName objName, final String attributeName)

Here you can find the source of getMBeanAttributeValue(final MBeanServerConnection connection, final ObjectName objName, final String attributeName)

Description

get M Bean Attribute Value

License

Apache License

Declaration

public static Object getMBeanAttributeValue(final MBeanServerConnection connection, final ObjectName objName,
            final String attributeName) 

Method Source Code


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

Related

  1. getJmxNameInternal(final Class mBeanClass, final String name)
  2. getMatchingObjectNames(CharSequence wildcardEq, CharSequence wildcardWc, MBeanServerConnection conn)
  3. getMBeanAttribute(final MBeanServerConnection connection, final String nameString, final String attributeName)
  4. getMBeanAttributeMap(MBeanServerConnection server, ObjectName objectName, String delimeter, String... attributeNames)
  5. getMBeanAttributes(final MBeanServer mBeanServer, final String objectNameString)
  6. getMBeanConnections(final Map connectors)
  7. getMBeanName(final String serviceName, final String nameName)
  8. getMbeans( final MBeanServerConnection mBeanServerConnection)
  9. getMBeanServer()