2

I want to create an OSGi (Equinox) bundle that contains a script engine (JSR-223 compliant) and use it in another bundle via ScriptEngineManager.getEngineFactories().

However the service discovery mechanism of Java Scripting API (jar file service discovery) fails to discover scripting engines in installed bundles.

I already saw few answers on the topic, which suggested using Apache Felix or Apache Sling since they have a solution. However I am wondering if the Equinox implementation has a way to handle the problem?

Community
  • 1
  • 1
  • Hi Ms. Sapunkova, having had a little while now to look at this, is there any particular approach you would recommend above the other suggestions? Even just marking one of the answers as right would be helpful, but a comment or two on how you ended up making that decision would be super useful if you can spare the time! Cheers, Eli – Elias Vasylenko May 07 '13 at 20:28

2 Answers2

1

Well, OSGi 5 will support it, it's called the Service Loader Mediator. That will effectively bridge the OSGi services with the java.util serviceloader.

Apache Aries has an implementation of it called Spi-Fly which should work. I guess it is more targeted at Felix but usually the OSGi implementations are pretty compatible.

To be honest though, I've never gone to the bottom of this one, so I can't speak from personal experience.

Good luck, Frank

Frank Lee
  • 2,728
  • 19
  • 30
  • **Spi-Fly** looks nice, I guess I will take a look at the source and see if it is going to work for me since it is pointed as the reference implementation of the **Service Loader Mediator**. Thanks. – Snezhana Sapunkova Jan 16 '13 at 20:46
1

I have implemented a solution based on one of the answers from Is OSGi fundamentally incompatible with JSR-223 Scripting Language Discovery? using OSGiScriptEngineManager and friends and that works pretty well.

The big problem then can be to find proper JSR 223 implementations for the scripting languages in question :-)

Community
  • 1
  • 1
Tonny Madsen
  • 12,628
  • 4
  • 31
  • 70