Package org.jppf.scripting
Class BaseScriptEvaluator
java.lang.Object
org.jppf.scripting.BaseScriptEvaluator
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ScriptedJobSelector,ScriptedNodeSelector
Base class for implementing and embedding all sorts of scripted logic. Scripts are evaluated using the
javax.script.* API (JSR-223).- Since:
- 5.2
- Author:
- Laurent Cohen
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBaseScriptEvaluator(String language, File scriptFile) Initialize this selector with the specfied language and script file.BaseScriptEvaluator(String language, Reader scriptReader) Initialize this selector with the specfied language and script reader.BaseScriptEvaluator(String language, String script) Initialize this selector with the specfied language and script. -
Method Summary
-
Constructor Details
-
BaseScriptEvaluator
Initialize this selector with the specfied language and script.- Parameters:
language- the language of the script to evaluate.script- the script to evaluate.
-
BaseScriptEvaluator
Initialize this selector with the specfied language and script reader.- Parameters:
language- the language of the script to evaluate.scriptReader- a reader from which to read the script to evaluate.- Throws:
IOException- if the script could not be read.
-
BaseScriptEvaluator
Initialize this selector with the specfied language and script file.- Parameters:
language- the language of the script to evaluate.scriptFile- a file from which to read the script to evaluate.- Throws:
IOException- if the script could not be read.
-
-
Method Details
-
getLanguage
Get the language of the script to evaluate.- Returns:
- the language as a string.
-
getScript
Get the script to evaluate.- Returns:
- th script as a string.
-
evaluate
Evaluate the script with the specified variable bindings.- Parameters:
variables- the variables to use i the script.- Returns:
- whatever is returned by the script, or
nullif the script evaluation raised an exception.
-
toString
-