- All Implemented Interfaces:
- EmbedRubyInstanceConfigAdapter
public class IsolatedScriptingContainer
extends ScriptingContainer
the IsolatedScriptingContainer detects the whether it is used with
a Thread.currentThread.contextClassLoader (J2EE) or with the classloader
which loaded IsolatedScriptingContainer.class (OSGi case)
the setup of LOAD_PATH and GEM_PATH and JRUBY_HOME uses ONLY uri: or uri:classloader:
protocol paths. i.e. everything lives within one or more classloaders - no jars added from
jave.class.path or similar "magics"
the root of the "main" classloader is add to LOAD_PATH and GEM_PATH.
in the OSGi case there are helper methods to add ClassLoaders to the LOAD_PATH or GEM_PATH
a typical setup for the ContextClassLoader case looks likes this:
LOAD_PATH == [ "uri:classloader:/META-INF/jruby.home/lib/ruby/1.9/site_ruby",
"uri:classloader:/META-INF/jruby.home/lib/ruby/shared",
"uri:classloader:/META-INF/jruby.home/lib/ruby/1.9",
"uri:classloader:" ]
Gem::Specification.dirs == [ "uri:classloader:", "uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared" ]
here very resource is loaded via Thread.currentTHread.getContextClassLoader().getResourceAsStream(...)
a typical setup for OSGi case (one bundle with everything):
LOAD_PATH == [ "uri:bundle://16.0:1/META-INF/jruby.home/lib/ruby/1.9/site_ruby",
"uri:bundle://16.0:1/META-INF/jruby.home/lib/ruby/shared",
"uri:bundle://16.0:1/META-INF/jruby.home/lib/ruby/1.9",
"uri:bundle://16.0:1" ]
Gem::Specification.dirs == [ "uri:bundle://16.0:1", "uri:bundle://16.0:1/META-INF/jruby.home/lib/ruby/gems/shared" ]
other OSGi frameworks use other uris like bundleresource:/16.fwk1661197821. here very resource is loaded via
new URL( uri )openStream()
, i.e. new URL(classloader.getResource().toString()).openStream()
has to work for
those classloaders. felix and equinox OSGi framework do work.
NOTE: Gem.path
is base for determine the Gem::Specification.dirs
and Gem::Specification.dirs
is
used to find gemspec files of the installed gems.