Search in sources :

Example 36 with ModelMBeanInfo

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);
}
Also used : ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) Test(org.junit.Test)

Example 37 with ModelMBeanInfo

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]);
}
Also used : MBeanNotificationInfo(javax.management.MBeanNotificationInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) Test(org.junit.Test)

Example 38 with ModelMBeanInfo

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);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) ObjectName(javax.management.ObjectName) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean)

Example 39 with ModelMBeanInfo

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());
    }
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) ModelMBeanOperationInfo(javax.management.modelmbean.ModelMBeanOperationInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) Test(org.junit.Test)

Example 40 with ModelMBeanInfo

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

ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)74 Test (org.junit.Test)51 ModelMBeanAttributeInfo (javax.management.modelmbean.ModelMBeanAttributeInfo)33 Descriptor (javax.management.Descriptor)16 ModelMBeanOperationInfo (javax.management.modelmbean.ModelMBeanOperationInfo)14 RequiredModelMBean (javax.management.modelmbean.RequiredModelMBean)11 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)10 ObjectName (javax.management.ObjectName)9 ModelMBeanInfoSupport (javax.management.modelmbean.ModelMBeanInfoSupport)9 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)8 MBeanException (javax.management.MBeanException)6 InstanceNotFoundException (javax.management.InstanceNotFoundException)5 MBeanServer (javax.management.MBeanServer)5 MalformedObjectNameException (javax.management.MalformedObjectNameException)5 RuntimeOperationsException (javax.management.RuntimeOperationsException)5 FileLogger (mx4j.log.FileLogger)5 Logger (mx4j.log.Logger)5 MBeanLogger (mx4j.log.MBeanLogger)5 JMException (javax.management.JMException)4 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)4