/** * Sets classloader based on System property. This is only used from * JRubyEgnineFactory. * * @param container ScriptingContainer to be set classloader */ public static void setClassLoader(ScriptingContainer container) { String s = SafePropertyAccessor.getProperty(PropertyName.CLASSLOADER.toString()); // current should be removed later if (s == null || "container".equals(s) || "current".equals(s)) { // default container.setClassLoader(container.getClass().getClassLoader()); return; } else if ("context".equals(s)) { container.setClassLoader(Thread.currentThread().getContextClassLoader()); return; } else if ("none".equals(s)) { return; } // if incorrect value is set, no classloader will set by ScriptingContainer. // allows RubyInstanceConfig to set whatever preferable }
/** * Sets classloader based on System property. This is only used from * JRubyEgnineFactory. * * @param container ScriptingContainer to be set classloader */ public static void setClassLoader(ScriptingContainer container) { String loader = SafePropertyAccessor.getProperty(PropertyName.CLASSLOADER.toString()); // current should be removed later if (loader == null || "container".equals(loader) || "current".equals(loader)) { // default container.setClassLoader(container.getClass().getClassLoader()); return; } if ("context".equals(loader)) { container.setClassLoader(Thread.currentThread().getContextClassLoader()); return; } if ("none".equals(loader)) { return; } // if incorrect value is set, no classloader will set by ScriptingContainer. // allows RubyInstanceConfig to set whatever preferable }
/** * Sets classloader based on System property. This is only used from * JRubyEgnineFactory. * * @param container ScriptingContainer to be set classloader */ public static void setClassLoader(ScriptingContainer container) { String s = SafePropertyAccessor.getProperty(PropertyName.CLASSLOADER.toString()); // current should be removed later if (s == null || "container".equals(s) || "current".equals(s)) { // default container.setClassLoader(container.getClass().getClassLoader()); return; } else if ("context".equals(s)) { container.setClassLoader(Thread.currentThread().getContextClassLoader()); return; } else if ("none".equals(s)) { return; } // if incorrect value is set, no classloader will set by ScriptingContainer. // allows RubyInstanceConfig to set whatever preferable }
/** * Sets classloader based on System property. This is only used from * JRubyEgnineFactory. * * @param container ScriptingContainer to be set classloader */ public static void setClassLoader(ScriptingContainer container) { String loader = SafePropertyAccessor.getProperty(PropertyName.CLASSLOADER.toString()); // current should be removed later if (loader == null || "container".equals(loader) || "current".equals(loader)) { // default container.setClassLoader(container.getClass().getClassLoader()); return; } if ("context".equals(loader)) { container.setClassLoader(Thread.currentThread().getContextClassLoader()); return; } if ("none".equals(loader)) { return; } // if incorrect value is set, no classloader will set by ScriptingContainer. // allows RubyInstanceConfig to set whatever preferable }
/** * @param scope if null, LocalContextScope.SINGLETHREAD * @param behavior if null, LocalVariableBehavior.TRANSIENT * @return A scripting container where the classloader can find classes * in the osgi creator bundle and where the jruby home is set to point to * the one in the jruby's bundle home folder. */ public OSGiScriptingContainer(Bundle creator, LocalContextScope scope, LocalVariableBehavior behavior) { super(scope, behavior); if (creator != null) { super.setClassLoader(new JRubyOSGiBundleClassLoader(creator)); } else { super.setClassLoader(new JRubyOSGiBundleClassLoader()); } super.setLoadServiceCreator(OSGiLoadService.OSGI_DEFAULT); }
/** * @param scope if null, LocalContextScope.SINGLETHREAD * @param behavior if null, LocalVariableBehavior.TRANSIENT * @return A scripting container where the classloader can find classes * in the osgi creator bundle and where the jruby home is set to point to * the one in the jruby's bundle home folder. */ public OSGiScriptingContainer(Bundle creator, LocalContextScope scope, LocalVariableBehavior behavior) { super(scope, behavior); if (creator != null) { super.setClassLoader(new JRubyOSGiBundleClassLoader(creator)); } else { super.setClassLoader(new JRubyOSGiBundleClassLoader()); } super.setLoadServiceCreator(OSGiLoadService.OSGI_DEFAULT); }
synchronized public static ScriptingContainer createScriptingContainer(boolean withPersistentLocalVars) { ScriptingContainer c = new ScriptingContainer(LocalContextScope.SINGLETHREAD, (withPersistentLocalVars) ? LocalVariableBehavior.PERSISTENT : LocalVariableBehavior.TRANSIENT); c.setCompileMode(CompileMode.JIT); c.setRunRubyInProcess(false); ClassLoader loader = ScriptingContainer.class.getClassLoader(); c.setClassLoader(loader); // does it make sense to include more in the class path? // List<String> paths = new ArrayList<String>(); // paths.add(c.getHomeDirectory()); // paths.add(ScriptingContainer.class.getProtectionDomain().getCodeSource().getLocation().toString()); // c.setLoadPaths(paths); return c; }
/** * @param scope if null, LocalContextScope.SINGLETHREAD * @param behavior if null, LocalVariableBehavior.TRANSIENT * @return A scripting container where the classloader can find classes * in the osgi creator bundle and where the jruby home is set to point to * the one in the jruby's bundle home folder. */ public OSGiScriptingContainer(Bundle creator, LocalContextScope scope, LocalVariableBehavior behavior) { super(scope, behavior); if (creator != null) { super.setClassLoader(new JRubyOSGiBundleClassLoader(creator)); } else { super.setClassLoader(new JRubyOSGiBundleClassLoader()); } super.setLoadServiceCreator(OSGiLoadService.OSGI_DEFAULT); try { super.setHomeDirectory(OSGiFileLocator.getJRubyHomeFolder().getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); } }
/** * @param scope if null, LocalContextScope.SINGLETHREAD * @param behavior if null, LocalVariableBehavior.TRANSIENT * @return A scripting container where the classloader can find classes * in the osgi creator bundle and where the jruby home is set to point to * the one in the jruby's bundle home folder. */ public OSGiScriptingContainer(Bundle creator, LocalContextScope scope, LocalVariableBehavior behavior) { super(scope, behavior); if (creator != null) { super.setClassLoader(new JRubyOSGiBundleClassLoader(creator)); } else { super.setClassLoader(new JRubyOSGiBundleClassLoader()); } super.setLoadServiceCreator(OSGiLoadService.OSGI_DEFAULT); try { super.setHomeDirectory(OSGiFileLocator.getJRubyHomeFolder().getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); } }