When providing scripting in a Java application, scripting engines conforming to JSR 223 (e.g. Groovy, JRuby, Scala, …) can easily be embedded using something along the lines of
ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); ScriptEngine scriptEngine = scriptEngineManager.getByName("groovy");
However, in an OSGi-based application, the ScriptEngineManager
fails to discover scripting engines located in installed bundles bundles, due to the way () it discovers engines available on the class path. Luckily, the Apache Felix project has already solved this problem, there are
which provide an OSGi-compliant way to discover and load scripting engines installed as OSGi bundles.
ScriptEngineManager scriptEngineManager = new OSGiScriptEngineManager(bundleContext); ScriptEngine scriptEngine = scriptEngineManager.getByName("groovy");
What bundle contains these classes? I see it is in the mishell folder, but don’t see that has a downloadable bundle.
A quick search on Maven Central confirmed that these classes don’t seem to be in any bundle on there. I guess the best option would be to copy the mentioned three classes to your project, if your license is compatible with Apache v2 that shouldn’t be an issue.