private static Map < OperationKey , Method > fetchOpkeyToMethod ( Class < ? > mbeanClass ) { Map < OperationKey , Method > opkeyToMethod = new HashMap <> ( ) ; Method [ ] methods = mbeanClass . getMethods ( ) ; for ( Method method : methods ) { if ( method . isAnnotationPresent ( JmxOperation . class ) ) { JmxOperation annotation = method . getAnnotation ( JmxOperation . class ) ; String opName = annotation . name ( ) ; if ( opName . equals ( "" ) ) { opName = method . getName ( ) ; } Class < ? > [ ] paramTypes = method . getParameterTypes ( ) ; Annotation [ ] [ ] paramAnnotations = method . getParameterAnnotations ( ) ; assert paramAnnotations . length == paramTypes . length ; String [ ] paramTypesNames = new String [ paramTypes . length ] ; for ( int i = 0 ; i < paramTypes . length ; i ++ ) { paramTypesNames [ i ] = paramTypes [ i ] . getName ( ) ; } opkeyToMethod . put ( new OperationKey ( opName , paramTypesNames ) , method ) ; } } return opkeyToMethod ; }
region jmx operations fetching