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);
}
}
Aggregations