Wednesday, December 30, 2009

MBean Descriptors

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.
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; 
public @interface Author { 
    String value(); 

package com.example.mxbeans; 
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 parameter. The same is true for OpenMBean*InfoSupport. The MBean*Info and OpenMBean*InfoSupport classes contain a getDescriptor() method.

Read: MBean Descriptors Tutorial

1 comment:

Javin @ classpath in java said...

Nice article , you have indeed cover the topic with great details. I have also blogged my experience on java How Synchronization works in Java. let me know how do you find it.

Post a Comment

Recent Posts

Unix Commands | List all My Posts


This blog intended to share the knowledge and contribute to JAVA Community such a way that by providing samples and pointing right documents/webpages. We try to give our knowledege level best and no guarantee can be claimed on truth. Copyright and Terms of Policy refer