Hi,

Here's what I've done. You may checkout http://swtbot.org/tools/ for
the final look and feel of the console.

* Use jruby's manifest AS-IS
* Create another bundle(https://gist.github.com/742000) that:
  * can manage creating and disposing of jruby runtimes
  * Does a "DynamicImport-Package: *" in the MANIFEST.MF(evil!) -
https://gist.github.com/742000
  * Uses the plugin's classloader when creating the jruby runtime -
https://gist.github.com/742003

"DynamicImport-Package: *" is a very evil thing to do in the OSGi
land. However my requirement at the time was to create an eclipse
console that allowed eclipse/OSGi developers to try out different
things in a jruby console with access to all the apis.

In your case, you may choose to import only those packages that you
are interested in.

- Ketan
studios.thoughtworks.com | twitter.com/ketanpkr




On Mon, Nov 29, 2010 at 6:07 PM, Anthony Juckel <ajuc...@gmail.com> wrote:
> I've been wanting to embed a JRuby REPL in Eclipse applications I'm building
> for some time now.  I finally started picking at the code to test
> feasibility and ran into one simple issue.  Basically, I wanted to have an
> Eclipse App load up the JRuby runtime, then run a simple(-ish) Ruby script
> within that runtime, where the script itself should load a Java class
> visible to the application bundle, but not explicitly visible to the JRuby
> bundle.
>
> I've uploaded the sample app to
> https://github.com/ajuckel/net.juckel.osgirubytest if anyone wants to check
> it out, but the only gotchas with the 1.6.0.dev bundle were:
>
> 1) I had to use ScriptingContainer#setClassLoader(ClassLoader) to make sure
> that my bundle's classloader was used to lookup classes within JRuby.  My
> bundle then does a Require-Bundle on org.jruby.jruby.
> 2) After that was done, in order for require 'java' to work, I had to update
> the jruby.bnd.template to export builtin.* so my application bundle could
> see the builtin resources.  I'm not a big fan of this second step, so either
> I'm doing something wrong in my sample app, or a more intelligent
> classloading change would have to be made within JRuby itself.
>
> I'm also curious if anyone to hear stories from anyone else running JRuby
> within an OSGi context.
>
> Anthony Juckel
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to