Script
interface, and run a Ruby Script as a class which implements this interface from Java.
public interface Script { public int execute(); }
public class RubyScriptWrapperImpl extends RubyScriptWrapper<Script> { }With this definition, we have defined that our wrapper wrap scripts which implement the
Script
interface.
ScriptWrapper<Script> wrapper = new RubyScriptWrapper<Script>(){ };
def execute return 10 endWe will get the script and create the ScriptWrapper:
File file = new File(<our script file>); Script script = wrapper.installScript(file);And now we can run the method:
int value = script.execute(); // value is 10
Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence