Search in sources :

Example 1 with ModelMBeanNotificationInfo

use of javax.management.modelmbean.ModelMBeanNotificationInfo in project Activiti by Activiti.

the class MBeanInfoAssembler method extractMbeanNotifications.

private void extractMbeanNotifications(Object managedBean, Set<ModelMBeanNotificationInfo> mBeanNotifications) {
    ManagedNotifications notifications = managedBean.getClass().getAnnotation(ManagedNotifications.class);
    if (notifications != null) {
        for (ManagedNotification notification : notifications.value()) {
            ModelMBeanNotificationInfo info = new ModelMBeanNotificationInfo(notification.notificationTypes(), notification.name(), notification.description());
            mBeanNotifications.add(info);
            LOG.trace("Assembled notification: {}", info);
        }
    }
}
Also used : ModelMBeanNotificationInfo(javax.management.modelmbean.ModelMBeanNotificationInfo) ManagedNotifications(org.activiti.management.jmx.annotations.ManagedNotifications) ManagedNotification(org.activiti.management.jmx.annotations.ManagedNotification)

Example 2 with ModelMBeanNotificationInfo

use of javax.management.modelmbean.ModelMBeanNotificationInfo in project Activiti by Activiti.

the class MBeanInfoAssembler method getMBeanInfo.

public ModelMBeanInfo getMBeanInfo(Object defaultManagedBean, Object customManagedBean, String objectName) throws JMException {
    if ((defaultManagedBean == null && customManagedBean == null) || objectName == null)
        return null;
    // skip proxy classes
    if (defaultManagedBean != null && Proxy.isProxyClass(defaultManagedBean.getClass())) {
        LOG.trace("Skip creating ModelMBeanInfo due proxy class {}", defaultManagedBean.getClass());
        return null;
    }
    // maps and lists to contain information about attributes and operations
    Map<String, ManagedAttributeInfo> attributes = new LinkedHashMap<String, ManagedAttributeInfo>();
    Set<ManagedOperationInfo> operations = new LinkedHashSet<ManagedOperationInfo>();
    Set<ModelMBeanAttributeInfo> mBeanAttributes = new LinkedHashSet<ModelMBeanAttributeInfo>();
    Set<ModelMBeanOperationInfo> mBeanOperations = new LinkedHashSet<ModelMBeanOperationInfo>();
    Set<ModelMBeanNotificationInfo> mBeanNotifications = new LinkedHashSet<ModelMBeanNotificationInfo>();
    // extract details from default managed bean
    if (defaultManagedBean != null) {
        extractAttributesAndOperations(defaultManagedBean.getClass(), attributes, operations);
        extractMbeanAttributes(defaultManagedBean, attributes, mBeanAttributes, mBeanOperations);
        extractMbeanOperations(defaultManagedBean, operations, mBeanOperations);
        extractMbeanNotifications(defaultManagedBean, mBeanNotifications);
    }
    // extract details from custom managed bean
    if (customManagedBean != null) {
        extractAttributesAndOperations(customManagedBean.getClass(), attributes, operations);
        extractMbeanAttributes(customManagedBean, attributes, mBeanAttributes, mBeanOperations);
        extractMbeanOperations(customManagedBean, operations, mBeanOperations);
        extractMbeanNotifications(customManagedBean, mBeanNotifications);
    }
    // create the ModelMBeanInfo
    String name = getName(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
    String description = getDescription(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
    ModelMBeanAttributeInfo[] arrayAttributes = mBeanAttributes.toArray(new ModelMBeanAttributeInfo[mBeanAttributes.size()]);
    ModelMBeanOperationInfo[] arrayOperations = mBeanOperations.toArray(new ModelMBeanOperationInfo[mBeanOperations.size()]);
    ModelMBeanNotificationInfo[] arrayNotifications = mBeanNotifications.toArray(new ModelMBeanNotificationInfo[mBeanNotifications.size()]);
    ModelMBeanInfo info = new ModelMBeanInfoSupport(name, description, arrayAttributes, null, arrayOperations, arrayNotifications);
    LOG.trace("Created ModelMBeanInfo {}", info);
    return info;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ModelMBeanOperationInfo(javax.management.modelmbean.ModelMBeanOperationInfo) ModelMBeanNotificationInfo(javax.management.modelmbean.ModelMBeanNotificationInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) LinkedHashMap(java.util.LinkedHashMap) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) ModelMBeanInfoSupport(javax.management.modelmbean.ModelMBeanInfoSupport)

Example 3 with ModelMBeanNotificationInfo

use of javax.management.modelmbean.ModelMBeanNotificationInfo in project spring-framework by spring-projects.

the class AbstractConfigurableMBeanInfoAssembler method setNotificationInfos.

public void setNotificationInfos(ManagedNotification[] notificationInfos) {
    ModelMBeanNotificationInfo[] infos = new ModelMBeanNotificationInfo[notificationInfos.length];
    for (int i = 0; i < notificationInfos.length; i++) {
        ManagedNotification notificationInfo = notificationInfos[i];
        infos[i] = JmxMetadataUtils.convertToModelMBeanNotificationInfo(notificationInfo);
    }
    this.notificationInfos = infos;
}
Also used : ModelMBeanNotificationInfo(javax.management.modelmbean.ModelMBeanNotificationInfo) ManagedNotification(org.springframework.jmx.export.metadata.ManagedNotification)

Example 4 with ModelMBeanNotificationInfo

use of javax.management.modelmbean.ModelMBeanNotificationInfo in project camel by apache.

the class MBeanInfoAssembler method getMBeanInfo.

/**
     * Gets the {@link ModelMBeanInfo} for the given managed bean
     *
     * @param defaultManagedBean  the default managed bean
     * @param customManagedBean   an optional custom managed bean
     * @param objectName   the object name
     * @return the model info, or <tt>null</tt> if not possible to create, for example due the managed bean is a proxy class
     * @throws JMException is thrown if error creating the model info
     */
public ModelMBeanInfo getMBeanInfo(Object defaultManagedBean, Object customManagedBean, String objectName) throws JMException {
    // skip proxy classes
    if (defaultManagedBean != null && Proxy.isProxyClass(defaultManagedBean.getClass())) {
        LOG.trace("Skip creating ModelMBeanInfo due proxy class {}", defaultManagedBean.getClass());
        return null;
    }
    // maps and lists to contain information about attributes and operations
    Map<String, ManagedAttributeInfo> attributes = new LinkedHashMap<String, ManagedAttributeInfo>();
    Set<ManagedOperationInfo> operations = new LinkedHashSet<ManagedOperationInfo>();
    Set<ModelMBeanAttributeInfo> mBeanAttributes = new LinkedHashSet<ModelMBeanAttributeInfo>();
    Set<ModelMBeanOperationInfo> mBeanOperations = new LinkedHashSet<ModelMBeanOperationInfo>();
    Set<ModelMBeanNotificationInfo> mBeanNotifications = new LinkedHashSet<ModelMBeanNotificationInfo>();
    // extract details from default managed bean
    if (defaultManagedBean != null) {
        extractAttributesAndOperations(defaultManagedBean.getClass(), attributes, operations);
        extractMbeanAttributes(defaultManagedBean, attributes, mBeanAttributes, mBeanOperations);
        extractMbeanOperations(defaultManagedBean, operations, mBeanOperations);
        extractMbeanNotifications(defaultManagedBean, mBeanNotifications);
    }
    // extract details from custom managed bean
    if (customManagedBean != null) {
        extractAttributesAndOperations(customManagedBean.getClass(), attributes, operations);
        extractMbeanAttributes(customManagedBean, attributes, mBeanAttributes, mBeanOperations);
        extractMbeanOperations(customManagedBean, operations, mBeanOperations);
        extractMbeanNotifications(customManagedBean, mBeanNotifications);
    }
    // create the ModelMBeanInfo
    String name = getName(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
    String description = getDescription(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
    ModelMBeanAttributeInfo[] arrayAttributes = mBeanAttributes.toArray(new ModelMBeanAttributeInfo[mBeanAttributes.size()]);
    ModelMBeanOperationInfo[] arrayOperations = mBeanOperations.toArray(new ModelMBeanOperationInfo[mBeanOperations.size()]);
    ModelMBeanNotificationInfo[] arrayNotifications = mBeanNotifications.toArray(new ModelMBeanNotificationInfo[mBeanNotifications.size()]);
    ModelMBeanInfo info = new ModelMBeanInfoSupport(name, description, arrayAttributes, null, arrayOperations, arrayNotifications);
    LOG.trace("Created ModelMBeanInfo {}", info);
    return info;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ModelMBeanOperationInfo(javax.management.modelmbean.ModelMBeanOperationInfo) ModelMBeanNotificationInfo(javax.management.modelmbean.ModelMBeanNotificationInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) LinkedHashMap(java.util.LinkedHashMap) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) ModelMBeanInfoSupport(javax.management.modelmbean.ModelMBeanInfoSupport)

Example 5 with ModelMBeanNotificationInfo

use of javax.management.modelmbean.ModelMBeanNotificationInfo in project camel by apache.

the class MBeanInfoAssembler method extractMbeanNotifications.

private void extractMbeanNotifications(Object managedBean, Set<ModelMBeanNotificationInfo> mBeanNotifications) {
    ManagedNotifications notifications = managedBean.getClass().getAnnotation(ManagedNotifications.class);
    if (notifications != null) {
        for (ManagedNotification notification : notifications.value()) {
            ModelMBeanNotificationInfo info = new ModelMBeanNotificationInfo(notification.notificationTypes(), notification.name(), notification.description());
            mBeanNotifications.add(info);
            LOG.trace("Assembled notification: {}", info);
        }
    }
}
Also used : ModelMBeanNotificationInfo(javax.management.modelmbean.ModelMBeanNotificationInfo) ManagedNotifications(org.apache.camel.api.management.ManagedNotifications) ManagedNotification(org.apache.camel.api.management.ManagedNotification)

Aggregations

ModelMBeanNotificationInfo (javax.management.modelmbean.ModelMBeanNotificationInfo)7 ModelMBeanAttributeInfo (javax.management.modelmbean.ModelMBeanAttributeInfo)3 ModelMBeanInfoSupport (javax.management.modelmbean.ModelMBeanInfoSupport)3 ModelMBeanOperationInfo (javax.management.modelmbean.ModelMBeanOperationInfo)3 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)2 ManagedNotification (org.springframework.jmx.export.metadata.ManagedNotification)2 Descriptor (javax.management.Descriptor)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)1 MBeanInfo (javax.management.MBeanInfo)1 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)1 MBeanOperationInfo (javax.management.MBeanOperationInfo)1 MBeanParameterInfo (javax.management.MBeanParameterInfo)1 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)1 ModelMBeanConstructorInfo (javax.management.modelmbean.ModelMBeanConstructorInfo)1 OpenMBeanAttributeInfo (javax.management.openmbean.OpenMBeanAttributeInfo)1 OpenMBeanAttributeInfoSupport (javax.management.openmbean.OpenMBeanAttributeInfoSupport)1 OpenMBeanConstructorInfo (javax.management.openmbean.OpenMBeanConstructorInfo)1