JRuby, Netbeans and OSGi


#1

Some excitement (?) seems to be developing around OSGi (Open Services
Gateway Initiative)
Are there any examples of using JRuby code in this environment, if it is
possible?
A few past entries in this JRuby list mention OSGi but no pointers to
any tutorials or examples can be found.
http://wiki.netbeans.org/OSGiAndNetBeans talks about netbeans, but a
simple introductory example for JRuby/Netbeans would be an excellent
starting point.

Thanks
Paul F.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

I don’t know much about the NetBeans world, Eclipse contributor and
fanboy
that I am. I do know that in my Eclipse plugin Groovy Monkey, I have
enabled JRuby as one of the languages that you can write scripts for. I
have also tested the plugin with an Eclipse distribution as small as the
Eclipse RCP.
Why might that relate to your question? Well Eclipse is run on an OSGi
container (one of its strengths IMHO) and the Eclipse RCP is an OSGi
container with a couple of megabytes of Eclipse bundles like resources,
core, runtime and SWT/JFace. I have put thought into extending Groovy
Monkey down to just the bare bones OSGi container, but haven’t had the
time
or really the push to get it done.
As far as using JRuby on OSGi and writing bundles in OSGi, I am not so
certain. I know it is possible for the Groovy language for instance,
and I
wrote a blog entry on the issues concerning that:
http://iacobus.blogspot.com/2007/03/add-groovy-to-your-eclipse-plugin.html

Still I know alot of this is specific to Groovy and the Eclipse
platform,
but hey the Eclipse platform running on Equinox (Eclipse’s OSGi
container)
is the number one example of an OSGi container (I’m sure to a bit of
chagrin
to OSGi folks like Peter Kriens).

In my opinion, if the JRuby compiler takes Ruby scripts and produces
byte
code that can be packaged in an OSGi bundle and you provide the JRuby
runtime as an OSGi library bundle for that container, it should work.

Another aside, take a look at Glimmer. It is a SWT builder plugin for
Eclipse that allows you to write SWT/JFace code in Ruby. I have a mind
to
try to incorporate it into Groovy Monkey. The URL for glimmer is:
http://www.eclipse.org/glimmer/

The author for Glimmer is Andy M. and he blogs about it at:
http://andymaleh.blogspot.com/

So there should be some examples, sorry they are all Eclipse specific.
I
would be curious to know if there is any activity of this sort on the
NetBeans side of the world.

Thanks,
James E. Ervin, IV

A human being should be able to change a diaper, plan an invasion,
butcher a
hog, conn a ship, design a building, write a sonnet, balance accounts,
build
a wall, set a bone, comfort the dying, take orders, give orders,
cooperate,
act alone, solve equations, analyze a new problem, pitch manure, program
a
computer, cook a tasty meal, fight efficiently, die gallantly.
Specialization is for insects.
-Robert A. Heinlein

Blog: http://iacobus.blogspot.com


#3

I just realized I missed the scope of your question. I know that it is
possible to run OSGi inside of a J2EE container and vice versa, via some
bridging frameworks. I am not aware of any bridges between NetBeans
module
system (what do they run on anyway?) and OSGi.
Thanks,
James E. Ervin, IV

A human being should be able to change a diaper, plan an invasion,
butcher a
hog, conn a ship, design a building, write a sonnet, balance accounts,
build
a wall, set a bone, comfort the dying, take orders, give orders,
cooperate,
act alone, solve equations, analyze a new problem, pitch manure, program
a
computer, cook a tasty meal, fight efficiently, die gallantly.
Specialization is for insects.
-Robert A. Heinlein

Blog: http://iacobus.blogspot.com


#4

James Ervin wrote:

I don’t know much about the NetBeans world, Eclipse contributor and
fanboy that I am. I do know that in my Eclipse plugin Groovy Monkey, I
have enabled JRuby as one of the languages that you can write scripts
for. I have also tested the plugin with an Eclipse distribution as
small as the Eclipse RCP.
[…]
So there should be some examples, sorry they are all Eclipse specific.
I would be curious to know if there is any activity of this sort on the
NetBeans side of the world.

Hi James,

I’ve tried to play with scripting NetBeans in Ruby. It was a half a year
ago and it kind of out-dated these days:

http://blogs.sun.com/martink/entry/scripting_netbeans_in_ruby

There were some barriers which made it a bit harder, but which should be
gone and thus it should be easier today. But I did not find a time to
get to the second round.

One day I would like to develop plugin for NetBeans in (J)Ruby. There
does not seem to be any technical barriers. So it’s just about the time
spent on that. But that’s off-topic for Eclipse guy :wink:

Cheers,
m.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#5

Speaking of JRuby and OSGi, I’m currently working with a couple of Rails
applications that we want to run on the SpringSource dm Server
(basically,
Equinox with Tomcat embedded and the ability to deploy .war files). One
thing
that I have gotten as far as a proof-of-concept is to:

  • remove jruby-complete-1.1.5.jar from the .war files (and rack) of a
    couple of
    really simple Rails apps,
  • add “Require-Bundle: jruby-complete” (and ditto rack) to the .war
    files’
    MANIFEST.MF,
  • use Peter Kriens’ bnd to add some OSGi metadata to
    jruby-complete-1.1.5.jar
    (…rack),
  • deploy the two apps to the server, with the jruby and rack bundles.

It looked like it worked.

The ultimate goal being to reduce the memory footprint by taking
everything that
is not the application out of the apps’ .war files. I have no idea yet
if it
actually does so, or if it actually really works, but it looks good so
far.

James Ervin wrote:

Monkey down to just the bare bones OSGi container, but haven’t had the
to a bit of chagrin to OSGi folks like Peter Kriens).
The author for Glimmer is Andy M. and he blogs about it
at: http://andymaleh.blogspot.com/

So there should be some examples, sorry they are all Eclipse specific.
I would be curious to know if there is any activity of this sort on the
NetBeans side of the world.

[…]

http://wiki.netbeans.org/OSGiAndNetBeans   talks about netbeans, but
a simple introductory example for JRuby/Netbeans would be an
excellent starting point.


Tommy M. McGuire
removed_email_address@domain.invalid


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#6

Tommy M. McGuire wrote:

jruby-complete-1.1.5.jar (…rack),

  • deploy the two apps to the server, with the jruby and rack bundles.

It looked like it worked.

The ultimate goal being to reduce the memory footprint by taking
everything that is not the application out of the apps’ .war files. I
have no idea yet if it actually does so, or if it actually really
works, but it looks good so far.

Ok, rather than leaving everyone hanging, here are the .bnd files I
used:

JRuby

-classpath: …/original/jruby-complete-1.1.5.jar
Bundle-Name: jruby-complete
Bundle-SymbolicName: jruby-complete
Bundle-Version: 1.1.5
Export-Package: org.jruby.; version=${Bundle-Version}
Private-Package: !org.jruby.
, *
Import-Package: *; resolution:=optional

That creates an OSGi bundle from jruby-complete, including all of the
original
contents. It exports the org.jruby.* packages (but not any others;
there are
quite a few, including com.kenai.constantine, that I don’t know anything
about),
and imports things like:

  • com.sun.mirror.*,
  • javax.management and .swing,
  • org.apache.bsf and .bsf.util, and
  • sun.misc

Rack

-classpath: …/original/jruby-rack-0.9.2.jar
Bundle-SymbolicName: jruby-rack
Bundle-Name: jruby-rack
Bundle-Version: 0.9.2
Import-Package:
org.jruby.,
javax.servlet.
,
*; resolution:=optional
Export-Package: *; version:=${Bundle-Version}

The import package header ensures org.jruby.* and javax.servlet.* are
required
and makes everything else optional.

OSGi uses bizarre classloader magic, JRuby uses bizarre classloader
magic, and
I’m fairly new to Java, Ruby, OSGi, and JRuby, so I have no idea whether
or not
it will ultimately explode and spew flaming death.


Tommy M. McGuire
removed_email_address@domain.invalid


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email