All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.embed.osgi.package.html Maven / Gradle / Ivy

There is a newer version: 9.4.7.0
Show newest version


  
    JRuby Embed OSGi support
  
  
    

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy