use of javax.management.modelmbean.ModelMBeanInfo in project cxf by apache.
the class ModelMBeanAssemblerTest method testRegisterOperations.
// the client get and set the ModelObject and setup the ManagerBean
@Test
public void testRegisterOperations() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
assertEquals("Incorrect number of operations registered", 10, info.getOperations().length);
}
use of javax.management.modelmbean.ModelMBeanInfo in project cxf by apache.
the class ModelMBeanAssemblerTest method testNotificationMetadata.
@Test
public void testNotificationMetadata() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
MBeanNotificationInfo[] notifications = info.getNotifications();
assertEquals("Incorrect number of notifications", 1, notifications.length);
assertEquals("Incorrect notification name", "My Notification", notifications[0].getName());
String[] notifTypes = notifications[0].getNotifTypes();
assertEquals("Incorrect number of notification types", 2, notifTypes.length);
assertEquals("Notification type.foo not found", "type.foo", notifTypes[0]);
assertEquals("Notification type.bar not found", "type.bar", notifTypes[1]);
}
use of javax.management.modelmbean.ModelMBeanInfo in project cxf by apache.
the class ModelMBeanAssemblerTest method onSetUp.
protected void onSetUp() throws Exception {
try {
ton = new ObjectName("org.apache.cxf:Type=testInstrumentation");
} catch (MalformedObjectNameException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
// create the mbean and register it
ModelMBeanInfo mbi = getMBeanInfoFromAssembler();
RequiredModelMBean rtMBean;
rtMBean = (RequiredModelMBean) server.instantiate("javax.management.modelmbean.RequiredModelMBean");
rtMBean.setModelMBeanInfo(mbi);
rtMBean.setManagedResource(ati, "ObjectReference");
server.registerMBean(rtMBean, ton);
}
use of javax.management.modelmbean.ModelMBeanInfo in project cxf by apache.
the class ModelMBeanAssemblerTest method testGetMBeanOperationInfo.
@Test
public void testGetMBeanOperationInfo() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
MBeanOperationInfo[] inf = info.getOperations();
assertEquals("Invalid number of Operations returned", 10, inf.length);
for (int x = 0; x < inf.length; x++) {
assertNotNull("MBeanOperationInfo should not be null", inf[x]);
assertNotNull("Description for MBeanOperationInfo should not be null", inf[x].getDescription());
}
}
use of javax.management.modelmbean.ModelMBeanInfo 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