/** * 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; } }
/** * 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; } }
/** * 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; } }
/** * 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; }
/** * 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 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 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 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; }
/** * 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; }
/** * 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 }
/** * Tries to find load paths for ruby files and/or libraries. This methods * sees org.jruby.embed.class.path system property first, then java.class.path. * * @return a list of load paths. */ @Deprecated public static List<String> findLoadPaths() { String paths = SafePropertyAccessor.getProperty(PropertyName.CLASSPATH.toString()); List<String> loadPaths = new ArrayList<String>(); if (paths == null) { paths = SafePropertyAccessor.getProperty("java.class.path"); } if (paths == null) return loadPaths; String[] possiblePaths = paths.split(File.pathSeparator); String[] prefixes = {"file", "url"}; for (int i=0; i<possiblePaths.length; i++) { int startIndex = i; for (int j=0; j < prefixes.length; j++) { if (prefixes[j].equals(possiblePaths[i]) && i < possiblePaths.length - 1) { loadPaths.add(possiblePaths[i] + ":" + possiblePaths[++i]); break; } } if (startIndex == i) { loadPaths.add(possiblePaths[i]); } } return loadPaths; }
/** * 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 }