
and i’ve been workin’ like a dog
Originally uploaded by manyfires
JRuby has proved (to me at least) to be really powerful in prototyping and learning Java APIs. A few weeks ago I started thinking to rewrite one of my old Java programs in JRuby. I wrote that Java program as part of learning Java programming (so it’s not as good as I hoped) and I am no longer interested in maintaining it in Java since I’ve learned JRuby. I also thought that I made it a bit complicated to maintain. So I am hoping to simplify it by rewriting in JRuby and Ruby. It will be a challenge for me since I am still learning Ruby, but I hope I enjoy it.
The program calls various JMX APIs on a JMS server periodically and publishes outputs in XML onto JMS. The JMS server has a JMX Console, but I needed a web application for a consolidated view to monitor a number of JMS servers and clients on them.
It was not difficult at all to rewrite one part of the program, calling JMX APIs in JRuby. However, I thought twice about the data transport. Although it’s possible to use JMS in JRuby, inspired by Joe Gregorio’s RESTful JSON, I have decided to use JSON as data transport format this time. Bearing in mind the further integration with the current infrastructure at work, I have also chosen Jetty as HTTP server. Thanks to Keith who has shared his experience in running Jetty in JRuby. Jetty has JSON libraries built in, which is a bonus.
During the development, I’ve found Eyal’s JSON Viewer handy (even I have to cut & paste JSON data from cURL output) since browsers do not render response which content type is “application./json”, while you can view unformatted JSON with Firebug’s network monitoring. Does anyone know anything like Michael Bolin‘s JSON Inspector?
So far I’ve got the RESTful JSON webservice working for some GET requests. Now I need to think about URIs mapping and implementation of other JMX functions I use. I will post follow-up if I find something worthy to post.
P.S. The photo is nothing to do with this post, but as always I love to attach a wonderful photo (and story, too) I’ve found in Flickr.
Related Posts:


3 comments
Comments feed for this article
July 27, 2007 at 10:11 pm
Raphaël Valyi
Hi Kiyo,
I didn’t heard about the JSON libs you used. But some time ago I found Jester (http://giantrobots.thoughtbot.com/2007/6/11/jester-1-3-jsonic-rest ) and found it really interesting to have Restful JSON working on the top of Ruby on Rails ActiveResources.
Did you look at Jester and do see any pros and cons compared to the method you used? I just thought Jester was out of the box and not only with GET…
Aside from that, I think JRuby is the right way to boost java web apps, have fun.
Raphaël Valyi.
July 29, 2007 at 7:17 pm
kiyo
Hi Raphaël,
Thanks for the pointer. Jester looks very interesting. I might try it out when rewriting the front end part of this program.
July 30, 2007 at 3:40 pm
Vasudev Ram
Interesting post, thanks. Gives me one more idea about how / with what to use REST (JRuby and Jetty) … Cool.
Vasudev Ram
Biz site: http://www.dancingbison.com
Blog: http://jugad.livejournal.com
PDF creation toolkit:
http://www.dancingbison.com/products.html