Package org.jgroups.jmx
Class ResourceDMBean
- java.lang.Object
-
- org.jgroups.jmx.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ResourceDMBean.Accessor
static class
ResourceDMBean.AttributeEntry
static class
ResourceDMBean.FieldAccessor
static class
ResourceDMBean.MethodAccessor
static class
ResourceDMBean.NoopAccessor
-
Field Summary
Fields Modifier and Type Field Description protected javax.management.MBeanAttributeInfo[]
attrInfo
protected java.util.HashMap<java.lang.String,ResourceDMBean.AttributeEntry>
atts
protected java.util.List<java.lang.Object>
components
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 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)
ResourceDMBean(java.lang.Object instance, java.util.function.Predicate<java.lang.reflect.AccessibleObject> filter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
dumpStats(java.lang.Object obj, java.lang.String prefix, java.util.Map<java.lang.String,java.lang.Object> map)
static void
dumpStats(java.lang.Object obj, java.util.Map<java.lang.String,java.lang.Object> map)
protected void
exposeManagedAttribute(java.lang.reflect.Method method, java.lang.Object instance, java.lang.String prefix)
protected void
findFields(java.lang.Object instance, java.util.function.Predicate<java.lang.reflect.AccessibleObject> filter, java.lang.String prefix)
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, java.util.function.Predicate<java.lang.reflect.AccessibleObject> filter, java.lang.String prefix)
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 presentvoid
forAllAttributes(java.util.function.BiConsumer<java.lang.String,ResourceDMBean.AttributeEntry> c)
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)
protected static java.util.concurrent.TimeUnit
getTimeUnit(java.lang.reflect.AccessibleObject ao)
protected static AttributeType
getType(java.lang.reflect.AccessibleObject ao)
java.lang.Object
invoke(java.lang.String name, java.lang.Object[] args, java.lang.String[] sig)
static boolean
isFractional(java.lang.Class<?> cl)
static boolean
isGetMethod(java.lang.reflect.Method method)
static boolean
isIsMethod(java.lang.reflect.Method method)
static boolean
isNumber(java.lang.Class<?> cl)
static boolean
isNumeric(java.lang.Class<?> cl)
static boolean
isSetMethod(java.lang.reflect.Method method)
protected static java.lang.String
prefix(java.lang.String s, java.lang.String prefix)
static java.lang.String
prettyPrint(java.lang.Object val, java.lang.reflect.AccessibleObject a)
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
-
-
-
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
-
components
protected java.util.List<java.lang.Object> components
-
attrInfo
protected final javax.management.MBeanAttributeInfo[] attrInfo
-
opInfo
protected final javax.management.MBeanOperationInfo[] opInfo
-
atts
protected final java.util.HashMap<java.lang.String,ResourceDMBean.AttributeEntry> atts
-
ops
protected final java.util.List<javax.management.MBeanOperationInfo> ops
-
FILTER
protected static final java.util.function.Predicate<java.lang.reflect.AccessibleObject> FILTER
-
-
Method Detail
-
getMBeanInfo
public javax.management.MBeanInfo getMBeanInfo()
- Specified by:
getMBeanInfo
in interfacejavax.management.DynamicMBean
-
forAllAttributes
public void forAllAttributes(java.util.function.BiConsumer<java.lang.String,ResourceDMBean.AttributeEntry> c)
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Specified by:
getAttribute
in interfacejavax.management.DynamicMBean
-
setAttribute
public void setAttribute(javax.management.Attribute attribute)
- Specified by:
setAttribute
in interfacejavax.management.DynamicMBean
-
getAttributes
public javax.management.AttributeList getAttributes(java.lang.String[] names)
- Specified by:
getAttributes
in interfacejavax.management.DynamicMBean
-
setAttributes
public javax.management.AttributeList setAttributes(javax.management.AttributeList list)
- Specified by:
setAttributes
in interfacejavax.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 interfacejavax.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)
-
dumpStats
public static void dumpStats(java.lang.Object obj, java.lang.String prefix, java.util.Map<java.lang.String,java.lang.Object> map)
-
prettyPrint
public static java.lang.String prettyPrint(java.lang.Object val, java.lang.reflect.AccessibleObject a)
-
isNumeric
public static boolean isNumeric(java.lang.Class<?> cl)
-
isFractional
public static boolean isFractional(java.lang.Class<?> cl)
-
isNumber
public static boolean isNumber(java.lang.Class<?> cl)
-
getType
protected static AttributeType getType(java.lang.reflect.AccessibleObject ao)
-
getTimeUnit
protected static java.util.concurrent.TimeUnit getTimeUnit(java.lang.reflect.AccessibleObject ao)
-
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, java.util.function.Predicate<java.lang.reflect.AccessibleObject> filter, java.lang.String prefix)
-
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, java.lang.String prefix)
-
prefix
protected static java.lang.String prefix(java.lang.String s, java.lang.String prefix)
-
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, java.util.function.Predicate<java.lang.reflect.AccessibleObject> filter, java.lang.String prefix)
-
getNamedAttribute
protected javax.management.Attribute getNamedAttribute(java.lang.String name)
-
setNamedAttribute
protected boolean setNamedAttribute(javax.management.Attribute attribute)
-
-