Search in sources :

Example 6 with Logger

use of org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger 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 7 with Logger

use of org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger 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 8 with Logger

use of org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger in project felix by apache.

the class MBeanIntrospector method getDynamicMBeanInfo.

private MBeanInfo getDynamicMBeanInfo(MBeanMetaData metadata) {
    Logger logger = getLogger();
    MBeanInfo info = null;
    try {
        info = ((DynamicMBean) metadata.mbean).getMBeanInfo();
    } catch (Exception x) {
        if (logger.isEnabledFor(Logger.DEBUG))
            logger.debug("getMBeanInfo threw: " + x.toString());
    }
    if (logger.isEnabledFor(Logger.TRACE))
        logger.trace("Dynamic MBeanInfo is: " + info);
    if (info == null) {
        if (logger.isEnabledFor(Logger.DEBUG))
            logger.debug("MBeanInfo cannot be null");
        return null;
    }
    return info;
}
Also used : MBeanInfo(javax.management.MBeanInfo) Logger(org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger)

Aggregations

Logger (org.apache.felix.mosgi.jmx.agent.mx4j.log.Logger)8 AttributeNotFoundException (javax.management.AttributeNotFoundException)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)4 JMRuntimeException (javax.management.JMRuntimeException)4 ListenerNotFoundException (javax.management.ListenerNotFoundException)4 MBeanException (javax.management.MBeanException)4 MBeanRegistrationException (javax.management.MBeanRegistrationException)4 ReflectionException (javax.management.ReflectionException)4 RuntimeErrorException (javax.management.RuntimeErrorException)4 ImplementationException (org.apache.felix.mosgi.jmx.agent.mx4j.ImplementationException)4 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 PrivilegedAction (java.security.PrivilegedAction)2 PrivilegedActionException (java.security.PrivilegedActionException)2 Attribute (javax.management.Attribute)2 AttributeList (javax.management.AttributeList)2 BadAttributeValueExpException (javax.management.BadAttributeValueExpException)2 BadBinaryOpValueExpException (javax.management.BadBinaryOpValueExpException)2 BadStringOperationException (javax.management.BadStringOperationException)2 DynamicMBean (javax.management.DynamicMBean)2