Search in sources :

Example 1 with JmxManaged

use of voldemort.annotations.jmx.JmxManaged in project voldemort by voldemort.

the class JmxUtils method createModelMBean.

/**
     * Create a model mbean from an object using the description given in the
     * Jmx annotation if present. Only operations are supported so far, no
     * attributes, constructors, or notifications
     * 
     * @param o The object to create an MBean for
     * @return The ModelMBean for the given object
     */
public static ModelMBean createModelMBean(Object o) {
    try {
        ModelMBean mbean = new RequiredModelMBean();
        JmxManaged annotation = o.getClass().getAnnotation(JmxManaged.class);
        String description = annotation == null ? "" : annotation.description();
        ModelMBeanInfo info = new ModelMBeanInfoSupport(o.getClass().getName(), description, extractAttributeInfo(o), new ModelMBeanConstructorInfo[0], extractOperationInfo(o), new ModelMBeanNotificationInfo[0]);
        mbean.setModelMBeanInfo(info);
        mbean.setManagedResource(o, "ObjectReference");
        return mbean;
    } catch (MBeanException e) {
        throw new VoldemortException(e);
    } catch (InvalidTargetObjectTypeException e) {
        throw new VoldemortException(e);
    } catch (InstanceNotFoundException e) {
        throw new VoldemortException(e);
    }
}
Also used : RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean) ModelMBean(javax.management.modelmbean.ModelMBean) JmxManaged(voldemort.annotations.jmx.JmxManaged) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanException(javax.management.MBeanException) ModelMBeanInfoSupport(javax.management.modelmbean.ModelMBeanInfoSupport) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) VoldemortException(voldemort.VoldemortException) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean)

Aggregations

InstanceNotFoundException (javax.management.InstanceNotFoundException)1 MBeanException (javax.management.MBeanException)1 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)1 ModelMBean (javax.management.modelmbean.ModelMBean)1 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)1 ModelMBeanInfoSupport (javax.management.modelmbean.ModelMBeanInfoSupport)1 RequiredModelMBean (javax.management.modelmbean.RequiredModelMBean)1 VoldemortException (voldemort.VoldemortException)1 JmxManaged (voldemort.annotations.jmx.JmxManaged)1