Search in sources :

Example 1 with JMRuntimeException

use of javax.management.JMRuntimeException in project felix by apache.

the class MX4JMBeanServer method getMBeanInfo.

public MBeanInfo getMBeanInfo(ObjectName objectName) throws InstanceNotFoundException, IntrospectionException, ReflectionException {
    objectName = secureObjectName(objectName);
    MBeanMetaData metadata = findMBeanMetaData(objectName);
    MBeanInfo info = getHeadInterceptor().getMBeanInfo(metadata);
    if (info == null)
        throw new JMRuntimeException("MBeanInfo returned for MBean " + objectName + " is null");
    return info;
}
Also used : MBeanInfo(javax.management.MBeanInfo) JMRuntimeException(javax.management.JMRuntimeException)

Example 2 with JMRuntimeException

use of javax.management.JMRuntimeException in project felix by apache.

the class InvokerMBeanServerInterceptor method getAttributes.

public AttributeList getAttributes(MBeanMetaData metadata, String[] attributes) {
    if (metadata.dynamic) {
        try {
            return ((DynamicMBean) metadata.mbean).getAttributes(attributes);
        } catch (JMRuntimeException x) {
            throw x;
        } catch (RuntimeException x) {
            throw new RuntimeMBeanException(x);
        } catch (Error x) {
            throw new RuntimeErrorException(x);
        }
    } else {
        AttributeList list = new AttributeList();
        for (int i = 0; i < attributes.length; ++i) {
            String name = attributes[i];
            try {
                Object value = getAttribute(metadata, name);
                Attribute attr = new Attribute(name, value);
                list.add(attr);
            } catch (Exception ignored) {
                Logger logger = getLogger();
                if (logger.isEnabledFor(Logger.DEBUG))
                    logger.debug("Exception caught from getAttributes(), ignoring attribute " + name);
            }
        }
        return list;
    }
}
Also used : RuntimeMBeanException(javax.management.RuntimeMBeanException) DynamicMBean(javax.management.DynamicMBean) RuntimeErrorException(javax.management.RuntimeErrorException) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) Logger(org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger) AttributeNotFoundException(javax.management.AttributeNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ReflectionException(javax.management.ReflectionException) JMRuntimeException(javax.management.JMRuntimeException) RuntimeMBeanException(javax.management.RuntimeMBeanException) RuntimeErrorException(javax.management.RuntimeErrorException) ImplementationException(org.apache.felix.mosgi.jmx.agent.mx4j.ImplementationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) ListenerNotFoundException(javax.management.ListenerNotFoundException) JMRuntimeException(javax.management.JMRuntimeException) JMRuntimeException(javax.management.JMRuntimeException)

Example 3 with JMRuntimeException

use of javax.management.JMRuntimeException in project felix by apache.

the class InvokerMBeanServerInterceptor method setAttributes.

public AttributeList setAttributes(MBeanMetaData metadata, AttributeList attributes) {
    if (metadata.dynamic) {
        try {
            return ((DynamicMBean) metadata.mbean).setAttributes(attributes);
        } catch (JMRuntimeException x) {
            throw x;
        } catch (RuntimeException x) {
            throw new RuntimeMBeanException(x);
        } catch (Error x) {
            throw new RuntimeErrorException(x);
        }
    } else {
        AttributeList list = new AttributeList();
        for (int i = 0; i < attributes.size(); ++i) {
            Attribute attr = (Attribute) attributes.get(i);
            try {
                setAttribute(metadata, attr);
                list.add(attr);
            } catch (Exception ignored) {
                Logger logger = getLogger();
                if (logger.isEnabledFor(Logger.DEBUG))
                    logger.debug("Exception caught from setAttributes(), ignoring attribute " + attr, ignored);
            }
        }
        return list;
    }
}
Also used : RuntimeMBeanException(javax.management.RuntimeMBeanException) DynamicMBean(javax.management.DynamicMBean) JMRuntimeException(javax.management.JMRuntimeException) RuntimeErrorException(javax.management.RuntimeErrorException) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) Logger(org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger) JMRuntimeException(javax.management.JMRuntimeException) AttributeNotFoundException(javax.management.AttributeNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ReflectionException(javax.management.ReflectionException) JMRuntimeException(javax.management.JMRuntimeException) RuntimeMBeanException(javax.management.RuntimeMBeanException) RuntimeErrorException(javax.management.RuntimeErrorException) ImplementationException(org.apache.felix.mosgi.jmx.agent.mx4j.ImplementationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) ListenerNotFoundException(javax.management.ListenerNotFoundException)

Example 4 with JMRuntimeException

use of javax.management.JMRuntimeException in project spf4j by zolyfarkas.

the class ExportedValuesMBean method setAttributes.

/**
 * {@inheritDoc}
 */
@Override
public AttributeList setAttributes(final AttributeList list) {
    AttributeList result = new AttributeList(list.size());
    for (Attribute attr : list.asList()) {
        ExportedValue<Object> eval = (ExportedValue<Object>) exportedValues.get(attr.getName());
        if (eval != null) {
            try {
                eval.set(attr.getValue());
                result.add(attr);
            } catch (InvalidAttributeValueException | InvalidObjectException | RuntimeException ex) {
                LOG.warn("Exception while setting attr {}", attr, ex);
                throw new JMRuntimeException("Exception while setting attributes " + list + ", detail:\n" + Throwables.toString(ex));
            }
        }
    }
    return result;
}
Also used : JMRuntimeException(javax.management.JMRuntimeException) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) InvalidObjectException(java.io.InvalidObjectException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) JMRuntimeException(javax.management.JMRuntimeException)

Example 5 with JMRuntimeException

use of javax.management.JMRuntimeException in project spf4j by zolyfarkas.

the class ExportedValuesMBean method getAttributes.

/**
 * {@inheritDoc}
 */
@Override
public AttributeList getAttributes(final String[] names) {
    AttributeList list = new AttributeList(names.length);
    for (String name : names) {
        try {
            ExportedValue<?> attr = exportedValues.get(name);
            if (attr == null) {
                throw new IllegalArgumentException("No attribute with name " + name);
            }
            list.add(new Attribute(name, attr.get()));
        } catch (OpenDataException | RuntimeException ex) {
            LOG.error("Exception getting attribute {}", name, ex);
            throw new JMRuntimeException("Exception while getting attributes " + Arrays.toString(names) + ", detail:\n" + Throwables.toString(ex));
        }
    }
    return list;
}
Also used : JMRuntimeException(javax.management.JMRuntimeException) Attribute(javax.management.Attribute) OpenDataException(javax.management.openmbean.OpenDataException) AttributeList(javax.management.AttributeList) JMRuntimeException(javax.management.JMRuntimeException)

Aggregations

JMRuntimeException (javax.management.JMRuntimeException)14 ObjectName (javax.management.ObjectName)6 Attribute (javax.management.Attribute)4 AttributeList (javax.management.AttributeList)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)4 MBeanInfo (javax.management.MBeanInfo)4 MBeanRegistrationException (javax.management.MBeanRegistrationException)4 RuntimeErrorException (javax.management.RuntimeErrorException)4 AttributeNotFoundException (javax.management.AttributeNotFoundException)3 DynamicMBean (javax.management.DynamicMBean)3 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)3 ListenerNotFoundException (javax.management.ListenerNotFoundException)3 MBeanException (javax.management.MBeanException)3 RuntimeOperationsException (javax.management.RuntimeOperationsException)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 JMException (javax.management.JMException)2 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2