public interface Script { public int execute(); }And the following helper class:
public class HelperAPI { public int getValue() { return 10; } }
ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>(){ }; wrapper.addAdditionalHelper("api", new HelperAPI()); File file = new File(<our script file>); Script script = wrapper.installScript(file); int value = script.execute();with the following script:
public int execute() { return api.getValue() + 1; }The result will be 11.
Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence