org.figure8.join.services.scripting.jsr223
Class JSR223ScriptLauncher

java.lang.Object
  extended by org.figure8.join.services.scripting.ScriptLauncher
      extended by org.figure8.join.services.scripting.jsr223.JSR223ScriptLauncher
All Implemented Interfaces:
Configurable

public class JSR223ScriptLauncher
extends ScriptLauncher

Extension of ScriptLauncher dedicated to the Java Scripting API (aka JSR-223, see http://www.jcp.org/en/jsr/detail?id=223). This implementation lets you wrap the execution of JSR-223 compatible scripts within a ScriptLauncher.
As a Configurable implementation, this launcher defines 1 more configurable parameters that is the name of the script engine to use for running the specified script.

Version:
$Revision: 1.2 $
Author:
Laurent Broudoux
See Also:
Configurable

Field Summary
static java.lang.String ENGINE_PARAM
          Name of configurable parameter denoting the engine for executing script.
protected static ParameterDefinition engineParam
          ParameterDefinition of the parameter representing the engine for executing script.
protected static java.util.List parameters
          List of ParameterDefinitions supported by this launcher
 
Fields inherited from class org.figure8.join.services.scripting.ScriptLauncher
SCRIPT_PARAM, scriptParam
 
Constructor Summary
JSR223ScriptLauncher()
          Creates a new instance of JSR223ScriptLauncher.
JSR223ScriptLauncher(java.lang.String scriptPath)
          Creates a new instance of JSR223ScriptLauncher with script path
 
Method Summary
 java.lang.String getEngine()
           
 ParameterDefinition[] getParameterDefinitions()
          Get this object parameters definitions as an array
 java.util.List getParameterDefinitionsAsList()
          Get this object parameters definitions as a list
 void runScript(java.util.Properties properties)
          Run the Groovy script file identified by scriptPath inner field according to the specified engine.
 void setEngine(java.lang.String engine)
           
 void setParameter(java.lang.String parameterName, java.lang.String parameterValue)
          Set the value of a parameter using its nama
 
Methods inherited from class org.figure8.join.services.scripting.ScriptLauncher
getLogOutputStream, getScript, getScriptPath, setLogOutputStream, setParameter, setParameters, setScriptPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENGINE_PARAM

public static final java.lang.String ENGINE_PARAM
Name of configurable parameter denoting the engine for executing script.

See Also:
Constant Field Values

parameters

protected static java.util.List parameters
List of ParameterDefinitions supported by this launcher


engineParam

protected static final ParameterDefinition engineParam
ParameterDefinition of the parameter representing the engine for executing script.

Constructor Detail

JSR223ScriptLauncher

public JSR223ScriptLauncher()
Creates a new instance of JSR223ScriptLauncher.


JSR223ScriptLauncher

public JSR223ScriptLauncher(java.lang.String scriptPath)
                     throws InvalidParameterException
Creates a new instance of JSR223ScriptLauncher with script path

Parameters:
scriptPath - the path of script to later execute
Throws:
InvalidParameterException - if path cannot be accessed
Method Detail

getEngine

public java.lang.String getEngine()
Returns:
The name of the script engine used for evaluationg script

setEngine

public void setEngine(java.lang.String engine)
Parameters:
engine - The name of the script engine used for evaluating script

runScript

public void runScript(java.util.Properties properties)
               throws ScriptException
Run the Groovy script file identified by scriptPath inner field according to the specified engine. Properties passed as param are injected into the script context as namespace properties. Script can directly use them using the ${property_name} form. Warning: "." in properties keys passing in are modified into "_" before injected. This is necessary because "." may have a special meaning in target script language (nested field) that we don't want to have here.

Specified by:
runScript in class ScriptLauncher
Parameters:
properties - The runtime properties to inject into execution environment
Throws:
ScriptException - if something wrong occurs during script parsing, evaluation, ...

getParameterDefinitionsAsList

public java.util.List getParameterDefinitionsAsList()
Get this object parameters definitions as a list

Specified by:
getParameterDefinitionsAsList in interface Configurable
Overrides:
getParameterDefinitionsAsList in class ScriptLauncher
Returns:
A list of ParameterDefinition objects

getParameterDefinitions

public ParameterDefinition[] getParameterDefinitions()
Get this object parameters definitions as an array

Specified by:
getParameterDefinitions in interface Configurable
Overrides:
getParameterDefinitions in class ScriptLauncher
Returns:
An array of ParameterDefinition objects

setParameter

public void setParameter(java.lang.String parameterName,
                         java.lang.String parameterValue)
                  throws InvalidParameterException
Set the value of a parameter using its nama

Specified by:
setParameter in interface Configurable
Overrides:
setParameter in class ScriptLauncher
Parameters:
parameterName - The name of parameter so set value for
parameterValue - The value of the paramater
Throws:
InvalidParameterException - if this parameter is not supported by this object


Copyright © 2005-2008 Join. All Rights Reserved.