Search in sources :

Example 1 with JmxParam

use of voldemort.annotations.jmx.JmxParam in project voldemort by voldemort.

the class JmxUtils method extractParameterInfo.

/**
     * Extract the parameters from a method using the Jmx annotation if present,
     * or just the raw types otherwise
     * 
     * @param m The method to extract parameters from
     * @return An array of parameter infos
     */
public static MBeanParameterInfo[] extractParameterInfo(Method m) {
    Class<?>[] types = m.getParameterTypes();
    Annotation[][] annotations = m.getParameterAnnotations();
    MBeanParameterInfo[] params = new MBeanParameterInfo[types.length];
    for (int i = 0; i < params.length; i++) {
        boolean hasAnnotation = false;
        for (int j = 0; j < annotations[i].length; j++) {
            if (annotations[i][j] instanceof JmxParam) {
                JmxParam param = (JmxParam) annotations[i][j];
                params[i] = new MBeanParameterInfo(param.name(), types[i].getName(), param.description());
                hasAnnotation = true;
                break;
            }
        }
        if (!hasAnnotation) {
            params[i] = new MBeanParameterInfo("", types[i].getName(), "");
        }
    }
    return params;
}
Also used : JmxParam(voldemort.annotations.jmx.JmxParam) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Aggregations

MBeanParameterInfo (javax.management.MBeanParameterInfo)1 JmxParam (voldemort.annotations.jmx.JmxParam)1