public class RhinoScriptEngine
extends javax.script.AbstractScriptEngine
implements javax.script.Invocable, javax.script.Compilable
ScriptEngine using the Mozilla Rhino
interpreter.| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
| Constructor and Description |
|---|
RhinoScriptEngine()
Creates a new instance of RhinoScriptEngine
|
| Modifier and Type | Method and Description |
|---|---|
static Object |
bindings(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
Object[] args,
org.mozilla.javascript.Function funObj)
The bindings function takes a JavaScript scope object
of type ExternalScriptable and returns the underlying Bindings
instance.
|
javax.script.CompiledScript |
compile(Reader script) |
javax.script.CompiledScript |
compile(String script) |
javax.script.Bindings |
createBindings() |
Object |
eval(Reader reader,
javax.script.ScriptContext ctxt) |
Object |
eval(String script,
javax.script.ScriptContext ctxt) |
javax.script.ScriptEngineFactory |
getFactory() |
<T> T |
getInterface(Class<T> clasz) |
<T> T |
getInterface(Object thiz,
Class<T> clasz) |
Object |
invokeFunction(String name,
Object... args) |
Object |
invokeMethod(Object thiz,
String name,
Object... args) |
static void |
main(String[] args) |
protected Reader |
preProcessScriptSource(Reader reader) |
protected void |
processAllTopLevelScripts(org.mozilla.javascript.Context cx) |
protected void |
processTopLevelScript(String scriptName,
org.mozilla.javascript.Context cx) |
static Object |
scope(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
Object[] args,
org.mozilla.javascript.Function funObj)
The scope function creates a new JavaScript scope object
with given Bindings object as backing store.
|
static Object |
sync(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
Object[] args,
org.mozilla.javascript.Function funObj)
The sync function creates a synchronized function (in the sense
of a Java synchronized method) from an existing function.
|
public static final boolean DEBUG
public RhinoScriptEngine()
public Object eval(Reader reader, javax.script.ScriptContext ctxt) throws javax.script.ScriptException
eval in interface javax.script.ScriptEnginejavax.script.ScriptExceptionpublic Object eval(String script, javax.script.ScriptContext ctxt) throws javax.script.ScriptException
eval in interface javax.script.ScriptEnginejavax.script.ScriptExceptionpublic javax.script.ScriptEngineFactory getFactory()
getFactory in interface javax.script.ScriptEnginepublic javax.script.Bindings createBindings()
createBindings in interface javax.script.ScriptEnginepublic Object invokeFunction(String name, Object... args) throws javax.script.ScriptException, NoSuchMethodException
invokeFunction in interface javax.script.Invocablejavax.script.ScriptExceptionNoSuchMethodExceptionpublic Object invokeMethod(Object thiz, String name, Object... args) throws javax.script.ScriptException, NoSuchMethodException
invokeMethod in interface javax.script.Invocablejavax.script.ScriptExceptionNoSuchMethodExceptionpublic <T> T getInterface(Class<T> clasz)
getInterface in interface javax.script.Invocablepublic <T> T getInterface(Object thiz, Class<T> clasz)
getInterface in interface javax.script.Invocablepublic javax.script.CompiledScript compile(String script) throws javax.script.ScriptException
compile in interface javax.script.Compilablejavax.script.ScriptExceptionpublic javax.script.CompiledScript compile(Reader script) throws javax.script.ScriptException
compile in interface javax.script.Compilablejavax.script.ScriptExceptionprotected Reader preProcessScriptSource(Reader reader) throws javax.script.ScriptException
javax.script.ScriptExceptionprotected void processAllTopLevelScripts(org.mozilla.javascript.Context cx)
protected void processTopLevelScript(String scriptName, org.mozilla.javascript.Context cx)
public static Object bindings(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj)
public static Object scope(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj)
public static Object sync(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj)
this object of
its invocation.
js> var o = { f : sync(function(x) {
print("entry");
Packages.java.lang.Thread.sleep(x*1000);
print("exit");
})};
js> thread(function() {o.f(5);});
entry
js> thread(function() {o.f(5);});
js>
exit
entry
exitCopyright © 2015. All Rights Reserved.