/** * Gets a local variable behavior from System property. If no value is assigned to * PropertyName.LOCALVARIABLE_BEHAVIOR, given default value is applied. * * @param defaultLaziness a default local variable behavior * @return a local variable behavior */ public static boolean isLazy(boolean defaultLaziness) { boolean lazy = defaultLaziness; String s = SafePropertyAccessor.getProperty(PropertyName.LAZINESS.toString()); if (s == null) return lazy; return Boolean.parseBoolean(s); }
/** * Gets a local variable behavior from System property. If no value is assigned to * PropertyName.LOCALVARIABLE_BEHAVIOR, given default value is applied. * * @param defaultLaziness a default local variable behavior * @return a local variable behavior */ public static boolean isLazy(boolean defaultLaziness) { boolean lazy = defaultLaziness; String s = SafePropertyAccessor.getProperty(PropertyName.LAZINESS.toString()); if (s == null) return lazy; return Boolean.parseBoolean(s); }
/** * Gets a local context scope from System property. If no value is assigned to * PropertyName.LOCALCONTEXT_SCOPE, given default value is applied. * * @param defaultScope a default scope. * @return one of three local context scopes. */ public static LocalContextScope getScope(LocalContextScope defaultScope) { LocalContextScope scope = defaultScope; String s = SafePropertyAccessor.getProperty(PropertyName.LOCALCONTEXT_SCOPE.toString()); if (s == null) return scope; if ("singlethread".equalsIgnoreCase(s)) return LocalContextScope.SINGLETHREAD; if ("singleton".equalsIgnoreCase(s)) return LocalContextScope.SINGLETON; if ("threadsafe".equalsIgnoreCase(s)) return LocalContextScope.THREADSAFE; if ("concurrent".equalsIgnoreCase(s)) return LocalContextScope.CONCURRENT; return scope; }
/** * Gets a local variable behavior from System property. If no value is assigned to * PropertyName.LOCALVARIABLE_BEHAVIOR, given default value is applied. * * @param defaultBehavior a default local variable behavior * @return a local variable behavior */ public static LocalVariableBehavior getBehavior(LocalVariableBehavior defaultBehavior) { LocalVariableBehavior behavior = defaultBehavior; String s = SafePropertyAccessor.getProperty(PropertyName.LOCALVARIABLE_BEHAVIOR.toString()); if (s == null) return behavior; if ("global".equalsIgnoreCase(s)) return LocalVariableBehavior.GLOBAL; if ("persistent".equalsIgnoreCase(s)) return LocalVariableBehavior.PERSISTENT; if ("transient".equalsIgnoreCase(s)) return LocalVariableBehavior.TRANSIENT; if ("bsf".equalsIgnoreCase(s)) return LocalVariableBehavior.BSF; return behavior; }
/** * Gets a local context scope from System property. If no value is assigned to * PropertyName.LOCALCONTEXT_SCOPE, given default value is applied. * * @param defaultScope a default scope. * @return one of three local context scopes. */ public static LocalContextScope getScope(LocalContextScope defaultScope) { LocalContextScope scope = defaultScope; String s = SafePropertyAccessor.getProperty(PropertyName.LOCALCONTEXT_SCOPE.toString()); if (s == null) return scope; if ("singlethread".equalsIgnoreCase(s)) return LocalContextScope.SINGLETHREAD; if ("singleton".equalsIgnoreCase(s)) return LocalContextScope.SINGLETON; if ("threadsafe".equalsIgnoreCase(s)) return LocalContextScope.THREADSAFE; if ("concurrent".equalsIgnoreCase(s)) return LocalContextScope.CONCURRENT; return scope; }
/** * Returns a fully qualified property name that corresponds to a given * enumerated type identifier. * * @param fqpn fully qualified property name * @return a matched enumerated type identifier */ public static PropertyName getType(String fqpn) { PropertyName[] names = PropertyName.values(); for (int i=0; i<names.length; i++) { if (fqpn.equals(names[i].toString())) { return names[i]; } } return null; } }
/** * Returns a fully qualified property name that corresponds to a given * enumerated type identifier. * * @param fqpn fully qualified property name * @return a matched enumerated type identifier */ public static PropertyName getType(String fqpn) { PropertyName[] names = PropertyName.values(); for (int i=0; i<names.length; i++) { if (fqpn.equals(names[i].toString())) { return names[i]; } } return null; } }
/** * Gets a local variable behavior from System property. If no value is assigned to * PropertyName.LOCALVARIABLE_BEHAVIOR, given default value is applied. * * @param defaultLaziness a default local variable behavior * @return a local variable behavior */ public static boolean isLazy(boolean defaultLaziness) { boolean lazy = defaultLaziness; String s = SafePropertyAccessor.getProperty(PropertyName.LAZINESS.toString()); if (s == null) { return lazy; } return Boolean.parseBoolean(s); }
/** * Gets a local variable behavior from System property. If no value is assigned to * PropertyName.LOCALVARIABLE_BEHAVIOR, given default value is applied. * * @param defaultLaziness a default local variable behavior * @return a local variable behavior */ public static boolean isLazy(boolean defaultLaziness) { boolean lazy = defaultLaziness; String s = SafePropertyAccessor.getProperty(PropertyName.LAZINESS.toString()); if (s == null) { return lazy; } return Boolean.parseBoolean(s); }
/** * Returns a fully qualified property name that corresponds to a given * enumerated type identifier. * * @param fqpn fully qualified property name * @return a matched enumerated type identifier */ public static PropertyName getType(String fqpn) { PropertyName[] names = PropertyName.values(); for (int i=0; i<names.length; i++) { if (fqpn.equals(names[i].toString())) { return names[i]; } } return null; } }
/** * Returns a fully qualified property name that corresponds to a given * enumerated type identifier. * * @param fqpn fully qualified property name * @return a matched enumerated type identifier */ public static PropertyName getType(String fqpn) { PropertyName[] names = PropertyName.values(); for (int i=0; i<names.length; i++) { if (fqpn.equals(names[i].toString())) { return names[i]; } } return null; } }
/** * Gets a local variable behavior from System property. If no value is assigned to * PropertyName.LOCALVARIABLE_BEHAVIOR, given default value is applied. * * @param defaultBehavior a default local variable behavior * @return a local variable behavior */ public static LocalVariableBehavior getBehavior(LocalVariableBehavior defaultBehavior) { LocalVariableBehavior behavior = defaultBehavior; String s = SafePropertyAccessor.getProperty(PropertyName.LOCALVARIABLE_BEHAVIOR.toString()); if (s == null) return behavior; if ("global".equalsIgnoreCase(s)) return LocalVariableBehavior.GLOBAL; if ("persistent".equalsIgnoreCase(s)) return LocalVariableBehavior.PERSISTENT; if ("transient".equalsIgnoreCase(s)) return LocalVariableBehavior.TRANSIENT; if ("bsf".equalsIgnoreCase(s)) return LocalVariableBehavior.BSF; return behavior; }
/** * Gets a local context scope from System property. If no value is assigned to * PropertyName.LOCALCONTEXT_SCOPE, given default value is applied. * * @param defaultScope a default scope. * @return one of three local context scopes. */ public static LocalContextScope getScope(LocalContextScope defaultScope) { LocalContextScope scope = defaultScope; String s = SafePropertyAccessor.getProperty(PropertyName.LOCALCONTEXT_SCOPE.toString()); if (s == null) { return scope; } if ("singlethread".equalsIgnoreCase(s)) { return LocalContextScope.SINGLETHREAD; } else if ("singleton".equalsIgnoreCase(s)) { return LocalContextScope.SINGLETON; } else if ("threadsafe".equalsIgnoreCase(s)) { return LocalContextScope.THREADSAFE; } else if ("concurrent".equalsIgnoreCase(s)) { return LocalContextScope.CONCURRENT; } return scope; }
/** * Gets a local variable behavior from System property. If no value is assigned to * PropertyName.LOCALVARIABLE_BEHAVIOR, given default value is applied. * * @param defaultBehavior a default local variable behavior * @return a local variable behavior */ public static LocalVariableBehavior getBehavior(LocalVariableBehavior defaultBehavior) { LocalVariableBehavior behavior = defaultBehavior; String s = SafePropertyAccessor.getProperty(PropertyName.LOCALVARIABLE_BEHAVIOR.toString()); if (s == null) { return behavior; } if ("global".equalsIgnoreCase(s)) { return LocalVariableBehavior.GLOBAL; } else if ("persistent".equalsIgnoreCase(s)) { return LocalVariableBehavior.PERSISTENT; } else if ("transient".equalsIgnoreCase(s)) { return LocalVariableBehavior.TRANSIENT; } else if ("bsf".equalsIgnoreCase(s)) { return LocalVariableBehavior.BSF; } return behavior; }
/** * Gets a local context scope from System property. If no value is assigned to * PropertyName.LOCALCONTEXT_SCOPE, given default value is applied. * * @param defaultScope a default scope. * @return one of three local context scopes. */ public static LocalContextScope getScope(LocalContextScope defaultScope) { LocalContextScope scope = defaultScope; String s = SafePropertyAccessor.getProperty(PropertyName.LOCALCONTEXT_SCOPE.toString()); if (s == null) { return scope; } if ("singlethread".equalsIgnoreCase(s)) { return LocalContextScope.SINGLETHREAD; } else if ("singleton".equalsIgnoreCase(s)) { return LocalContextScope.SINGLETON; } else if ("threadsafe".equalsIgnoreCase(s)) { return LocalContextScope.THREADSAFE; } else if ("concurrent".equalsIgnoreCase(s)) { return LocalContextScope.CONCURRENT; } return scope; }
/** * 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 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 configuration parameters given by System properties. Compile mode and * Compat version can be set. * * @param container ScriptingContainer to be set configurations. */ public static void setConfiguration(ScriptingContainer container) { LocalContextProvider provider = container.getProvider(); RubyInstanceConfig config = provider.getRubyInstanceConfig(); String s = SafePropertyAccessor.getProperty(PropertyName.COMPILEMODE.toString()); if (s != null) { if ("jit".equalsIgnoreCase(s)) { config.setCompileMode(CompileMode.JIT); } else if ("force".equalsIgnoreCase(s)) { config.setCompileMode(CompileMode.FORCE); } else { config.setCompileMode(CompileMode.OFF); } } s = SafePropertyAccessor.getProperty(PropertyName.COMPATVERSION.toString()); if (s != null) { if (isRuby19(s)) { config.setCompatVersion(CompatVersion.RUBY1_9); } } }
/** * Sets configuration parameters given by System properties. Compile mode and * Compat version can be set. * * @param container ScriptingContainer to be set configurations. */ public static void setConfiguration(ScriptingContainer container) { LocalContextProvider provider = container.getProvider(); RubyInstanceConfig config = provider.getRubyInstanceConfig(); String mode = SafePropertyAccessor.getProperty(PropertyName.COMPILEMODE.toString()); if (mode != null) { if ("jit".equalsIgnoreCase(mode)) { config.setCompileMode(CompileMode.JIT); } else if ("force".equalsIgnoreCase(mode)) { config.setCompileMode(CompileMode.FORCE); } else { config.setCompileMode(CompileMode.OFF); } } // NOTE: no JRuby COMPAT version setting, since it no longer makes sense in 9K ! // String compat = SafePropertyAccessor.getProperty(PropertyName.COMPATVERSION.toString()); }