Class ReflectUtils

java.lang.Object
org.jgroups.jmx.ReflectUtils

public class ReflectUtils extends Object
Methods to get/set attributes and invoke operations of a given instance.
Since:
5.2
  • Constructor Details

    • ReflectUtils

      public ReflectUtils()
  • Method Details

    • handleAttributeAccess

      public static void handleAttributeAccess(Map<String,String> map, String attrs, Object target)
      Handles an attribute read or write
    • dumpSelectedAttributes

      public static Map<String,Map<String,Object>> dumpSelectedAttributes(Object target, List<String> attrs)
      Reads all attributes and values of the given target (annotated with ManagedAttribute and filters them if a non-null list of attributes is given
      Parameters:
      target - The object to read the attributes from
      attrs - A list of attributes to match against. Example:
      bind
      with match
      bind_addr
      ,
      bind_port
      etc. If
      null
      , all attributes will be read.
      Returns:
      A map of attributes and values, keyed by the object's class
    • dumpStats

      public static void dumpStats(Object obj, Map<String,Object> map)
    • listOperations

      public static String listOperations(Class<?> clazz)
      Prints all operations of clazz annotated with ManagedOperation
    • invokeOperation

      public static void invokeOperation(Map<String,String> map, String operation, Object target) throws Exception
      Invokes an operation and puts the return value into map
      Parameters:
      map -
      operation - Protocol.OperationName[args], e.g. STABLE.foo[arg1 arg2 arg3]
      target - The target object on which to invoke the operation
      Throws:
      Exception
    • invoke

      public static Object invoke(Method method, Object target, String[] args) throws Exception
      Throws:
      Exception
    • convert

      protected static void convert(Map<String,Map<String,Object>> in, Map<String,String> out)
    • handleAttrWrite

      public static void handleAttrWrite(Object target, String attr_name, String attr_value) throws Exception
      Throws:
      Exception
    • _handleAttrWrite

      public static void _handleAttrWrite(Object target, String attr_name, String attr_value)
    • methodToString

      protected static String methodToString(Method m)