org.jruby.embed.util
Class SystemPropertyCatcher

java.lang.Object
  extended by org.jruby.embed.util.SystemPropertyCatcher

public class SystemPropertyCatcher
extends java.lang.Object

Utility methods to retrieve System properties or environment variables to get configuration parameters.

Author:
Yoko Harada

Constructor Summary
SystemPropertyCatcher()
           
 
Method Summary
static java.lang.String findFromJar(java.lang.Object instance)
           
static java.lang.String findJRubyHome(java.lang.Object instance)
          Tries to find JRuby home from the order of JRUBY_HOME environment variable, jruby.home System property, then "/META-INF/jruby.home" if jruby-complete.jar is used.
static java.util.List<java.lang.String> findLoadPaths()
          Tries to find load paths for ruby files and/or libraries.
static java.lang.String getBaseDir()
          Returns a possible base directory.
static LocalVariableBehavior getBehavior(LocalVariableBehavior defaultBehavior)
          Gets a local variable behavior from System property.
static LocalContextScope getScope(LocalContextScope defaultScope)
          Gets a local context scope from System property.
static boolean isLazy(boolean defaultLaziness)
          Gets a local variable behavior from System property.
static boolean isRuby19(java.lang.String name)
          Checks that a given name is an appropriate configuration parameter to choose Ruby 1.9 mode.
static void setClassLoader(ScriptingContainer container)
          Sets classloader based on System property.
static void setConfiguration(ScriptingContainer container)
          Sets configuration parameters given by System properties.
static void setJRubyHome(ScriptingContainer container)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemPropertyCatcher

public SystemPropertyCatcher()
Method Detail

getScope

public static LocalContextScope getScope(LocalContextScope defaultScope)
Gets a local context scope from System property. If no value is assigned to PropertyName.LOCALCONTEXT_SCOPE, given default value is applied.

Parameters:
defaultScope - a default scope.
Returns:
one of three local context scopes.

getBehavior

public static LocalVariableBehavior getBehavior(LocalVariableBehavior defaultBehavior)
Gets a local variable behavior from System property. If no value is assigned to PropertyName.LOCALVARIABLE_BEHAVIOR, given default value is applied.

Parameters:
defaultBehavior - a default local variable behavior
Returns:
a local variable behavior

isLazy

public static boolean isLazy(boolean defaultLaziness)
Gets a local variable behavior from System property. If no value is assigned to PropertyName.LOCALVARIABLE_BEHAVIOR, given default value is applied.

Parameters:
defaultLaziness - a default local variable behavior
Returns:
a local variable behavior

setClassLoader

public static void setClassLoader(ScriptingContainer container)
Sets classloader based on System property. This is only used from JRubyEgnineFactory.

Parameters:
container - ScriptingContainer to be set classloader

setConfiguration

public static void setConfiguration(ScriptingContainer container)
Sets configuration parameters given by System properties. Compile mode and Compat version can be set.

Parameters:
container - ScriptingContainer to be set configurations.

setJRubyHome

@Deprecated
public static void setJRubyHome(ScriptingContainer container)
Deprecated. 

Sets JRuby home if it is given by a JRUBY_HOME environment variable, jruby.home system property, or jury.home in jruby-complete.jar

Parameters:
container - ScriptingContainer to be set jruby home.

findJRubyHome

public static java.lang.String findJRubyHome(java.lang.Object instance)
Tries to find JRuby home from the order of JRUBY_HOME environment variable, jruby.home System property, then "/META-INF/jruby.home" if jruby-complete.jar is used.

Parameters:
instance - any instance to get a resource
Returns:
JRuby home path if exists, null when failed to find it.

findFromJar

public static java.lang.String findFromJar(java.lang.Object instance)

findLoadPaths

public static java.util.List<java.lang.String> findLoadPaths()
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.

Returns:
a list of load paths.

isRuby19

public static boolean isRuby19(java.lang.String name)
Checks that a given name is an appropriate configuration parameter to choose Ruby 1.9 mode.

Parameters:
name - a possible name that expresses Ruby 1.9.
Returns:
true is the given name is correct to choose Ruby 1.9 version. Otherwise, returns false.

getBaseDir

public static java.lang.String getBaseDir()
Returns a possible base directory. PWD environment variables is looked up first, then user.dir System property second. This directory is used as a default value when base directory is not given.

Returns:
a base directory.


Copyright © 2002-2009 JRuby Team. All Rights Reserved.