public interface Script { public int compute() { } }We can perform:
ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>() { }; DebugSession<Script> session = wrapper.createDebugSession(); SessionHook<Script> hook = new SessionHook<> { public Object start(Script script) { return script.compute(); } } session.setSessionHook(hook); session.startSession(); session.startScript(); // here the script.compute() method is effectively executed
null
. For example:ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>() { }; DebugSession<Script> session = wrapper.createDebugSession(); SessionHook<Script> hook = new SessionHook<> { public Object start(Script script) { script.compute(); return null; } } session.setSessionHook(hook); session.startSession(); session.startScript(); // here the script.compute() method is effectively executed
ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>() { }; DebugSession<Script> session = wrapper.createDebugSession(); SessionHook<Script> hook = new SessionHook<> { public Object start(Script script, int arg) { return script.compute(arg); } } session.setSessionHook(hook); session.startSession(); session.startScript(10); // here the script.compute() method is effectively executed
SessionHook
. For example, for the following script interface:public interface Script { public int compute(int value) { } }It is valid to have the following code for the
SessionHook
:ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>() { }; DebugSession<Script> session = wrapper.createDebugSession(); SessionHook<Script> hook = new SessionHook<> { public Object start(Script script) { int result = 0; for (int i = 0; i < 100; i++) { result += script.compute(i); } return result; } } session.setSessionHook(hook); session.startSession(); session.startScript();
Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence