jmesnil/jmx4r — pull request #7 by nicobrevin (2013-02-03 23:12:30+00:00)
Title: Allow attributes to be backed by methods, not just plain attr_accessors

Hey there,

So I've tweaked the dynamic mbean class a bit so that you can do things like:

```
class HttpServerMBean < JMX::DynamicMBean

def initialize(http_server)
@http_server = http_server
end

r_attribute :thread_count, :int, 'number of threads'

def thread_count
@http_server.thread_count
end
end
```

It didn't work as it was, because it was fetching values by accessing the instance variable directly, which didn't seem necessary. I could have gone a lot further, you can see the code above code benefit from some ruby meta magic, but this was just enough to get in what I needed. I also made another small change so you can connect via pid, useful when you have a pidfile somewhere, as I often do.

Cheers,
Nick