org.jppf.scripting
Class GroovyScriptRunner

java.lang.Object
  extended by org.jppf.scripting.GroovyScriptRunner
All Implemented Interfaces:
ScriptRunner

public class GroovyScriptRunner
extends Object
implements ScriptRunner

Script runner wrapper around a Groovy script engine.

Author:
Laurent Cohen

Constructor Summary
GroovyScriptRunner()
           
 
Method Summary
 void cleanup()
          Perform cleanup after we're done using this script runner.
 Object evaluate(String script, Map<String,Object> variables)
          Evaluate the script specified as input and get the evaluation result.
 Object evaluate(String scriptId, String script, Map<String,Object> variables)
          Evaluate the script specified as input and get the evaluation result.
 void init()
          Initialize the execution environment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroovyScriptRunner

public GroovyScriptRunner()
Method Detail

evaluate

public Object evaluate(String script,
                       Map<String,Object> variables)
                throws JPPFScriptingException
Evaluate the script specified as input and get the evaluation result.

Specified by:
evaluate in interface ScriptRunner
Parameters:
script - a string containing the script to evaluate.
variables - a mapping of objects to add the scope of the script.
Returns:
the result of the evaluation as an object.
Throws:
JPPFScriptingException - if an error occurs while evaluating the script.
See Also:
ScriptRunner.evaluate(java.lang.String, java.util.Map)

evaluate

public Object evaluate(String scriptId,
                       String script,
                       Map<String,Object> variables)
                throws JPPFScriptingException
Evaluate the script specified as input and get the evaluation result.

Specified by:
evaluate in interface ScriptRunner
Parameters:
scriptId - a unique identifer 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.
See Also:
ScriptRunner.evaluate(java.lang.String, java.lang.String, java.util.Map)

init

public void init()
Initialize the execution environment.

Specified by:
init in interface ScriptRunner
See Also:
ScriptRunner.init()

cleanup

public void cleanup()
Perform cleanup after we're done using this script runner.

Specified by:
cleanup in interface ScriptRunner
See Also:
ScriptRunner.cleanup()


Copyright © 2005-2010 JPPF Team.