Wed 19 Dec 2007
Charles, Thomas, Ola — You guys absolutely rock. I am really appreciating the work you have done on JRuby. Thanks also to Sun for supporting this work.
Today I dropped bsf.jar and jruby.jar (1.1b1) into the Emissary P2P Workflow project’s lib directory. I wrote a few dozen lines of java to set up jruby as my ruby scripting language in the framework, create a context to run ruby in. I wrote few more line to hook all of this into our custom high-performance MVC system and now we have a Ruby scripting console served up by Jetty, protected by our normal J2EE security mechanisms. The initial context gets a load of all the important objects inside an emissary node via BSFManager.declareBean. This makes them available as globals in jruby (duh, once you remember to put the “$” in front on the ruby side).
While adding the important object from the Emissary namespace into the JRuby context, some of the object names we were binding things with turned out to be not-so-great for use in Ruby. So here is the little regex that we ended up using to clean up the names and make them nice.
key = key.replaceAll("[-'\"?><{\\\[\\]&$!@#^*()+=]","");
A little css, some MochiKit and how I have an Ajax-enabled JRuby window into running Emissary code served up by our own embedded Jetty. The power this is going to unleash is hard to fathom at the moment but the ideas are coming fast and furious.