Search in sources :

Example 1 with MXBeanDescription

use of org.apache.ignite.mxbean.MXBeanDescription in project ignite by apache.

the class IgniteStandardMXBean method getDescription.

/**
 * {@inheritDoc}
 */
@Override
protected String getDescription(MBeanOperationInfo info) {
    String str = super.getDescription(info);
    try {
        Method m = getMethod(info);
        MXBeanDescription desc = m.getAnnotation(MXBeanDescription.class);
        if (desc != null) {
            str = desc.value();
            assert str != null;
            assert !str.trim().isEmpty();
            // Enforce proper English.
            assert Character.isUpperCase(str.charAt(0)) : DESC_MUST_START_WITH_UPP_CASE + str;
            assert str.charAt(str.length() - 1) == '.' : DESC_MUST_END_WITH_PERIOD + str;
        }
    } catch (SecurityException | ClassNotFoundException ignored) {
    // No-op. Default value will be returned.
    }
    return str;
}
Also used : MXBeanDescription(org.apache.ignite.mxbean.MXBeanDescription) Method(java.lang.reflect.Method)

Example 2 with MXBeanDescription

use of org.apache.ignite.mxbean.MXBeanDescription in project ignite by apache.

the class IgniteStandardMXBean method getDescription.

/**
 * {@inheritDoc}
 */
@Override
protected String getDescription(MBeanAttributeInfo info) {
    String str = super.getDescription(info);
    String methodName = (info.isIs() ? "is" : "get") + info.getName();
    try {
        // Recursively get method.
        Method mtd = findMethod(getMBeanInterface(), methodName, new Class[] {});
        if (mtd != null) {
            MXBeanDescription desc = mtd.getAnnotation(MXBeanDescription.class);
            if (desc != null) {
                str = desc.value();
                assert str != null : "Failed to find method: " + mtd;
                assert !str.trim().isEmpty() : "Method description cannot be empty: " + mtd;
                // Enforce proper English.
                assert Character.isUpperCase(str.charAt(0)) : DESC_MUST_START_WITH_UPP_CASE + str;
                assert str.charAt(str.length() - 1) == '.' : DESC_MUST_END_WITH_PERIOD + str;
            }
        }
    } catch (SecurityException ignored) {
    // No-op. Default value will be returned.
    }
    return str;
}
Also used : MXBeanDescription(org.apache.ignite.mxbean.MXBeanDescription) Method(java.lang.reflect.Method)

Example 3 with MXBeanDescription

use of org.apache.ignite.mxbean.MXBeanDescription in project ignite by apache.

the class IgniteStandardMXBean method getDescription.

/**
 * {@inheritDoc}
 */
@Override
protected String getDescription(MBeanInfo info) {
    String str = super.getDescription(info);
    // Return either default one or given by annotation.
    MXBeanDescription desc = U.getAnnotation(getMBeanInterface(), MXBeanDescription.class);
    if (desc != null) {
        str = desc.value();
        assert str != null;
        assert !str.trim().isEmpty();
        // Enforce proper English.
        assert Character.isUpperCase(str.charAt(0)) : DESC_MUST_START_WITH_UPP_CASE + str;
        assert str.charAt(str.length() - 1) == '.' : DESC_MUST_END_WITH_PERIOD + str;
    }
    return str;
}
Also used : MXBeanDescription(org.apache.ignite.mxbean.MXBeanDescription)

Aggregations

MXBeanDescription (org.apache.ignite.mxbean.MXBeanDescription)3 Method (java.lang.reflect.Method)2