Class NashornHookerImpl
-
- All Implemented Interfaces:
public final class NashornHookerImpl extends NashornHooker
openjdk nashorn挂钩
-
-
Constructor Summary
Constructors Constructor Description NashornHookerImpl()
启用openjdk nashorn挂钩
-
Method Summary
Modifier and Type Method Description ScriptEngine
getNashornEngine(Array<String> args, ClassLoader classLoader)
获取一个新的Nashorn引擎 Object
invoke(CompiledScript compiledScript, String function, Map<String, Object> map, Object args)
调用脚本中的某个函数, 返回函数返回值 因为内部涉及ScriptObjectMirror的使用, 所以放入nashornHooker Boolean
isFunction(ScriptEngine engine, Object func)
检测引擎中是否包含对应函数 -
Methods inherited from class pers.neige.neigeitems.hook.nashorn.NashornHooker
compile, compile, compile, compile, getGlobalEngine, getNashornEngine, getNashornEngine, isFunction
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getNashornEngine
ScriptEngine getNashornEngine(Array<String> args, ClassLoader classLoader)
获取一个新的Nashorn引擎
- Parameters:
args
- 应用于引擎的参数classLoader
- 用于生成引擎的classLoader- Returns:
一个新的Nashorn引擎
-
invoke
Object invoke(CompiledScript compiledScript, String function, Map<String, Object> map, Object args)
调用脚本中的某个函数, 返回函数返回值 因为内部涉及ScriptObjectMirror的使用, 所以放入nashornHooker
- Parameters:
compiledScript
- 待调用脚本function
- 待调用函数名map
- 顶级变量args
- 传入函数的参数- Returns:
返回值
-
isFunction
Boolean isFunction(ScriptEngine engine, Object func)
检测引擎中是否包含对应函数
- Parameters:
engine
- 函数所在引擎func
- 待检测函数- Returns:
是否包含对应函数
-
-
-
-