Package org.jppf.scripting
Interface ScriptRunner
public interface ScriptRunner
Common interface for all script runners, allowing access to a scripting engine.
- Author:
- Laurent Cohen
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Perform cleanup after we're done using this script runner.Evaluate the script specified as input and get the evaluation result.Evaluate the script specified as input and get the evaluation result.Get the script language this script runner is intended for.voidinit()Initialize the execution environment.
-
Method Details
-
getLanguage
String getLanguage()Get the script language this script runner is intended for.- Returns:
- the short name of this runner's script language.
-
evaluate
Evaluate the script specified as input and get the evaluation result.- Parameters:
script- a string containing the script to evaluate.variables- a mapping of objects to variable names, added within the scope of the script.- Returns:
- the result of the evaluation as an object. The actual type of the result depends on the scripting engine that is used.
- Throws:
JPPFScriptingException- if an error occurs while evaluating the script.
-
evaluate
Object evaluate(String scriptId, String script, Map<String, Object> variables) throws JPPFScriptingExceptionEvaluate the script specified as input and get the evaluation result.- Parameters:
scriptId- a unique identifier for the script, to be used if the engine generates compiled code which can be later retrieved through this id.script- a string containing the script to evaluate.variables- a mapping of objects to variable names, added within the scope of the script.- Returns:
- the result of the evaluation as an object. The actual type of the result depends on the scripting engine that is used.
- Throws:
JPPFScriptingException- if an error occurs while evaluating the script.
-
init
void init()Initialize the execution environment. -
cleanup
void cleanup()Perform cleanup after we're done using this script runner.
-