org.jruby.embed
Interface EmbedRubyInstanceConfigAdapter

All Known Implementing Classes:
OSGiScriptingContainer, ScriptingContainer

public interface EmbedRubyInstanceConfigAdapter

This interface defines methods to configure Ruby runtime for embedding.

Since:
JRuby 1.5.0
Author:
Yoko Harada

Method Summary
 java.lang.String[] getArgv()
          Returns an arguments' list.
 ClassCache getClassCache()
          Returns a ClassCache object that is tied to a class loader.
 java.lang.ClassLoader getClassLoader()
          Returns a class loader object that is currently used.
 CompatVersion getCompatVersion()
          Returns a Ruby version currently chosen, which is one of CompatVersion.RUBY1_8, CompatVersion.RUBY1_9, or CompatVersion.BOTH.
 RubyInstanceConfig.CompileMode getCompileMode()
          Returns a compile mode currently chosen, which is one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF.
 java.lang.String getCurrentDirectory()
          Returns a current directory.
 java.util.Map getEnvironment()
          Returns a map of environment variables.
 java.io.PrintStream getError()
          Returns an error stream assigned to STDERR and $stderr.
 java.lang.String getHomeDirectory()
          Returns a JRuby home directory.
 java.io.InputStream getInput()
          Returns an input stream assigned to STDIN and $stdin.
 int getJitLogEvery()
          Returns the value of n, which means that jitted methods are logged in every n methods.
 int getJitMax()
          Returns a value of a max class cache size.
 int getJitMaxSize()
          Returns a value of a max size of the bytecode generated by compiler.
 int getJitThreshold()
          Returns a value of the threshold that determines whether jitted methods' call reached to the limit or not.
 KCode getKCode()
          Returns a value of KCode currently used.
 java.util.List<java.lang.String> getLoadPaths()
          Returns a list of load paths for Ruby scripts/libraries.
 RubyInstanceConfig.LoadServiceCreator getLoadServiceCreator()
          Returns a LoadServiceCreator currently used.
 java.io.PrintStream getOutput()
          Returns an output stream assigned to STDOUT and $stdout
 Profile getProfile()
          Returns a profiler currently used.
 java.lang.String getRecordSeparator()
          Returns a record separator.
 java.lang.String getScriptFilename()
          Returns a script filename to run.
 java.lang.String getSupportedRubyVersion()
          Returns version information about JRuby and Ruby supported by this platform.
 boolean isObjectSpaceEnabled()
          Tests whether the Object Space is enabled or not.
 boolean isRunRubyInProcess()
          Tests whether Ruby runs in a process or not.
 void setArgv(java.lang.String[] argv)
          Changes values of the arguments' list.
 void setClassCache(ClassCache cache)
          Changes a ClassCache object to a given one.
 void setClassLoader(java.lang.ClassLoader loader)
          Changes a class loader to a given loader.
 void setCompatVersion(CompatVersion version)
          Changes a Ruby version to be evaluated into one of CompatVersion.RUBY1_8, CompatVersion.RUBY1_9, or CompatVersion.BOTH.
 void setCompileMode(RubyInstanceConfig.CompileMode mode)
          Changes a compile mode to a given mode, which should be one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF.
 void setCurrentDirectory(java.lang.String directory)
          Changes a current directory to a given directory.
 void setEnvironment(java.util.Map environment)
          Changes an environment variables' map.
 void setError(java.io.PrintStream pstream)
          Changes STDERR and $stderr to a gievn print stream.
 void setError(java.io.Writer writer)
          Changes STDERR and $stderr to a given writer.
 void setHomeDirectory(java.lang.String home)
          Changes a JRuby home directroy to a directory of a given name.
 void setInput(java.io.InputStream istream)
          Changes STDIN and $stdin to a given input stream.
 void setInput(java.io.Reader reader)
          Changes STDIN and $stdin to a given reader.
 void setJitLogEvery(int logEvery)
          Changes a value of n, so that jitted methods are logged in every n methods.
 void setJitMax(int max)
          Changes a value of a max class cache size.
 void setJitMaxSize(int maxSize)
          Changes a value of a max size of the bytecode generated by compiler.
 void setJitThreshold(int threshold)
          Changes a value of the threshold that determines whether jitted methods' call reached to the limit or not.
 void setKCode(KCode kcode)
          Changes a value of KCode to a given value.
 void setLoadPaths(java.util.List<java.lang.String> paths)
          Changes a list of load paths Ruby scripts/libraries.
 void setLoadServiceCreator(RubyInstanceConfig.LoadServiceCreator creator)
          Changes a LoadServiceCreator to a given one.
 void setObjectSpaceEnabled(boolean enable)
          Changes the value to determine whether the Object Space is enabled or not.
 void setOutput(java.io.PrintStream pstream)
          Changes STDOUT and $stdout to a given output stream.
 void setOutput(java.io.Writer writer)
          Changes STDOUT and $stdout to a given writer.
 void setProfile(Profile profile)
          Changes a profiler to a given one.
 void setRecordSeparator(java.lang.String separator)
          Changes a record separator to a given value.
 void setRunRubyInProcess(boolean inprocess)
          Changes the value to determine whether Ruby runs in a process or not.
 void setScriptFilename(java.lang.String filename)
          Changes a script filename to run.
 

Method Detail

getLoadPaths

java.util.List<java.lang.String> getLoadPaths()
Returns a list of load paths for Ruby scripts/libraries. If no paths is given, the list is created from java.class.path System property.

Returns:
a list of load paths.

setLoadPaths

void setLoadPaths(java.util.List<java.lang.String> paths)
Changes a list of load paths Ruby scripts/libraries. The default value is an empty array. If no paths is given, the list is created from java.class.path System property. This value can be set by org.jruby.embed.class.path System property.

Parameters:
paths - a new list of load paths.

getInput

java.io.InputStream getInput()
Returns an input stream assigned to STDIN and $stdin.

Returns:
input stream of STDIN and $stdin

setInput

void setInput(java.io.InputStream istream)
Changes STDIN and $stdin to a given input stream. The default standard input is java.lang.System.in.

Parameters:
istream - an input stream to be set

setInput

void setInput(java.io.Reader reader)
Changes STDIN and $stdin to a given reader. No reader is set by default.

Parameters:
reader - a reader to be set

getOutput

java.io.PrintStream getOutput()
Returns an output stream assigned to STDOUT and $stdout

Returns:
an output stream of STDOUT and $stdout

setOutput

void setOutput(java.io.PrintStream pstream)
Changes STDOUT and $stdout to a given output stream. The default standard output is java.lang.System.out.

Parameters:
pstream - an output stream to be set

setOutput

void setOutput(java.io.Writer writer)
Changes STDOUT and $stdout to a given writer. No writer is set by default.

Parameters:
writer - a writer to be set

getError

java.io.PrintStream getError()
Returns an error stream assigned to STDERR and $stderr.

Returns:
output stream for error stream

setError

void setError(java.io.PrintStream pstream)
Changes STDERR and $stderr to a gievn print stream. The default standard error is java.lang.System.err.

Parameters:
pstream - a print stream to be set

setError

void setError(java.io.Writer writer)
Changes STDERR and $stderr to a given writer. No writer is set by default.

Parameters:
writer - a writer to be set

getCompileMode

RubyInstanceConfig.CompileMode getCompileMode()
Returns a compile mode currently chosen, which is one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF. The default mode is CompileMode.OFF.

Returns:
a compile mode.

setCompileMode

void setCompileMode(RubyInstanceConfig.CompileMode mode)
Changes a compile mode to a given mode, which should be one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF. The default value is CompileMode.OFF.

Parameters:
mode - compile mode

isRunRubyInProcess

boolean isRunRubyInProcess()
Tests whether Ruby runs in a process or not.

Returns:
true if Ruby is configured to run in a process, otherwise, false.

setRunRubyInProcess

void setRunRubyInProcess(boolean inprocess)
Changes the value to determine whether Ruby runs in a process or not. The default value is true.

Parameters:
inprocess - true when Ruby is set to run in the process, or false not to run in the process.

getCompatVersion

CompatVersion getCompatVersion()
Returns a Ruby version currently chosen, which is one of CompatVersion.RUBY1_8, CompatVersion.RUBY1_9, or CompatVersion.BOTH. The default version is CompatVersion.RUBY1_8.

Returns:
a Ruby version

setCompatVersion

void setCompatVersion(CompatVersion version)
Changes a Ruby version to be evaluated into one of CompatVersion.RUBY1_8, CompatVersion.RUBY1_9, or CompatVersion.BOTH. The default version is CompatVersion.RUBY1_8.

Parameters:
version - a Ruby version

isObjectSpaceEnabled

boolean isObjectSpaceEnabled()
Tests whether the Object Space is enabled or not.

Returns:
true if the Object Space is able to use, otherwise, false.

setObjectSpaceEnabled

void setObjectSpaceEnabled(boolean enable)
Changes the value to determine whether the Object Space is enabled or not. The default value is false. This value can be set by jruby.objectspace.enabled system property.

Parameters:
enable - true to enable the Object Space, or false to disable.

getEnvironment

java.util.Map getEnvironment()
Returns a map of environment variables.

Returns:
a map that has environment variables' key-value pairs.

setEnvironment

void setEnvironment(java.util.Map environment)
Changes an environment variables' map.

Parameters:
environment - a new map of environment variables.

getCurrentDirectory

java.lang.String getCurrentDirectory()
Returns a current directory. The default current directory is identical to a value of "user.dir" system property if no security restriction is set. If the "user.dir" directory is protected by the security restriction, the default value is "/".

Returns:
a current directory.

setCurrentDirectory

void setCurrentDirectory(java.lang.String directory)
Changes a current directory to a given directory.

Parameters:
directory - a new directory to be set.

getHomeDirectory

java.lang.String getHomeDirectory()
Returns a JRuby home directory. The default JRuby home is the value of JRUBY_HOME environmet variable, or "jruby.home" system property when no security restriction is set to those directories. If none of JRUBY_HOME or jruby.home is set and jruby-complete.jar is used, the default JRuby home is "/META-INF/jruby.home" in the jar archive. Otherwise, "java.io.tmpdir" system property is the default value.

Returns:
a JRuby home directory.

setHomeDirectory

void setHomeDirectory(java.lang.String home)
Changes a JRuby home directroy to a directory of a given name.

Parameters:
home - a name of new JRuby home directory.

getClassCache

ClassCache getClassCache()
Returns a ClassCache object that is tied to a class loader. The default ClassCache object is tied to a current thread' context loader if it exists. Otherwise, it is tied to the class loader that loaded RubyInstanceConfig.

Returns:
a ClassCache object.

setClassCache

void setClassCache(ClassCache cache)
Changes a ClassCache object to a given one.

Parameters:
cache - a new ClassCache object to be set.

getClassLoader

java.lang.ClassLoader getClassLoader()
Returns a class loader object that is currently used. This loader loads Ruby files and libraries.

Returns:
a class loader object that is currently used.

setClassLoader

void setClassLoader(java.lang.ClassLoader loader)
Changes a class loader to a given loader.

Parameters:
loader - a new class loader to be set.

getProfile

Profile getProfile()
Returns a profiler currently used. The default profiler is Profile.DEFAULT, which has the same behavior to Profile.ALL.

Returns:
a current profiler.

setProfile

void setProfile(Profile profile)
Changes a profiler to a given one.

Parameters:
profile - a new profiler to be set.

getLoadServiceCreator

RubyInstanceConfig.LoadServiceCreator getLoadServiceCreator()
Returns a LoadServiceCreator currently used.

Returns:
a current LoadServiceCreator.

setLoadServiceCreator

void setLoadServiceCreator(RubyInstanceConfig.LoadServiceCreator creator)
Changes a LoadServiceCreator to a given one.

Parameters:
creator - a new LoadServiceCreator

getArgv

java.lang.String[] getArgv()
Returns an arguments' list.

Returns:
an arguments' list.

setArgv

void setArgv(java.lang.String[] argv)
Changes values of the arguments' list.

Parameters:
argv - a new arguments' list.

getScriptFilename

java.lang.String getScriptFilename()
Returns a script filename to run. The default value is null.

Returns:
a script filename.

setScriptFilename

void setScriptFilename(java.lang.String filename)
Changes a script filename to run. The default value is null.

Parameters:
filename - a new script filename.

getRecordSeparator

java.lang.String getRecordSeparator()
Returns a record separator. The default value is .

Returns:
a record separator.

setRecordSeparator

void setRecordSeparator(java.lang.String separator)
Changes a record separator to a given value. If "0" is given, the record separator goes to "\n\n", "777" goes to "?", otherwise, an octal value of the given number.

Parameters:
separator - a new record separator value, "0" or "777"

getKCode

KCode getKCode()
Returns a value of KCode currently used. The default value is KCode.NONE.

Returns:
a KCode value.

setKCode

void setKCode(KCode kcode)
Changes a value of KCode to a given value. The default value is KCode.NONE.

Parameters:
kcode - a new KCode value.

getJitLogEvery

int getJitLogEvery()
Returns the value of n, which means that jitted methods are logged in every n methods. The default value is 0.

Returns:
a value that determines how often jitted methods are logged.

setJitLogEvery

void setJitLogEvery(int logEvery)
Changes a value of n, so that jitted methods are logged in every n methods. The default value is 0. This value can be set by the jruby.jit.logEvery System property.

Parameters:
logEvery - a new number of methods.

getJitThreshold

int getJitThreshold()
Returns a value of the threshold that determines whether jitted methods' call reached to the limit or not. The default value is -1 when security restriction is applied, or 50 when no security restriction exists.

Returns:
a value of the threshold.

setJitThreshold

void setJitThreshold(int threshold)
Changes a value of the threshold that determines whether jitted methods' call reached to the limit or not. The default value is -1 when security restriction is applied, or 50 when no security restriction exists. This value can be set by jruby.jit.threshold System property.

Parameters:
threshold - a new value of the threshold.

getJitMax

int getJitMax()
Returns a value of a max class cache size. The default value is 0 when security restriction is applied, or 4096 when no security restriction exists.

Returns:
a value of a max class cache size.

setJitMax

void setJitMax(int max)
Changes a value of a max class cache size. The default value is 0 when security restriction is applied, or 4096 when no security restriction exists. This value can be set by jruby.jit.max System property.

Parameters:
max - a new value of a max class cache size.

getJitMaxSize

int getJitMaxSize()
Returns a value of a max size of the bytecode generated by compiler. The default value is -1 when security restriction is applied, or 10000 when no security restriction exists.

Returns:
a value of a max size of the bytecode.

setJitMaxSize

void setJitMaxSize(int maxSize)
Changes a value of a max size of the bytecode generated by compiler. The default value is -1 when security restriction is applied, or 10000 when no security restriction exists. This value can be set by jruby.jit.maxsize System property.

Parameters:
maxSize - a new value of a max size of the bytecode.

getSupportedRubyVersion

java.lang.String getSupportedRubyVersion()
Returns version information about JRuby and Ruby supported by this platform.

Returns:
version information.


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