Search in sources :

Example 16 with MBeanNotificationInfo

use of javax.management.MBeanNotificationInfo in project jdk8u_jdk by JetBrains.

the class MBeanIntrospector method getMBeanInfo.

/**
     * Return the MBeanInfo for the given resource, based on the given
     * per-interface data.
     */
final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) {
    MBeanInfo mbi = getClassMBeanInfo(resource.getClass(), perInterface);
    MBeanNotificationInfo[] notifs = findNotifications(resource);
    if (notifs == null || notifs.length == 0)
        return mbi;
    else {
        return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), notifs, mbi.getDescriptor());
    }
}
Also used : MBeanNotificationInfo(javax.management.MBeanNotificationInfo) MBeanInfo(javax.management.MBeanInfo)

Example 17 with MBeanNotificationInfo

use of javax.management.MBeanNotificationInfo in project tomcat by apache.

the class ManagedBean method getMBeanInfo.

/**
     * Create and return a <code>ModelMBeanInfo</code> object that
     * describes this entire managed bean.
     * @return the MBean info
     */
MBeanInfo getMBeanInfo() {
    // Return our cached information (if any)
    mBeanInfoLock.readLock().lock();
    try {
        if (info != null) {
            return info;
        }
    } finally {
        mBeanInfoLock.readLock().unlock();
    }
    mBeanInfoLock.writeLock().lock();
    try {
        if (info == null) {
            // Create subordinate information descriptors as required
            AttributeInfo[] attrs = getAttributes();
            MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[attrs.length];
            for (int i = 0; i < attrs.length; i++) attributes[i] = attrs[i].createAttributeInfo();
            OperationInfo[] opers = getOperations();
            MBeanOperationInfo[] operations = new MBeanOperationInfo[opers.length];
            for (int i = 0; i < opers.length; i++) operations[i] = opers[i].createOperationInfo();
            NotificationInfo[] notifs = getNotifications();
            MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[notifs.length];
            for (int i = 0; i < notifs.length; i++) notifications[i] = notifs[i].createNotificationInfo();
            // Construct and return a new ModelMBeanInfo object
            info = new MBeanInfo(getClassName(), getDescription(), attributes, new MBeanConstructorInfo[] {}, operations, notifications);
        }
        return info;
    } finally {
        mBeanInfoLock.writeLock().unlock();
    }
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanConstructorInfo(javax.management.MBeanConstructorInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo)

Example 18 with MBeanNotificationInfo

use of javax.management.MBeanNotificationInfo in project tomcat by apache.

the class ConnectionPool method getDefaultNotificationInfo.

public static MBeanNotificationInfo[] getDefaultNotificationInfo() {
    String[] types = new String[] { NOTIFY_INIT, NOTIFY_CONNECT, NOTIFY_ABANDON, SLOW_QUERY_NOTIFICATION, FAILED_QUERY_NOTIFICATION, SUSPECT_ABANDONED_NOTIFICATION, POOL_EMPTY, SUSPECT_RETURNED_NOTIFICATION };
    String name = Notification.class.getName();
    String description = "A connection pool error condition was met.";
    MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description);
    return new MBeanNotificationInfo[] { info };
}
Also used : MBeanNotificationInfo(javax.management.MBeanNotificationInfo)

Example 19 with MBeanNotificationInfo

use of javax.management.MBeanNotificationInfo in project jetty.project by eclipse.

the class ObjectMBean method getMBeanInfo.

public MBeanInfo getMBeanInfo() {
    try {
        if (_info == null) {
            // Start with blank lazy lists attributes etc.
            String desc = null;
            List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>();
            List<MBeanConstructorInfo> constructors = new ArrayList<MBeanConstructorInfo>();
            List<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>();
            List<MBeanNotificationInfo> notifications = new ArrayList<MBeanNotificationInfo>();
            // Find list of classes that can influence the mbean
            Class<?> o_class = _managed.getClass();
            List<Class<?>> influences = new ArrayList<Class<?>>();
            // always add MBean itself
            influences.add(this.getClass());
            influences = findInfluences(influences, _managed.getClass());
            if (LOG.isDebugEnabled())
                LOG.debug("Influence Count: {}", influences.size());
            // Process Type Annotations
            ManagedObject primary = o_class.getAnnotation(ManagedObject.class);
            if (primary != null) {
                desc = primary.value();
            } else {
                if (LOG.isDebugEnabled())
                    LOG.debug("No @ManagedObject declared on {}", _managed.getClass());
            }
            // For each influence
            for (int i = 0; i < influences.size(); i++) {
                Class<?> oClass = influences.get(i);
                ManagedObject typeAnnotation = oClass.getAnnotation(ManagedObject.class);
                if (LOG.isDebugEnabled())
                    LOG.debug("Influenced by: " + oClass.getCanonicalName());
                if (typeAnnotation == null) {
                    if (LOG.isDebugEnabled())
                        LOG.debug("Annotations not found for: {}", oClass.getCanonicalName());
                    continue;
                }
                for (Method method : oClass.getDeclaredMethods()) {
                    ManagedAttribute methodAttributeAnnotation = method.getAnnotation(ManagedAttribute.class);
                    if (methodAttributeAnnotation != null) {
                        // TODO sort out how a proper name could get here, its a method name as an attribute at this point.
                        if (LOG.isDebugEnabled())
                            LOG.debug("Attribute Annotation found for: {}", method.getName());
                        MBeanAttributeInfo mai = defineAttribute(method, methodAttributeAnnotation);
                        if (mai != null) {
                            attributes.add(mai);
                        }
                    }
                    ManagedOperation methodOperationAnnotation = method.getAnnotation(ManagedOperation.class);
                    if (methodOperationAnnotation != null) {
                        if (LOG.isDebugEnabled())
                            LOG.debug("Method Annotation found for: {}", method.getName());
                        MBeanOperationInfo oi = defineOperation(method, methodOperationAnnotation);
                        if (oi != null) {
                            operations.add(oi);
                        }
                    }
                }
            }
            _info = new MBeanInfo(o_class.getName(), desc, (MBeanAttributeInfo[]) attributes.toArray(new MBeanAttributeInfo[attributes.size()]), (MBeanConstructorInfo[]) constructors.toArray(new MBeanConstructorInfo[constructors.size()]), (MBeanOperationInfo[]) operations.toArray(new MBeanOperationInfo[operations.size()]), (MBeanNotificationInfo[]) notifications.toArray(new MBeanNotificationInfo[notifications.size()]));
        }
    } catch (RuntimeException e) {
        LOG.warn(e);
        throw e;
    }
    return _info;
}
Also used : MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) ManagedAttribute(org.eclipse.jetty.util.annotation.ManagedAttribute) ManagedOperation(org.eclipse.jetty.util.annotation.ManagedOperation) MBeanConstructorInfo(javax.management.MBeanConstructorInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) ManagedObject(org.eclipse.jetty.util.annotation.ManagedObject)

Example 20 with MBeanNotificationInfo

use of javax.management.MBeanNotificationInfo in project camel by apache.

the class ManagedEventNotifier method getNotificationInfo.

public MBeanNotificationInfo[] getNotificationInfo() {
    // all the class names in the event package
    String[] names = { "CamelContextStartedEvent", "CamelContextStartingEvent", "CamelContextStartupFailureEvent", "CamelContextStopFailureEvent", "CamelContextStoppedEvent", "CamelContextStoppingEvent", "CamelContextSuspendingEvent", "CamelContextSuspendedEvent", "CamelContextResumingEvent", "CamelContextResumedEvent", "CamelContextResumeFailureEvent", "ExchangeCompletedEvent", "ExchangeCreatedEvent", "ExchangeFailedEvent", "ExchangeFailureHandledEvent", "ExchangeRedeliveryEvents", "ExchangeSendingEvent", "ExchangeSentEvent", "RouteStartedEvent", "RouteStoppedEvent", "ServiceStartupFailureEvent", "ServiceStopFailureEvent" };
    List<MBeanNotificationInfo> infos = new ArrayList<MBeanNotificationInfo>();
    for (String name : names) {
        MBeanNotificationInfo info = new MBeanNotificationInfo(new String[] { "org.apache.camel.management.event" }, "org.apache.camel.management.event." + name, "The event " + name + " occurred");
        infos.add(info);
    }
    return infos.toArray(new MBeanNotificationInfo[infos.size()]);
}
Also used : MBeanNotificationInfo(javax.management.MBeanNotificationInfo) ArrayList(java.util.ArrayList)

Aggregations

MBeanNotificationInfo (javax.management.MBeanNotificationInfo)28 MBeanInfo (javax.management.MBeanInfo)10 MBeanOperationInfo (javax.management.MBeanOperationInfo)7 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)6 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)6 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)5 MBeanParameterInfo (javax.management.MBeanParameterInfo)3 OpenMBeanAttributeInfo (javax.management.openmbean.OpenMBeanAttributeInfo)3 OpenMBeanAttributeInfoSupport (javax.management.openmbean.OpenMBeanAttributeInfoSupport)3 OpenMBeanConstructorInfo (javax.management.openmbean.OpenMBeanConstructorInfo)3 OpenMBeanConstructorInfoSupport (javax.management.openmbean.OpenMBeanConstructorInfoSupport)3 OpenMBeanInfoSupport (javax.management.openmbean.OpenMBeanInfoSupport)3 OpenMBeanOperationInfo (javax.management.openmbean.OpenMBeanOperationInfo)3 OpenMBeanOperationInfoSupport (javax.management.openmbean.OpenMBeanOperationInfoSupport)3 OpenMBeanParameterInfo (javax.management.openmbean.OpenMBeanParameterInfo)3 OpenMBeanParameterInfoSupport (javax.management.openmbean.OpenMBeanParameterInfoSupport)3 ArrayList (java.util.ArrayList)2 AttributeChangeNotification (javax.management.AttributeChangeNotification)2 Descriptor (javax.management.Descriptor)2 Notification (javax.management.Notification)2