If I’ve got a the jruby rack filter running and I want to another
servlet to grab access to the shared runtime and run some things, what’s
the best way to go about that?
Currently I’m doing:
RackApplicationFactory raf = (RackApplicationFactory)
servletContext.getAttribute(RackServletContextListener.FACTORY_KEY);
RackApplication app = raf.getApplication();
RubyRuntimeAdapter evaler = JavaEmbedUtils.newRuntimeAdapter();
evaler.eval(app.getRuntime(), code);
Which works fine, but it doesn’t line up at all with the Redbridge way
of doing things - I’m guessing that this is just because jruby-rack was
written before Redbridge was finalized? Or am I better off using these
low level methods without having a ScriptingContainer wrapping
everything?
If jruby-rack was written from scratch today, would it still use
JavaEmbedUtils directly to get a runtime object, or would the newRuntime
method in the application factory actually be a newScriptingContext
method? (and that a singleton localcontext would be appropriate?)
I’m asking because I’m playing around with mirah and dubious for an
appengine project and looking at having some parts written in ruby, but
I don’t need to be loading rack or a rack framework - so my end goal
will be dumping jruby-rack and only loading a ruby runtime if/when
needed (and then, only requiring the bare minimum of libraries).