Hi Mike,
You can use the JSR 223 js-engine.jar found at:
https://scripting.dev.java.net/servlets/ProjectDocumentList
Download the jsr223-engines.tar.gz, extract the js-engine.jar. There is a
META-INF/services/javax.script.ScriptEngineFactory file that registers the
script engine. I think you can request this new script engine with
something
like 'factory.getEngineByName("rhino-nonjdk")'.
--
Kevin
In case anyone is going down a similar path, I ended up doing the
following to get a mavenized version of this.
1. Exported the scripting/engines/javascript source using cvs.
* See https://scripting.dev.java.net/source/browse/scripting/
2. Added a basic pom.xml file
3. moved the src/ directory contents to src/main/java/
4. moved the META-INF directory to src/main/resources/
5. deleted bin, lib and make directory
6. Added a dependency on the latest rhino version to the pom.xml
<dependencies>
<dependency>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
<version>1.7R2</version>
</dependency>
</dependencies>
7. Added some sanity check tests to src/test/java
That worked like a charm and (being mavenized) will be easy to upgrade
to newer versions of rhino.
Also, for bonus points, I modified RhinoScriptEngineFactory to return
a more accurate version of the Rhino Engine (it was hardcoded to
1.6R7).
Added the following method to RhinoScriptEngineFactory:
private String getRhinoVersion()
{
// The rhino version message looks like "Rhino 1.7 release 2
2009 03 22"
// We need something of the form "1.7R2"
String longVersion =
ScriptRuntime.getMessage("implementation.version", null);
Pattern pattern = Pattern.compile("Rhino ([0-9.]*)( release
([0-9.]*))?");
Matcher matcher = pattern.matcher(longVersion);
if (matcher.find() && matcher.group(1) != null)
{
String version = matcher.group(1);
if (matcher.group(3) != null)
version += "R" + matcher.group(3);
return version;
}
return "unknown";
}
And replaced
} else if (key.equals(ScriptEngine.ENGINE_VERSION)) {
return "1.6R7";
with
} else if (key.equals(ScriptEngine.ENGINE_VERSION)) {
return getRhinoVersion();
Mike