Package wt.jmx.core

Class DynamicMBeanDelegator

java.lang.Object
wt.jmx.core.DynamicMBeanDelegator

public final class DynamicMBeanDelegator extends Object
DynamicMBeanDelegator provides a number of utilities useful when implementing DynamicMBean methods and behaviors.

Supported API: true

Extendable: false
  • Method Details

    • getAttributes

      public static AttributeList getAttributes(DynamicMBean delegate, String[] attributeNames)
      Provides an implementation of DynamicMBean's getAttributes() method by repeatedly calling getAttribute() on 'delegate'.

      This saves DynamicMBean implementors from implementing this method themselves if they cannot achieve any further savings by treating multiple attributes at once (e.g. handling all of them in on network trip).

      Supported API: true

    • setAttributes

      public static AttributeList setAttributes(DynamicMBean delegate, AttributeList attributeList)
      Provides an implementation of DynamicMBean's setAttributes() method by repeatedly calling setAttribute() on 'delegate'.

      This saves DynamicMBean implementors from implementing this method themselves if they cannot achieve any further savings by treating multiple attributes at once (e.g. handling all of them in on network trip).

      Supported API: true

    • getMethodMapsForBeanProperties

      public static void getMethodMapsForBeanProperties(Class targetClass, Collection<Class> additionalAllowablePropertyTypes, Map<String,Method> attrNameToReadMethodMap, Map<String,Method> attrNameToWriteMethodMap)
      Given a target class, populates maps from attribute names to read and write methods for these attribute names based on the target class' properties as per Java Beans reflection. Note that the first letter of returned attribute name is capitalized per JMX attribute convention, whereas bean property names normally start with a lowercase letter.

      Supported API: true
      Parameters:
      targetClass - class being targeted
      additionalAllowablePropertyTypes - additional property types to include beyond MBean open types (which are normally the only properties considered)
      attrNameToReadMethodMap - map from attribute names to read methods; to be populated by this method
      attrNameToWriteMethodMap - map from attribute names to write methods; to be populated by this method
    • getMBeanAttributeInfoFromMethodMaps

      public static void getMBeanAttributeInfoFromMethodMaps(Map<String,MBeanAttributeInfo> attrNameToInfoMap, Map<String,Method> attrNameToReadMethodMap, Map<String,Method> attrNameToWriteMethodMap)
      Populates a map from attribute names to MBeanAttributeInfo objects based on input maps from attribute names to read and write methods (which are treated as read-only).

      Supported API: true
      Parameters:
      attrNameToInfoMap - map from attribute names to MBeanAttributeInfo objects; to be populated by this method
      attrNameToReadMethodMap - map from attribute names to read methods; treated as read-only by this method
      attrNameToWriteMethodMap - map from attribute names to write methods; treated as read-only by this method
    • getAttribute

      public static Object getAttribute(Object targetObject, String attributeName, Method readMethod) throws AttributeNotFoundException, MBeanException, ReflectionException
      Utility for implementing DyanmicMBean's getAttribute() method against a target object when the read method is known. Produces appropriate exceptions for various error cases.

      Supported API: true
      Throws:
      AttributeNotFoundException
      MBeanException
      ReflectionException
    • getAttribute

      public static Object getAttribute(Object targetObject, String attributeName, Map<String,Method> attrNameToReadMethodMap, Map<String,Method> attrNameToWriteMethodMap) throws AttributeNotFoundException, MBeanException, ReflectionException
      Same as other getAttribute() method here except this provides a bit more explicit feedback when the target attribute is write-only (e.g. a password field). This comes at the expense of assuming that the caller has string to method maps and also at some minor performance overhead (one extra null check and one extra method call).

      Supported API: true
      Throws:
      AttributeNotFoundException
      MBeanException
      ReflectionException
    • setAttribute

      public static void setAttribute(Object targetObject, Attribute attribute, Method writeMethod) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
      Utility for implementing DyanmicMBean's setAttribute() method against a target object when the write method is known. Produces appropriate exceptions for various error cases.

      Supported API: true
      Throws:
      AttributeNotFoundException
      InvalidAttributeValueException
      MBeanException
      ReflectionException
    • setAttribute

      public static void setAttribute(Object targetObject, Attribute attribute, Map<String,Method> attrNameToReadMethodMap, Map<String,Method> attrNameToWriteMethodMap) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
      Same as other setAttribute() method here except this provides a bit more explicit feedback when the target attribute is read-only. This comes at the expense of assuming that the caller has string to method maps and also at some minor performance overhead (one extra null check and one extra method call).

      Supported API: true
      Throws:
      AttributeNotFoundException
      InvalidAttributeValueException
      MBeanException
      ReflectionException
    • invoke

      public static Object invoke(Object targetObject, Class targetClass, String operationName, Object[] arguments, String[] argumentTypes) throws MBeanException, ReflectionException
      Looks up method in 'targetClass' and invokes it on 'targetObject'.

      Supported API: true
      Throws:
      MBeanException
      ReflectionException
    • invoke

      public static Object invoke(Object targetObject, Method operMethod, String operationName, Object[] arguments) throws MBeanException, ReflectionException
      Invokes 'operMethod' on 'targetObject'. Produces appropriate exceptions for various error cases.

      Supported API: true
      Throws:
      MBeanException
      ReflectionException
    • getMethod

      public static Method getMethod(Class cls, String operationName, String[] argumentTypes)
      Look up method in 'cls' based on method name and argument type strings.

      Supported API: true
    • getFullSignature

      public static String getFullSignature(MBeanOperationInfo operInfo)
      Get full method signature given MBeanOperationInfo.

      Supported API: true
    • getFullSignature

      public static String getFullSignature(String operationName, String[] argumentTypes)
      Get full method signature given operation name and argument type strings.

      Supported API: true