I got the Ape running on JRuby and wired Jing back in, which is really useful (some of the so-called Service Docs out there are canine fecal matter). I was pretty damn impressed when the now-2400+ lines of Ape code totally just worked in JRuby. Then, I was irritated by the realization that my primitive CGI setup for running the Ape is just not gonna fly if I have to start up a JVM and JRuby for each request. So I thought “this is what servlets are for, right?” and the good news is that It Can Be Done.
Of course, there were those who told me “We’re working on this, just make
the Ape a Rails app and our magic Web Integration will solve the problem!”
“Feh” I said. “Camping?” “Bah.” I cast aspersions at
frameworks near and far, I’m a PORO kinda guy; if you have
Builder::XmlMarkup and a pure heart you’re good to go IMHO.
Templates? Scaffolds? ActiveWhatever? No, use the Web Architecture, Luke!
It turns out that Marcin Mielżyński had already constructed a RubyServlet with some inspiration from Jython’s PyServlet. It didn’t work with 0.9.8, but Marcin was hanging out on #jruby and heard me whining and morphed it then & there, and now it does. It took a whole lot of string and glue and reading source code but now I have it running here on my Mac and I have to say it’s cool to point my browser at some JRuby code and have it refresh like instantly, whether because the output is dynamic or because I went and edited the script.
This is not quite ready for prime time; we need to have a bunch of debates. Should RubyServlet be part of the core JRuby.jar? Should you have to copy all eleven (!) JRuby .jar files into your app server? And, most important and fun, how should you map URIs into JRuby method calls? Oh yeah, and once we’ve finished arguing, a little documentation wouldn’t hurt so you don’t have to plow through Marcin’s Java code to figure out how to connect A to B.
Humorous side-note; I was talking this over with Charles Nutter and he
wondered if Marcin had done anything about the new Java integration in 0.9.8,
and I didn’t even know. Gimme something that claims to be an
HttpServletResponse and I’ll call
getWriter on it
and then I’ll call
println whatever comes back and it all Just
Works. Duck Typing and Java, sittin’ in a tree... we make progress.