org.jruby.embed.osgi
Class OSGiScriptingContainer
java.lang.Object
org.jruby.embed.ScriptingContainer
org.jruby.embed.osgi.OSGiScriptingContainer
- All Implemented Interfaces:
- EmbedRubyInstanceConfigAdapter
public class OSGiScriptingContainer
- extends ScriptingContainer
Helpers to create a ScriptingContainer and set it up so it lives as well
as possible in the OSGi world.
Currently:
- Access to the java classes and resources provided by the osgi bundle.
- Setup of jruby home pointing at the jruby bundle by default. Supporting unzipped jruby bundle for now.
TODO: look into using the LoadService of jruby.
Look if it would be possible to reuse the base runtime and minimize the cost of new
jruby runtimes.
- Author:
- hmalphettes
Methods inherited from class org.jruby.embed.ScriptingContainer |
callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, callSuper, clear, finalize, get, get, getArgv, getAttribute, getAttributeMap, getClassCache, getClassLoader, getCompatVersion, getCompileMode, getCurrentDirectory, getEnvironment, getErr, getError, getErrorWriter, getHomeDirectory, getIn, getInput, getInstance, getJitLogEvery, getJitMax, getJitMaxSize, getJitThreshold, getKCode, getLoadPaths, getLoadServiceCreator, getOut, getOutput, getProfile, getProperty, getProvider, getReader, getRecordSeparator, getRuntime, getScriptFilename, getSupportedRubyVersion, getVarMap, getWriter, isObjectSpaceEnabled, isRunRubyInProcess, newObjectAdapter, newRuntimeAdapter, parse, parse, parse, parse, put, put, remove, remove, removeAttribute, resetErrorWriter, resetWriter, runScriptlet, runScriptlet, runScriptlet, runScriptlet, setArgv, setAttribute, setClassCache, setClassLoader, setCompatVersion, setCompileMode, setCurrentDirectory, setEnvironment, setError, setError, setErrorWriter, setHomeDirectory, setInput, setInput, setJitLogEvery, setJitMax, setJitMaxSize, setJitThreshold, setKCode, setLoadPaths, setLoadServiceCreator, setObjectSpaceEnabled, setOutput, setOutput, setProfile, setReader, setRecordSeparator, setRunRubyInProcess, setScriptFilename, setWriter, terminate |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OSGiScriptingContainer
public OSGiScriptingContainer(org.osgi.framework.Bundle creator)
OSGiScriptingContainer
public OSGiScriptingContainer(org.osgi.framework.Bundle creator,
LocalContextScope scope,
LocalVariableBehavior behavior)
- Parameters:
scope
- if null, LocalContextScope.SINGLETHREADbehavior
- if null, LocalVariableBehavior.TRANSIENT
runScriptlet
public java.lang.Object runScriptlet(java.lang.String bundleSymbolicName,
java.lang.String path)
- Parameters:
bundleSymbolicName
- The bundle where the script is located. Lazily added to the
loader of the OSGiScriptingContainer. (require bundle:/... is implicitly done here)path
- The entry in the bundle
- Returns:
runScriptlet
public java.lang.Object runScriptlet(org.osgi.framework.Bundle bundle,
java.lang.String path)
- Parameters:
bundle
- The bundle where the script is located. Lazily added to the
loader of the OSGiScriptingContainer. (require bundle:/... is implicitly done here)path
- The entry in the bundle
- Returns:
parse
public EmbedEvalUnit parse(org.osgi.framework.Bundle bundle,
java.lang.String path,
int... lines)
throws java.io.IOException
- Parses a script given by a input stream and return an object which can be run().
This allows the script to be parsed once and evaluated many times.
- Parameters:
bundle
- is where the script is locatedpath
- is the entry in the bundle.lines
- are linenumbers to display for parse errors and backtraces.
This field is optional. Only the first argument is used for parsing.
When no line number is specified, 0 is applied to.
- Returns:
- an object which can be run
- Throws:
java.io.IOException
addToClassPath
public void addToClassPath(org.osgi.framework.Bundle bundle)
- Parameters:
bundle
- Add a bundle to the jruby classloader.
Equivalent to require "bundle:/#{bundle.symbolic.name}"
getOSGiBundleClassLoader
public JRubyOSGiBundleClassLoader getOSGiBundleClassLoader()
- Returns:
- The ScriptingContainer's classloader casted to a JRubyOSGiBundleClassLoader.
It is the parent classloader of the actual's runtime's JRubyClassLoader.
It enables finding classes and resources in the OSGi environment.
Copyright © 2002-2009 JRuby Team. All Rights Reserved.