Search in sources :

Example 61 with AttributeNotFoundException

use of javax.management.AttributeNotFoundException in project Payara by payara.

the class MBeanAttributeReadHandler method getValueObject.

@Override
public JsonValue getValueObject() throws JsonException {
    try {
        Object attribute = delegate.getMBeanAttribute(mbeanname, attributename);
        if (attribute == null) {
            return JsonValue.NULL;
        }
        TypeProcessor<?> processor = ProcessorFactory.getTypeProcessor(attribute);
        return processor.processObject(attribute);
    } catch (InstanceNotFoundException | ReflectionException | MalformedObjectNameException | MBeanException | AttributeNotFoundException ex) {
        super.setStatus(Response.Status.NOT_FOUND);
        return getTraceObject(ex);
    }
}
Also used : ReflectionException(javax.management.ReflectionException) MalformedObjectNameException(javax.management.MalformedObjectNameException) AttributeNotFoundException(javax.management.AttributeNotFoundException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanException(javax.management.MBeanException) JsonObject(javax.json.JsonObject)

Example 62 with AttributeNotFoundException

use of javax.management.AttributeNotFoundException in project ignite by apache.

the class ReadOnlyDynamicMBean method getAttributes.

/**
 * {@inheritDoc}
 */
@Override
public AttributeList getAttributes(String[] attributes) {
    AttributeList list = new AttributeList();
    try {
        for (String attribute : attributes) {
            Object val = getAttribute(attribute);
            list.add(val);
        }
        return list;
    } catch (MBeanException | ReflectionException | AttributeNotFoundException e) {
        throw new IgniteException(e);
    }
}
Also used : ReflectionException(javax.management.ReflectionException) AttributeNotFoundException(javax.management.AttributeNotFoundException) AttributeList(javax.management.AttributeList) IgniteException(org.apache.ignite.IgniteException) MBeanException(javax.management.MBeanException)

Example 63 with AttributeNotFoundException

use of javax.management.AttributeNotFoundException in project Payara by payara.

the class AbstractDynamicMBeanImpl method setAttributes.

public final AttributeList setAttributes(AttributeList attributes) {
    AttributeList r = new AttributeList(attributes.size());
    for (Object a : attributes) {
        try {
            setAttribute(Attribute.class.cast(a));
            r.add(Attribute.class.cast(a));
        } catch (AttributeNotFoundException e) {
        // error is silently ignored
        } catch (ReflectionException e) {
        // error is silently ignored
        } catch (MBeanException e) {
        // error is silently ignored
        } catch (InvalidAttributeValueException e) {
        // error is silently ignored
        }
    }
    return r;
}
Also used : ReflectionException(javax.management.ReflectionException) AttributeNotFoundException(javax.management.AttributeNotFoundException) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) MBeanException(javax.management.MBeanException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException)

Example 64 with AttributeNotFoundException

use of javax.management.AttributeNotFoundException in project infrautils by opendaylight.

the class MBeanUtils method readMBeanAttribute.

@Nullable
public static Object readMBeanAttribute(String objName, String attribute) {
    @Var Object attributeObj = null;
    try {
        ObjectName objectName = new ObjectName(objName);
        MBeanServer platformMbeanServer = ManagementFactory.getPlatformMBeanServer();
        attributeObj = platformMbeanServer.getAttribute(objectName, attribute);
    } catch (AttributeNotFoundException | InstanceNotFoundException | MBeanException | ReflectionException | MalformedObjectNameException t) {
        LOG.info("CRITICAL : Exception in executing MXBean function");
    }
    return attributeObj;
}
Also used : ReflectionException(javax.management.ReflectionException) AttributeNotFoundException(javax.management.AttributeNotFoundException) MalformedObjectNameException(javax.management.MalformedObjectNameException) Var(com.google.errorprone.annotations.Var) InstanceNotFoundException(javax.management.InstanceNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) UnicastRemoteObject(java.rmi.server.UnicastRemoteObject) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer) Nullable(javax.annotation.Nullable)

Example 65 with AttributeNotFoundException

use of javax.management.AttributeNotFoundException in project infrautils by opendaylight.

the class AbstractMXBean method readMBeanAttribute.

/**
 * Read an mbean attribute from the platform MBean server.
 *
 * @return Object if successfully executed, "" otherwise.
 */
public Object readMBeanAttribute(String attribute) {
    @Var Object attributeObj = "";
    try {
        ObjectName objectName = this.getMBeanObjectName();
        MBeanServer platformMbeanServer = ManagementFactory.getPlatformMBeanServer();
        attributeObj = platformMbeanServer.getAttribute(objectName, attribute);
    } catch (AttributeNotFoundException | InstanceNotFoundException | MBeanException | ReflectionException | MalformedObjectNameException e) {
        LOG.info("Failed when reading MBean attribute", e);
    }
    return attributeObj;
}
Also used : ReflectionException(javax.management.ReflectionException) AttributeNotFoundException(javax.management.AttributeNotFoundException) MalformedObjectNameException(javax.management.MalformedObjectNameException) Var(com.google.errorprone.annotations.Var) InstanceNotFoundException(javax.management.InstanceNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Aggregations

AttributeNotFoundException (javax.management.AttributeNotFoundException)77 ReflectionException (javax.management.ReflectionException)57 MBeanException (javax.management.MBeanException)54 InstanceNotFoundException (javax.management.InstanceNotFoundException)40 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)30 Attribute (javax.management.Attribute)26 ObjectName (javax.management.ObjectName)24 RuntimeOperationsException (javax.management.RuntimeOperationsException)16 IntrospectionException (javax.management.IntrospectionException)13 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)13 AttributeList (javax.management.AttributeList)12 MalformedObjectNameException (javax.management.MalformedObjectNameException)11 Method (java.lang.reflect.Method)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 Test (org.testng.annotations.Test)9 MBeanInfo (javax.management.MBeanInfo)8 ListenerNotFoundException (javax.management.ListenerNotFoundException)7 RuntimeErrorException (javax.management.RuntimeErrorException)7 RuntimeMBeanException (javax.management.RuntimeMBeanException)7 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)7