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");