Package org.jruby.embed
Interface EmbedRubyInstanceConfigAdapter
- All Known Implementing Classes:
IsolatedScriptingContainer
,OSGiIsolatedScriptingContainer
,OSGiScriptingContainer
,ScriptingContainer
public interface EmbedRubyInstanceConfigAdapter
This interface defines methods to configure Ruby runtime for embedding.
- Since:
- JRuby 1.5.0
- Author:
- Yoko Harada <[email protected]>
-
Method Summary
Modifier and TypeMethodDescriptionString[]
getArgv()
Returns an arguments' list.Returns a class loader object that is currently used.Returns a compile mode currently chosen, which is one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF.Returns a current directory.Returns a map of environment variables.getError()
Returns an error stream assigned to STDERR and $stderr.Returns a JRuby home directory.getInput()
Returns an input stream assigned to STDIN and $stdin.int
Returns the value of n, which means that jitted methods are logged in every n methods.int
Returns a value of a max class cache size.int
Returns a value of a max size of the bytecode generated by compiler.int
Returns a value of the threshold that determines whether jitted methods' call reached to the limit or not.getKCode()
Returns a value of KCode currently used.Returns a list of load paths for Ruby scripts/libraries.Returns a LoadServiceCreator currently used.Returns an output stream assigned to STDOUT and $stdoutReturns a profiler currently used.Returns a record separator.Returns a script filename to run.Returns version information about JRuby and Ruby supported by this platform.boolean
Tests whether the Object Space is enabled or not.boolean
Tests whether Ruby runs in a process or not.void
Changes values of the arguments' list.void
setClassLoader
(ClassLoader loader) Changes a class loader to a given loader.void
Changes a compile mode to a given mode, which should be one of CompileMode.JIT, CompileMode.FORCE, CompileMode.OFF.void
setCurrentDirectory
(String directory) Changes a current directory to a given directory.void
setEnvironment
(Map environment) Changes an environment variables' map.void
setError
(PrintStream pstream) Changes STDERR and $stderr to a gievn print stream.void
Changes STDERR and $stderr to a given writer.void
setHomeDirectory
(String home) Changes a JRuby home directroy to a directory of a given name.void
setInput
(InputStream istream) Changes STDIN and $stdin to a given input stream.void
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
Changes a value of KCode to a given value.void
setLoadPaths
(List<String> paths) Changes a list of load paths Ruby scripts/libraries.void
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
(PrintStream pstream) Changes STDOUT and $stdout to a given output stream.void
Changes STDOUT and $stdout to a given writer.void
setProfile
(Profile profile) Changes a profiler to a given one.void
setRecordSeparator
(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
(String filename) Changes a script filename to run.
-
Method Details
-
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
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
InputStream getInput()Returns an input stream assigned to STDIN and $stdin.- Returns:
- input stream of STDIN and $stdin
-
setInput
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
Changes STDIN and $stdin to a given reader. No reader is set by default.- Parameters:
reader
- a reader to be set
-
getOutput
PrintStream getOutput()Returns an output stream assigned to STDOUT and $stdout- Returns:
- an output stream of STDOUT and $stdout
-
setOutput
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
Changes STDOUT and $stdout to a given writer. No writer is set by default.- Parameters:
writer
- a writer to be set
-
getError
PrintStream getError()Returns an error stream assigned to STDERR and $stderr.- Returns:
- output stream for error stream
-
setError
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
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
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.
-
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
Map getEnvironment()Returns a map of environment variables.- Returns:
- a map that has environment variables' key-value pairs.
-
setEnvironment
Changes an environment variables' map.- Parameters:
environment
- a new map of environment variables.
-
getCurrentDirectory
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
Changes a current directory to a given directory.- Parameters:
directory
- a new directory to be set.
-
getHomeDirectory
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
Changes a JRuby home directroy to a directory of a given name.- Parameters:
home
- a name of new JRuby home directory.
-
getClassLoader
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
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
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
Changes a LoadServiceCreator to a given one.- Parameters:
creator
- a new LoadServiceCreator
-
getArgv
String[] getArgv()Returns an arguments' list.- Returns:
- an arguments' list.
-
setArgv
Changes values of the arguments' list.- Parameters:
argv
- a new arguments' list.
-
getScriptFilename
String getScriptFilename()Returns a script filename to run. The default value is null.- Returns:
- a script filename.
-
setScriptFilename
Changes a script filename to run. The default value is null.- Parameters:
filename
- a new script filename.
-
getRecordSeparator
String getRecordSeparator()Returns a record separator. The default value is .- Returns:
- a record separator.
-
setRecordSeparator
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
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
String getSupportedRubyVersion()Returns version information about JRuby and Ruby supported by this platform.- Returns:
- version information.
-