Class ResourceDMBean

  • All Implemented Interfaces:
    javax.management.DynamicMBean

    public class ResourceDMBean
    extends java.lang.Object
    implements javax.management.DynamicMBean
    A DynamicMBean wrapping an annotated object instance and exposing attributes annotated with @ManagedAttribute and operations annotated with @ManagedOperation.
    Author:
    Chris Mills, Vladimir Blagojevic, Bela Ban
    See Also:
    ManagedAttribute, ManagedOperation, MBean
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.management.MBeanAttributeInfo[] attrInfo  
      protected java.util.HashMap<java.lang.String,​ResourceDMBean.AttributeEntry> atts  
      protected boolean expose_all  
      protected static java.util.function.Predicate<java.lang.reflect.AccessibleObject> FILTER  
      protected Log log  
      protected java.lang.Object obj  
      protected static java.util.List<java.lang.reflect.Method> OBJECT_METHODS  
      protected java.util.List<java.lang.Object> objs  
      protected javax.management.MBeanOperationInfo[] opInfo  
      protected java.util.List<javax.management.MBeanOperationInfo> ops  
      protected static java.lang.Class<?>[] primitives  
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceDMBean​(java.lang.Object instance)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void dumpStats​(java.lang.Object obj, java.util.Map<java.lang.String,​java.lang.Object> map, Log log)  
      protected void exposeManagedAttribute​(java.lang.reflect.Method method, java.lang.Object instance)  
      protected void findFields​(java.lang.Object instance)  
      protected static ResourceDMBean.Accessor findGetter​(java.lang.Object target, java.lang.String attr_name)
      Finds an accessor for an attribute.
      protected void findMethods​(java.lang.Object instance)  
      static ResourceDMBean.Accessor findSetter​(java.lang.Object target, java.lang.String attr_name)
      Finds an accessor for an attribute.
      protected void fixFields​(java.lang.Object instance)
      Provides field-based getter and/or setters for all attributes in attrs if not present
      java.lang.Object getAttribute​(java.lang.String name)  
      javax.management.AttributeList getAttributes​(java.lang.String[] names)  
      protected static java.lang.Class<?> getClassForName​(java.lang.String name)  
      javax.management.MBeanInfo getMBeanInfo()  
      protected javax.management.Attribute getNamedAttribute​(java.lang.String name)  
      java.lang.Object invoke​(java.lang.String name, java.lang.Object[] args, java.lang.String[] sig)  
      static boolean isGetMethod​(java.lang.reflect.Method method)  
      static boolean isIsMethod​(java.lang.reflect.Method method)  
      static boolean isSetMethod​(java.lang.reflect.Method method)  
      void setAttribute​(javax.management.Attribute attribute)  
      javax.management.AttributeList setAttributes​(javax.management.AttributeList list)  
      protected boolean setNamedAttribute​(javax.management.Attribute attribute)  
      protected static java.lang.String toLowerCase​(java.lang.String input)
      Returns a string with the first letter being lowercase
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • primitives

        protected static final java.lang.Class<?>[] primitives
      • OBJECT_METHODS

        protected static final java.util.List<java.lang.reflect.Method> OBJECT_METHODS
      • expose_all

        protected final boolean expose_all
      • log

        protected final Log log
      • obj

        protected final java.lang.Object obj
      • objs

        protected java.util.List<java.lang.Object> objs
      • attrInfo

        protected final javax.management.MBeanAttributeInfo[] attrInfo
      • opInfo

        protected final javax.management.MBeanOperationInfo[] opInfo
      • ops

        protected final java.util.List<javax.management.MBeanOperationInfo> ops
      • FILTER

        protected static final java.util.function.Predicate<java.lang.reflect.AccessibleObject> FILTER
    • Constructor Detail

      • ResourceDMBean

        public ResourceDMBean​(java.lang.Object instance)
    • Method Detail

      • getMBeanInfo

        public javax.management.MBeanInfo getMBeanInfo()
        Specified by:
        getMBeanInfo in interface javax.management.DynamicMBean
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
        Specified by:
        getAttribute in interface javax.management.DynamicMBean
      • setAttribute

        public void setAttribute​(javax.management.Attribute attribute)
        Specified by:
        setAttribute in interface javax.management.DynamicMBean
      • getAttributes

        public javax.management.AttributeList getAttributes​(java.lang.String[] names)
        Specified by:
        getAttributes in interface javax.management.DynamicMBean
      • setAttributes

        public javax.management.AttributeList setAttributes​(javax.management.AttributeList list)
        Specified by:
        setAttributes in interface javax.management.DynamicMBean
      • invoke

        public java.lang.Object invoke​(java.lang.String name,
                                       java.lang.Object[] args,
                                       java.lang.String[] sig)
                                throws javax.management.MBeanException,
                                       javax.management.ReflectionException
        Specified by:
        invoke in interface javax.management.DynamicMBean
        Throws:
        javax.management.MBeanException
        javax.management.ReflectionException
      • isSetMethod

        public static boolean isSetMethod​(java.lang.reflect.Method method)
      • isGetMethod

        public static boolean isGetMethod​(java.lang.reflect.Method method)
      • isIsMethod

        public static boolean isIsMethod​(java.lang.reflect.Method method)
      • dumpStats

        public static void dumpStats​(java.lang.Object obj,
                                     java.util.Map<java.lang.String,​java.lang.Object> map,
                                     Log log)
      • getClassForName

        protected static java.lang.Class<?> getClassForName​(java.lang.String name)
                                                     throws java.lang.ClassNotFoundException
        Throws:
        java.lang.ClassNotFoundException
      • findMethods

        protected void findMethods​(java.lang.Object instance)
      • fixFields

        protected void fixFields​(java.lang.Object instance)
        Provides field-based getter and/or setters for all attributes in attrs if not present
      • exposeManagedAttribute

        protected void exposeManagedAttribute​(java.lang.reflect.Method method,
                                              java.lang.Object instance)
      • findGetter

        protected static ResourceDMBean.Accessor findGetter​(java.lang.Object target,
                                                            java.lang.String attr_name)
        Finds an accessor for an attribute. Tries to find getAttrName(), isAttrName(), attrName() methods. If not found, tries to use reflection to get the value of attr_name. If still not found, creates a NullAccessor.
      • findSetter

        public static ResourceDMBean.Accessor findSetter​(java.lang.Object target,
                                                         java.lang.String attr_name)
        Finds an accessor for an attribute. Tries to find setAttrName(), attrName() methods. If not found, tries to use reflection to set the value of attr_name. If still not found, creates a NullAccessor.
      • toLowerCase

        protected static java.lang.String toLowerCase​(java.lang.String input)
        Returns a string with the first letter being lowercase
      • findFields

        protected void findFields​(java.lang.Object instance)
      • getNamedAttribute

        protected javax.management.Attribute getNamedAttribute​(java.lang.String name)
      • setNamedAttribute

        protected boolean setNamedAttribute​(javax.management.Attribute attribute)