Package org.jruby.embed.osgi

JRuby Embed OSGi support

See: Description

Package org.jruby.embed.osgi Description

JRuby Embed OSGi support

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"

It is also possible to add OSGi bundles to JRuby’s ClassPath from java:


require '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"

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.