/** * Changes a class loader to a given loader. * Call this method before you use put/get, runScriptlet, and parse methods so that * the given class loader will be used. * * @since JRuby 1.5.0. * * @param loader a new class loader to be set. */ public void setClassLoader(ClassLoader loader) { provider.getRubyInstanceConfig().setLoader(loader); }
/** * Changes a class loader to a given loader. * Call this method before you use put/get, runScriptlet, and parse methods so that * the given class loader will be used. * * @since JRuby 1.5.0. * * @param loader a new class loader to be set. */ public void setClassLoader(ClassLoader loader) { provider.getRubyInstanceConfig().setLoader(loader); }
/** * Changes a class loader to a given loader. * Call this method before you use put/get, runScriptlet, and parse methods so that * the given class loader will be used. * * @since JRuby 1.5.0. * * @param loader a new class loader to be set. */ public void setClassLoader(ClassLoader loader) { provider.getRubyInstanceConfig().setLoader(loader); }
/** * Changes a class loader to a given loader. * Call this method before you use put/get, runScriptlet, and parse methods so that * the given class loader will be used. * * @since JRuby 1.5.0. * * @param loader a new class loader to be set. */ public void setClassLoader(ClassLoader loader) { provider.getRubyInstanceConfig().setLoader(loader); }
JRubyMain(String bundleDisableSharedGems, String currentDirectory, String jrubyHome, RubyInstanceConfig config) { super(config); // TODO have property to disable hard exit - see warbler config.setHardExit(true); config.setCurrentDirectory(currentDirectory + "/"); config.setJRubyHome(jrubyHome); // for jruby 1.7.x add the current directory explicitly to LOAD_PATH config.setLoadPaths(Arrays.asList(currentDirectory + "/")); Map<String, String> env = new HashMap<String, String>(System.getenv()); // we assume the embedded jars are placed in jars directory env.put("JARS_HOME", currentDirectory + "/jars"); // we assume the embedded gems are placed at the root of the "archive" env.put("GEM_PATH", currentDirectory + "/"); // make sure we do not inherit it from outside // NOTE: setting it to GEM_PATH will break the extractingMain cases env.put("GEM_HOME", jrubyHome + "/lib/ruby/gems/shared"); if (bundleDisableSharedGems != null) { // for spawning jruby we need bundler to tell to // NOT clean up the load Path env.put("BUNDLE_DISABLE_SHARED_GEMS", bundleDisableSharedGems); } config.setEnvironment(env); // older jruby-1.7.x does need this config.setLoader(JRubyMain.class.getClassLoader()); }
JRubyMain(String bundleDisableSharedGems, String currentDirectory, String jrubyHome, RubyInstanceConfig config) { super(config); // TODO have property to disable hard exit - see warbler config.setHardExit(true); config.setCurrentDirectory(currentDirectory + "/"); config.setJRubyHome(jrubyHome); // for jruby 1.7.x add the current directory explicitly to LOAD_PATH config.setLoadPaths(Arrays.asList(currentDirectory + "/")); Map<String, String> env = new HashMap<String, String>(System.getenv()); // we assume the embedded jars are placed in jars directory env.put("JARS_HOME", currentDirectory + "/jars"); // we assume the embedded gems are placed at the root of the "archive" env.put("GEM_PATH", currentDirectory + "/"); // make sure we do not inherit it from outside // NOTE: setting it to GEM_PATH will break the extractingMain cases env.put("GEM_HOME", jrubyHome + "/lib/ruby/gems/shared"); if (bundleDisableSharedGems != null) { // for spawning jruby we need bundler to tell to // NOT clean up the load Path env.put("BUNDLE_DISABLE_SHARED_GEMS", bundleDisableSharedGems); } config.setEnvironment(env); // older jruby-1.7.x does need this config.setLoader(JRubyMain.class.getClassLoader()); }
private static JRubyAsciidoctor createJRubyAsciidoctorInstance(Map<String, String> environmentVars, List<String> loadPaths, ClassLoader classloader) { Map<String, String> env = environmentVars != null ? new HashMap<String, String>(environmentVars) : new HashMap<String, String>(); RubyInstanceConfig config = createOptimizedConfiguration(); if (classloader != null) { config.setLoader(classloader); } injectEnvironmentVariables(config, env); Ruby rubyRuntime = JavaEmbedUtils.initialize(loadPaths, config); JRubyAsciidoctor jrubyAsciidoctor = new JRubyAsciidoctor(rubyRuntime); JavaLogger.install(rubyRuntime, jrubyAsciidoctor); return jrubyAsciidoctor; }
private static JRubyAsciidoctor createJRubyAsciidoctorInstance(Map<String, String> environmentVars, List<String> loadPaths, ClassLoader classloader) { Map<String, String> env = environmentVars != null ? new HashMap<String, String>(environmentVars) : new HashMap<String, String>(); RubyInstanceConfig config = createOptimizedConfiguration(); if (classloader != null) { config.setLoader(classloader); } injectEnvironmentVariables(config, env); Ruby rubyRuntime = JavaEmbedUtils.initialize(loadPaths, config); JRubyAsciidoctor jrubyAsciidoctor = new JRubyAsciidoctor(rubyRuntime); JavaLogger.install(rubyRuntime, jrubyAsciidoctor); return jrubyAsciidoctor; }
protected RubyInstanceConfig initRuntimeConfig(final RubyInstanceConfig config) { final RackConfig rackConfig = rackContext.getConfig(); config.setLoader(Thread.currentThread().getContextClassLoader());