context
field in your script. For example:public void apply() { context.echo("Hello World"); }
public class ScriptContext |
---|
Modifier and Type | Method and Description |
---|---|
void | abort(String message)
Abort the current script. The Scripting engine will use the throwable exception to stop the execution
|
void | echo(String message)
Echo a message
|
void | echo(Number number)
Echo a numeric value
|
void | error(String message)
Error a message
|
ScriptHelper | getHelper()
Return the script helper. Return null by default
|
File | getPath(String path)
Return the absolute path of a file defined relative to the script file
|
File | getScriptFile()
Return the script file
|
ScriptLogger | getScriptLogger()
Return the associated ScriptLogger
|
abort(String message)
will abort the script. It can be listened by an Exception listener
public interface Script extends ContextListener { public int computeResult(int value) { } }Note that:
context
field in the script. For example to show a message on the logger:public void execute(int value) { context.echo("My value:" + value); }
ScriptWrapper<Script> wrapper = new GroovyScriptWrapper<Script>() { protected ScriptContext getScriptContext() { return null; } };
Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence