Search code examples
osgiequinoxjsr223

Equinox and Java Scripting API


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?


Solution

  • 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