1

I'm not quite a total newbie to OSGi, but apparently newbie enough.

What I want to do is write an OSGi (Apache Felix) bundle and use the Java scripting API (JSR-223) with for example Groovy. For this I installed groovy 2.4.12, which already is an OSGi bundle, and I see the Groovy Runtime (2.4.12) as an active service in Felix's Remote Shell Console.

I also understand the conflict between Java's ServiceLoader API and OSGi's bundles. This Is OSGi fundamentally incompatible with JSR-223 Scripting Language Discovery? refers to a blog stating that Felix has found a workaround already.

All good. But then. What do I need to import to use that OSGiScriptEngineManager sniplet?

tbeernot
  • 2,473
  • 4
  • 24
  • 31

1 Answers1

1

If you use Maven, something like this could work:

 <dependency>
     <groupId>org.apache.felix</groupId>
     <artifactId>org.apache.felix.mishell</artifactId>
     <version>1.0.0</version>
 </dependency>

But I think this package was never released, probably a dead project. Well, you can try to compile it yourself from https://github.com/Dexels/apachecon/tree/master/org.apache.felix.mishell

I try to avoid ServiceLoaders, and if you say they offer Groovy as OSGi Service, then you really should use that.

If you just want to use Groovy, I suggest this:

import org.codehaus.groovy.jsr223.GroovyScriptEngineFactory;
import javax.script.ScriptEngine;

public class Test {

    public static void main(String[] args) {
        ScriptEngine e = new GroovyScriptEngineFactory().getScriptEngine();
    }
}
Marcos Zolnowski
  • 2,751
  • 1
  • 24
  • 29