dev@glassfish.java.net

[RFC] OSGi/SPI integration via "patches"?

From: Ancoron Luciferis <ancoron.luciferis_at_googlemail.com>
Date: Wed, 2 Mar 2011 12:45:03 +0100

Hi devs,

I just stumbled across the problem, that I need to have the groovy
scripting engine available inside our GlassFish OSGi environment.

As groovy is already available as an OSGi bundle I just took that, but
the scripting engine hasn't been picked up by the
javax.script.ScriptEnginesManager.

So I have to manually register the groovy engine, which implies that I
need to have access to the implementation. I've searched a bit for
information around this META-INF/services issue and found the
solution that Sahoo came up with:

http://wikis.sun.com/display/GlassFish/JdkSpiOsgi

I also read about other implementation efforts:

ServiceMix 4:
http://gnodet.blogspot.com/2008/05/jee-specs-in-osgi.html

Aries SPI Fly:
https://cwiki.apache.org/confluence/display/ARIES/SPI+Fly


However, I think all those methods are rather intrusive and don't
provide a transparent way to "just run" anything that relies on the
Java SPI mechanism.

Therefore I searched a bit more regarding class overrides in OSGi and
here is something that got my attention:

http://blog.afkham.org/2008/10/how-to-create-patches-for-osgi-bundles.html

With that technique would it be possible to override implementations of
the JRE itself, e.g. "sun.misc.Service" or some higher level like
"javax.script.ScriptEnginesManager"?

If that works (especially the "sun.misc.Service" one) than all problems
regarding integration of META-INF/services could be solved in one shot
(at least what I think).

What do you think?

Cheers,

ancoron