| Message: 89706 |
 |
BY: John Lloyd-Jones (johnlloydjones) DATE: 2009-08-17 20:59 SUBJECT: RE: What needs to happen in config.ru? Well, I think I know why it won't work:
Deep down in the grizzly-ruby.jar, I find this:
public IRubyObject createApplicationObject(Ruby runtime)
{
IRubyObject app = runtime.evalScriptlet(creationString);
runtime.defineReadonlyVariable("$glassfish_app", app);
return runtime.evalScriptlet("Rack::Handler::Grizzly.new($glassfish_app)");
}
Now Rack::Handler::Grizzly is a ruby class class (it's in the same jar) that looks like this:
module Rack
module Handler
class Grizzly
def initialize(rack_app)
@rack_app = rack_app
end
def self.run (rack_app, *args)
@rack_app = rack_app
$grizzly_rack_app = rack_app
#Look at me, I'm a dummy method
end
def self.stop
#I'm another dummy method
end
def self.method_missing (m, *args)
puts "Someone tried to call #{m} on Rack::Handler::Grizzly!"
end
def call(env)
JRuby::Rack::Response.new(@rack_app.call(env))
end
end
end
end
What is really needed would be:
evalScriptlet("Rack::Builder.new($glassfish_app)")
because that puts you in the context of the the rack Builer class. FWIW, this is what jruby-rack has in the corresponding place:
evalScriptlet("load 'jruby/rack/boot/rack.rb'\n" + "Rack::Handler::Servlet.new(Rack::Builder.new {(" + rackup + "\n )}.to_app)");
(of course the Servlet class wrapper wouldn't apply to the glassfish gem).
Interestingly, the source code for the glassfish gem has disappeared from the repository. I had to use a decompiler to get the source. | |