org.camunda.bpm.engine.impl.bpmn.behavior
Class ScriptInvocationHandler

java.lang.Object
  extended by org.camunda.bpm.engine.impl.bpmn.behavior.ScriptInvocationHandler

public class ScriptInvocationHandler
extends Object

Handles the script invocation in a given VariableScope. The script invocation context supports pre-compilation of the script sources into a CompiledScript.

This class is thread-safe and instances of this class are meant to be used for evaluating the same script multiple, times in different variable scope instances.

Author:
Daniel Meyer

Field Summary
protected  CompiledScript compiledScript
          Holds the compiled script
protected  boolean isScriptCompilationSupported
          Flag indicating whether script compilation is supported.
protected  String language
          The language in which the scipt is written (JavaScript, Groovy ...).
protected  String resultVariable
          The name of the variable under which the result of the script should be stored in the variable scope.
protected  String script
          Source code of the script to execute.
 
Constructor Summary
ScriptInvocationHandler(String script, String language, String resultVariable)
           
 
Method Summary
 void evaluate(VariableScope variableScope)
          Evaluates the script in the given variable scope.
protected  void preCompileScript(ScriptingEngines scriptingEngines)
          Will attempt to pre-compile a script and cache it in compiledScript.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

script

protected String script
Source code of the script to execute.


language

protected String language
The language in which the scipt is written (JavaScript, Groovy ...).


resultVariable

protected String resultVariable
The name of the variable under which the result of the script should be stored in the variable scope.


compiledScript

protected CompiledScript compiledScript
Holds the compiled script


isScriptCompilationSupported

protected boolean isScriptCompilationSupported
Flag indicating whether script compilation is supported. Keeps us from attempting to pre-compile scripts multiple times in case the script engine does not support compilation. Will be populated after first invocation. See preCompileScript(ScriptingEngines)

Constructor Detail

ScriptInvocationHandler

public ScriptInvocationHandler(String script,
                               String language,
                               String resultVariable)
Parameters:
script - source code of the script
language - the language used
resultVariable - the variable name under which the result of the script invocation (if any) should be stored
Method Detail

evaluate

public void evaluate(VariableScope variableScope)

Evaluates the script in the given variable scope.

Parameters:
variableScope - the variable scope in which the script should be evaluate
Throws:
ProcessEngineException - in case the script cannot be evaluated.

preCompileScript

protected void preCompileScript(ScriptingEngines scriptingEngines)
Will attempt to pre-compile a script and cache it in compiledScript. If the script compilation returns 'null', isScriptCompilationSupported will be set to false and re-compilation will not be attempted.

Parameters:
scriptingEngines -


Copyright © 2014 camunda services GmbH. All Rights Reserved.