Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6323980

Annotations to simplify MBean development

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 6
    • core-svc
    • b32
    • generic
    • generic
    • Verified

      Today creating a Standard MBean means writing an interface that defines the management interface, and a class that implements that interface. This could be made simpler using annotations.

      In the simplest case, you could eliminate the interface and instead add a @Management annotation to each public method that is part of the management interface.

      @MBean
      public class MyResource {
          @Management
          public int getCacheSize() {...}
          @Management
          public void setCacheSize(int x) {...}
          ...other stuff unrelated to management...
      }

      You could also use annotations to control what the name of the MBean is, for example by saying that its name is derived from the values of the Foo and Bar attributes.

      @MBean(type = "MyResource")
      public class MyResource {
          @MBeanNameKey("foo")
          public String getFoo() {...}
          @MBeanNameKey("bar")
          public int getBar() {...}
      }

      Although there are some tricky implementation questions, it would be great if you could tag a private field as being an attribute:

      public class MyResource {
          @MBeanAttribute("RequestCount")
          private int requestCount;

          public Result request(...) {
              requestCount++;
              ...
          }
      }

            emcmanus Eamonn McManus
            emcmanus Eamonn McManus
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: