public interface Script { public int execute(); }and the script wrapper creation:
ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>(){ }; Script script = wrapper.getScript(); File file = new File(<our script file>); wrapper.installScript(file); int value = script.execute();wythe the folliowing script:
public int execute() { return 10; }The result will be 10.
public interface Script { public int execute(); }And the following
support.groovy
Groovy script:public int give() { return 10; }And finally the Groovy script implementing the interface:
load 'support.groovy' as loaded public int execute() { return loaded.give(); }Executing this script will return 10.
Script
interface:public interface Script { public int execute(); }To create the wrapper, you must use a GroovyScriptWrapper:
ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>(){ }; Script script = wrapper.getScript(); File file = new File(<our script file>); wrapper.installScript(file); int value = script.execute();You can use for example the following script:
public int execute() { return 10; }or even:
return 10;
invokeDynamic
:Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence