Saturday, June 9, 2007

Nice Blog on JRuby + JMX

While stumbling around trying to replicate a JXTA Hello world type application in JRuby, I ran across a well-written tutorial by Jeff Mesnil on how to script JMX with JRuby as well a part II.

module JMX
require 'java'

include_class 'java.util.HashMap'
include_package ''
include_package ''
include_package ''

url = "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi"
connector = JMXConnectorFactory::connect url,
mbsc = connector.mbean_server_connection

memory_mbean = ManagementFactory::newPlatformMXBeanProxy mbsc, "java.lang:type=Memory",

memory_mbean.verbose = !memory_mbean.verbose
puts "verbose = #{memory_mbean.verbose}"


No comments: