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 ; }
Extract the parameters from a method using the Jmx annotation if present or just the raw types otherwise