JMX MBean/MXBean get accessed by different clients(Ex: JConsole, VisualVM, and etc.,), where it is our responsibility that to explain/descirbe the details of the Bean, it includes
- MBean author, version and etc.,
- Attribute display name, type, minValue, maxValue, defaultValue and recommendedValue and its behaviour
- Operation display name, and its argument details
Java SE 6 has come up integrated way of annotation approach for all types of MBean, where we can specify the additional details, is called Descriptors.
Author.java
package com.example.mxbeans;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.management.DescriptorKey;
@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Author {
@DescriptorKey("Author")
String value();
}
HelloWorldMXBean.java
package com.example.mxbeans;
@Author("Krishna")
public interface HelloWorldMXBean {
@DisplayName("GETTER: Name")
public QueueSample getName();
@DisplayName("OPERATION: clearHelloCount")
public void clearCount();
}
In runtime these metadata/annotation converts in to JAVA object, for most constructors in the classes MBean*Info (MBeanInfo, MBeanAttributeInfo, and so on), a parallel constructor exists with the same parameters plus an additional javax.management.Descriptor parameter. The same is true for OpenMBean*InfoSupport. The MBean*Info and OpenMBean*InfoSupport classes contain a getDescriptor() method.
Read: MBean Descriptors Tutorial
No comments:
Post a Comment