Package wt.jmx.core
Class DynamicMBeanDelegator
java.lang.Object
wt.jmx.core.DynamicMBeanDelegator
DynamicMBeanDelegator provides a number of utilities useful when implementing
DynamicMBean methods and behaviors.
Supported API: true
Extendable: false
Supported API: true
Extendable: false
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetAttribute(Object targetObject, String attributeName, Method readMethod) Utility for implementing DyanmicMBean's getAttribute() method against a target object when the read method is known.static ObjectgetAttribute(Object targetObject, String attributeName, Map<String, Method> attrNameToReadMethodMap, Map<String, Method> attrNameToWriteMethodMap) Same as other getAttribute() method here except this provides a bit more explicit feedback when the target attribute is write-only (e.g.static AttributeListgetAttributes(DynamicMBean delegate, String[] attributeNames) Provides an implementation ofDynamicMBean's getAttributes() method by repeatedly calling getAttribute() on 'delegate'.static StringgetFullSignature(String operationName, String[] argumentTypes) Get full method signature given operation name and argument type strings.static StringgetFullSignature(MBeanOperationInfo operInfo) Get full method signature given MBeanOperationInfo.static voidgetMBeanAttributeInfoFromMethodMaps(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).static MethodLook up method in 'cls' based on method name and argument type strings.static voidgetMethodMapsForBeanProperties(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.static Objectinvoke(Object targetObject, Class targetClass, String operationName, Object[] arguments, String[] argumentTypes) Looks up method in 'targetClass' and invokes it on 'targetObject'.static ObjectInvokes 'operMethod' on 'targetObject'.static voidsetAttribute(Object targetObject, Attribute attribute, Method writeMethod) Utility for implementing DyanmicMBean's setAttribute() method against a target object when the write method is known.static voidsetAttribute(Object targetObject, Attribute attribute, Map<String, Method> attrNameToReadMethodMap, Map<String, Method> attrNameToWriteMethodMap) Same as other setAttribute() method here except this provides a bit more explicit feedback when the target attribute is read-only.static AttributeListsetAttributes(DynamicMBean delegate, AttributeList attributeList) Provides an implementation ofDynamicMBean's setAttributes() method by repeatedly calling setAttribute() on 'delegate'.
-
Method Details
-
getAttributes
Provides an implementation ofDynamicMBean'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
Provides an implementation ofDynamicMBean'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 targetedadditionalAllowablePropertyTypes- 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 methodattrNameToWriteMethodMap- 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 methodattrNameToReadMethodMap- map from attribute names to read methods; treated as read-only by this methodattrNameToWriteMethodMap- 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 -
getAttribute
public static Object getAttribute(Object targetObject, String attributeName, Map<String, Method> attrNameToReadMethodMap, Map<String, throws AttributeNotFoundException, MBeanException, ReflectionExceptionMethod> attrNameToWriteMethodMap) 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 -
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 -
setAttribute
public static void setAttribute(Object targetObject, Attribute attribute, Map<String, Method> attrNameToReadMethodMap, Map<String, throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionExceptionMethod> attrNameToWriteMethodMap) 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 -
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:
MBeanExceptionReflectionException
-
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:
MBeanExceptionReflectionException
-
getMethod
Look up method in 'cls' based on method name and argument type strings.
Supported API: true -
getFullSignature
Get full method signature given MBeanOperationInfo.
Supported API: true -
getFullSignature
Get full method signature given operation name and argument type strings.
Supported API: true
-