This OSGi bundle exemplifies the minimal setup required to use the Nashorn JavaScript engine as an external script engine in Apache Sling.
Significant implementation details:
- embeds the Nashorn engine inside the bundle
- also embeds the transitive ASM depedndency to make the bundle fully self-contained
- uses a more recent ASM version for compatibility with recent JDKs
- exposes a servlet at
/bin/nashornthat executes a simple script using the Nashorn engine - obtains the
ScriptEngineManageras an OSGi reference
Build with mvn install. Deploy with mvn sling:install. Test by accessing http://localhost:8080/bin/nashorn-test .