Class LegacyNashornHookerImpl

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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
    • Constructor Detail

      • LegacyNashornHookerImpl

        LegacyNashornHookerImpl()
        启用jdk自带nashorn挂钩
    • 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:

        是否包含对应函数