Class | Description |
---|---|
OSGiScriptingContainer |
Helpers to create a ScriptingContainer and set it up so it lives as well
as possible in the OSGi world.
|
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.
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)
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'
Copyright © 2001-2015 JRuby. All Rights Reserved.