I'm thinking of refactoring a somewhat large Java based application. There are some parts of it that should be able to run at a pretty decent speed, so I thought about keeping those in pure Java ... and the rest in JRuby. Do you think it would be worth doing this "refactoring"?
Do you hope to run the code through a scripting interface (such as the JSR223 API)? If so, and your logic changes often, this may be valuable.
Otherwise, I don't think it would be worth it. My experience trying something similar in Scala was that doing a straight-forward port, you end up writing Java code in Ruby (or in your case, Scala). The only reason it might be worth it is if you are trying to take advantage of some feature of JRuby that would make the problem inherently easier, or if you're just practicing your coding skills.
A thing I have had to consider is that mixing languages makes the maintainance burden exponentially bigger since future programmers need to know All the languages involved plus the bridges between Them. If you all have the full skill set, great, otherwise Think twice. Your code Will live longer than you Think
Absolutely! There are already sufficient tools to do this: The org.jruby.embed API which shipped in 1.4, and jruby-rack, an add-on library which allows you to mount Ruby applications as servlets.
I'm playing around with mixed Java and JRuby in my fork of the spring-petclinic app. You can find an example of a jruby-rack configured servlet in there that mounts an embedded Rails application.
You can see an example of the embedding API in the net.caldersphere.webdemos.StartupScriptLauncher class in that project.
Feel free to contact me if you're interested in pushing these kinds of scenarios further.