Created
March 19, 2011 16:45
-
-
Save calavera/877596 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From dc95ec82769ad1fe26210acc71b5f3cc70484824 Mon Sep 17 00:00:00 2001 | |
From: David Calavera <[email protected]> | |
Date: Sat, 19 Mar 2011 09:45:05 -0700 | |
Subject: [PATCH] use scripting container to initialize the runtime | |
--- | |
.../jruby/rack/DefaultRackApplicationFactory.java | 24 ++++++++++++++++++- | |
1 files changed, 22 insertions(+), 2 deletions(-) | |
diff --git a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java | |
index 84a44a1..add0e9d 100644 | |
--- a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java | |
+++ b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java | |
@@ -10,6 +10,8 @@ package org.jruby.rack; | |
import org.jruby.Ruby; | |
import org.jruby.RubyInstanceConfig; | |
import org.jruby.exceptions.RaiseException; | |
+import org.jruby.embed.ScriptingContainer; | |
+import org.jruby.embed.LocalContextScope; | |
import org.jruby.javasupport.JavaEmbedUtils; | |
import org.jruby.runtime.ThreadContext; | |
import org.jruby.runtime.builtin.IRubyObject; | |
@@ -81,8 +83,9 @@ public class DefaultRackApplicationFactory implements RackApplicationFactory { | |
Ruby runtime = (Ruby) rackContext.getAttribute("jruby.runtime"); | |
if (runtime == null) { | |
setupJRubyManagement(); | |
- RubyInstanceConfig config = createRuntimeConfig(); | |
- runtime = JavaEmbedUtils.initialize(config.loadPaths(), config); | |
+ ScriptingContainer container = newContainer(); | |
+ | |
+ runtime = container.getProvider().getRuntime(); | |
} | |
if (rackContext.getConfig().isIgnoreEnvironment()) { | |
runtime.evalScriptlet("ENV.clear"); | |
@@ -197,6 +200,23 @@ public class DefaultRackApplicationFactory implements RackApplicationFactory { | |
IRubyObject create(Ruby runtime); | |
} | |
+ private ScriptingContainer newContainer() { | |
+ RubyInstanceConfig config = createRuntimeConfig(); | |
+ | |
+ ScriptingContainer container = new ScriptingContainer(LocalContextScope.SINGLETHREAD); | |
+ | |
+ container.setClassLoader(Thread.currentThread().getContextClassLoader()); | |
+ container.setHomeDirectory(config.getJRubyHome()); | |
+ container.setEnvironment(config.getEnvironment()); | |
+ container.setLoadPaths(config.loadPaths()); | |
+ | |
+ if (rackContext.getConfig().getCompatVersion() != null) { | |
+ container.setCompatVersion(config.getCompatVersion()); | |
+ } | |
+ | |
+ return container; | |
+ } | |
+ | |
private RackApplication createApplication(final ApplicationObjectFactory appfact) | |
throws RackInitializationException { | |
try { | |
-- | |
1.7.4.1 | |
(END) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment