Package org.jruby.embed.osgi
package org.jruby.embed.osgi
Extends the jruby.embed APIs. Access classes, ruby and libraries contained in OSGi bundles.
Example: use EclipseRT Web Starter Kit to run some ruby servlets and access some java objects.
This code was originally developed by Intalio.
org.jruby.embed.osgi.OSGiScriptingContainer extends ScriptingContainer
Java code in an OSGi bundle:
OSGiScriptingContainer container = new OSGiScriptingContainer(); container.runScriptlet(bundle, "/ruby/extend_MyClass.rb")
The bundle is lazily added to JRuby’s ClassPath.
where 'extend_MyClass.rb’ reads:
class Java::OrgJrubyOsgiTestSample::MyClass def say_hello puts "hello" end end
It is also possible to add OSGi bundles to JRuby’s ClassPath from java:
container.addToClassPath(bundle)
require 'bundle:/bundle.symbolic.name’
Define ruby libraries contained in an osgi bundle:
require 'osgibundle:/org.jruby.embed.osgi.test.samplebundle' class Java::OrgJrubyOsgiTestSamplebundle::MyOtherClass def say_hello_as_well puts "hello_as_well" end end
Access a ruby file inside a bundle:
require 'osgibundle:/org.jruby.embed.osgi.test/ruby/extend_MyClass.rb'
-
ClassesClassDescriptionadds some helper methods to add Bundle to the LOAD_PATH or GEM_PATH using the IsolatedScriptingContainer as base.Helpers to create a ScriptingContainer and set it up so it lives as well as possible in the OSGi world.