The Artima Developer Community
Sponsored Link

Java Buzz Forum
Treasure Trove: jmxutils

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
Treasure Trove: jmxutils Posted: Oct 7, 2009 10:02 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: Treasure Trove: jmxutils
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

Gianugo and I used to do a talk at JavaOne called “The Long Tail Treasure Trove.” The goal of the talk was to introduce at least thirty or so small, open source, useful libraries which the majority of attendees had never heard of. They were great talks. We haven’t done one, in a while, so at Henri’s prompting (very belatedly), I’m just going to start blogging them!

So, we’ll start with a great one – Martin’s JMX exporting library, jmxutils. Writing JMX beans tends to be agonizing, so unless someone is holding a blowtorch to you toes, you avoid it. Well, it doesn’t need to be, examine this:

public class Something
{
    private volatile String color;
    
    @Managed(description="Favorite Color")
    public String getColor() {
        return color;
    }

    @Managed
    public void setColor(String color) {
        this.color = color;
    }

    @Managed 
    public void pickOne(String first, String second) {
        this.color = second;
    }
}


MBeanExporter exporter 
    = new MBeanExporter(ManagementFactory.getPlatformMBeanServer());

Something s = new Something();
exporter.export("org.skife.example:name=Something", s);

This little tidbit exports a JMX Bean, building a model mbean by inspecting the annotations. This particular one exports a mutable property (color) and an operation (pickOne). Nicely, it uses Paranamer (subject for another post) to even get the parameter names on the operation right!

Now, to get it into maven central…

Read: Treasure Trove: jmxutils

Topic: Hurco Companies says chief operating officer stepping down Previous Topic   Next Topic Topic: Google giving Web surfers more ways to slice up search results as Microsoft rivalry heats up

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use