uklimaschewski / JMXWrapper

JMXWrapper is a wrapper that allows creation of dynamic JMX MBeans through annotations
Other
41 stars 9 forks source link

Order of attributes and operations #6

Closed TuomasKiviaho closed 10 years ago

TuomasKiviaho commented 10 years ago

Would it be possible to re-order attributes and operation alphabetically. Furthermore @JMXBean could have "attributes" and "operations" arrays where one could define a more specific order by listing each annotated method/property name.

uklimaschewski commented 10 years ago

I'll have a look, looks quite easy.

uklimaschewski commented 10 years ago

I have added support to specify the order of attributes and operations.

Only complex task was to push the changes to the repository - I pushed the wrong repository to this repository and had to push the complete project again. So do not wonder about the strange file histories now.

I Hope you find it useful, I think I found a more elegant way of specifying the sort order instead of specifying arrays:

Sorting the attributes and operations

To sort attributes and operations in a certain way, you have to mark the bean as sorted. By default, attributes and operations will be sorted by their name. You can specify a sortValue for the operations and attributes to override the default value.

      @JMXBean(sorted=true)
      public class MyBean {
          int level = 0;

          @JMXBeanAttribute(nameKey="level", descriptionKey="levelDescription", sortKey="1")
          public int getLevel() {
              return level;
          }

          @JMXBeanOperation(sortValue="2")
          public String methodX(String p1) {
              return p1;
          }
      }