@Test public void testGrvyScriptEngine() throws ScriptException { List<String> card = Arrays.asList("1","2","3"); grvyScriptEngine.bingingGlobalScopeMapper("渠道","NET"); grvyScriptEngine.bindingEngineScopeMapper("交易码","1101"); grvyScriptEngine.bindingEngineScopeMapper("name","name is grvy"); String script = " def list = [\"1101\",\"1411\",\"1121\",\"1131\"]\n" + " def channels = [\"NET\",\"NCUP\"]\n" + " def str = com.grvyframework.grvy.GrvyInvokeInterface.test(name)\n" + " println( \"str:->\" + str)\n" + " if (list.contains(交易码) && channels.contains(渠道)){\n" + " return 2\n" + " } "; Object obj = grvyScriptEngine.eval(script); System.out.println(obj); System.out.println(Objects.isNull(obj)); }
private GrvyScriptEngine(){ this.scriptEngine = factory.getEngineByName("groovy"); }
GrvyScriptEngine { private GrvyScriptEngine(){ this.scriptEngine = factory.getEngineByName("groovy"); } }
GrvyScriptEngine { private GrvyScriptEngine(){ this.scriptEngine = factory.getEngineByName("groovy"); } private  GrvyScriptEngine(); }
GrvyScriptEngine { private GrvyScriptEngine(){ this.scriptEngine = factory.getEngineByName("groovy"); } private  GrvyScriptEngine(); T eval(String script); GrvyScriptEngine bingingGlobalScopeMapper(String key,Object orgField); ScriptEngine getCurrentGrvyScriptEngine(); GrvyScriptEngine bindingEngineScopeMapper(String key,Object orgField); GrvyScriptEngine bindingEngineScopeMapper(Bindings bindings); void clearCurrEngineBinding(); }
GrvyScriptEngine { private GrvyScriptEngine(){ this.scriptEngine = factory.getEngineByName("groovy"); } private  GrvyScriptEngine(); T eval(String script); GrvyScriptEngine bingingGlobalScopeMapper(String key,Object orgField); ScriptEngine getCurrentGrvyScriptEngine(); GrvyScriptEngine bindingEngineScopeMapper(String key,Object orgField); GrvyScriptEngine bindingEngineScopeMapper(Bindings bindings); void clearCurrEngineBinding();  }