Search in sources :

Example 1 with NotificationSenderAware

use of org.activiti.management.jmx.annotations.NotificationSenderAware in project Activiti by Activiti.

the class DefaultManagementMBeanAssembler method assemble.

public ModelMBean assemble(Object obj, ObjectName name) throws JMException {
    ModelMBeanInfo mbi = null;
    // use the default provided mbean which has been annotated with JMX
    // annotations
    LOG.trace("Assembling MBeanInfo for: {} from @ManagedResource object: {}", name, obj);
    mbi = assembler.getMBeanInfo(obj, null, name.toString());
    if (mbi == null) {
        return null;
    }
    RequiredModelMBean mbean = new RequiredModelMBean(mbi);
    try {
        mbean.setManagedResource(obj, "ObjectReference");
    } catch (InvalidTargetObjectTypeException e) {
        throw new JMException(e.getMessage());
    }
    // Allows the managed object to send notifications
    if (obj instanceof NotificationSenderAware) {
        ((NotificationSenderAware) obj).setNotificationSender(new NotificationSenderAdapter(mbean));
    }
    return mbean;
}
Also used : JMException(javax.management.JMException) NotificationSenderAware(org.activiti.management.jmx.annotations.NotificationSenderAware) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean)

Example 2 with NotificationSenderAware

use of org.activiti.management.jmx.annotations.NotificationSenderAware in project Activiti by Activiti.

the class DefaultManagementMBeanAssemblerTest method testNotificationAware.

@Test
public void testNotificationAware() throws MalformedObjectNameException, JMException {
    NotificationSenderAware mockedNotificationAwareMbean = mock(NotificationSenderAware.class);
    ModelMBean modelBean = defaultManagementMBeanAssembler.assemble(mockedNotificationAwareMbean, new ObjectName("org.activiti.jmx.Mbeans:type=something"));
    assertNotNull(modelBean);
    ArgumentCaptor<NotificationSender> argument = ArgumentCaptor.forClass(NotificationSender.class);
    verify(mockedNotificationAwareMbean).setNotificationSender(argument.capture());
    assertNotNull(argument);
    assertNotNull(argument.getValue());
}
Also used : ModelMBean(javax.management.modelmbean.ModelMBean) NotificationSenderAware(org.activiti.management.jmx.annotations.NotificationSenderAware) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

NotificationSenderAware (org.activiti.management.jmx.annotations.NotificationSenderAware)2 JMException (javax.management.JMException)1 ObjectName (javax.management.ObjectName)1 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)1 ModelMBean (javax.management.modelmbean.ModelMBean)1 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)1 RequiredModelMBean (javax.management.modelmbean.RequiredModelMBean)1 Test (org.junit.Test)1