Class ToOpenTypeConverter

java.lang.Object
org.jolokia.client.jmxadapter.ToOpenTypeConverter

public class ToOpenTypeConverter extends Object
Attempt to produce openmbean results to emulate a native JMX connection by reverse engineering type information from JSON response from Jolokia and use the appropriate converter to convert to corresponding objects
  • Constructor Details

    • ToOpenTypeConverter

      public ToOpenTypeConverter()
  • Method Details

    • returnOpenTypedValue

      public static Object returnOpenTypedValue(String name, Object rawValue, String typeFromMBeanInfo) throws OpenDataException
      Throws:
      OpenDataException
    • recursivelyBuildOpenType

      public static OpenType<?> recursivelyBuildOpenType(String name, Object rawValue, String typeFromMBeanInfo) throws OpenDataException
      Try to figure out open type, order of preference 1. handle simple objects, respect type introspected from MBeanInfo if any 2. Handle arrays (comes before cached types due to issues specifying multiple return values for all the Threading overloaded methods) 3. Handle hard coded tabular return types (important for visual presentation in certain tools) 4. Use cached type for attribute/item : either hardcoded to please JConsole / JVisualVM or introspected from MBeanInfo 5. Dynamically build structured type from contents (will struggle with null values for unknown entities) 6. Fail
      Throws:
      OpenDataException
    • cacheType

      public static void cacheType(OpenType<?> type, String... names)
      Specify type to use for an attribute, operation or an attribute within the response. Syntax
         cacheType(TYPE, "ObjectName.Operation/Attribute.item(if array).attribute.innerattribute")
       
      Parameters:
      type - type to apply for reverse engineering
      names - One or more items to type according to syntax given above
    • introspectComplexTypeFrom

      public static OpenType<?> introspectComplexTypeFrom(Class<?> klass) throws OpenDataException
      Parameters:
      klass - The Java type
      Returns:
      OpenType deducted from Java type by reflection
      Throws:
      OpenDataException - When the open type is not found