Class ScriptingEnvironment
- java.lang.Object
-
- org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment
-
public class ScriptingEnvironment extends java.lang.Object
The scripting environment contains scripts that provide an environment to a user provided script. The environment may contain additional libraries or imports.
The environment performs lazy initialization of scripts: the first time a script of a given script language is executed, the environment will use the
ScriptEnvResolvers
for resolving the environment scripts for that language. The scripts (if any) are then pre-compiled and cached for reuse.- Author:
- Daniel Meyer
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.util.List<ExecutableScript>>
env
the cached environment scripts per script languageprotected java.util.List<ScriptEnvResolver>
envResolvers
the resolversprotected ScriptFactory
scriptFactory
the script factory used for compiling env scriptsprotected ScriptingEngines
scriptingEngines
the scripting engines
-
Constructor Summary
Constructors Constructor Description ScriptingEnvironment(ScriptFactory scriptFactory, java.util.List<ScriptEnvResolver> scriptEnvResolvers, ScriptingEngines scriptingEngines)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
execute(ExecutableScript script, VariableScope scope)
execute a given script in the environmentjava.lang.Object
execute(ExecutableScript script, VariableScope scope, javax.script.Bindings bindings, javax.script.ScriptEngine scriptEngine)
protected java.util.Map<java.lang.String,java.util.List<ExecutableScript>>
getEnv(java.lang.String language)
protected java.util.List<ExecutableScript>
getEnvScripts(java.lang.String scriptLanguage)
Returns the env scripts for the given language.protected java.util.List<ExecutableScript>
getEnvScripts(ExecutableScript script, javax.script.ScriptEngine scriptEngine)
protected java.util.Map<java.lang.String,java.util.List<ExecutableScript>>
getPaEnvScripts(ProcessApplicationReference pa)
protected java.util.List<ExecutableScript>
initEnvForLanguage(java.lang.String language)
Initializes the env scripts for a given language.
-
-
-
Field Detail
-
env
protected java.util.Map<java.lang.String,java.util.List<ExecutableScript>> env
the cached environment scripts per script language
-
envResolvers
protected java.util.List<ScriptEnvResolver> envResolvers
the resolvers
-
scriptFactory
protected ScriptFactory scriptFactory
the script factory used for compiling env scripts
-
scriptingEngines
protected ScriptingEngines scriptingEngines
the scripting engines
-
-
Constructor Detail
-
ScriptingEnvironment
public ScriptingEnvironment(ScriptFactory scriptFactory, java.util.List<ScriptEnvResolver> scriptEnvResolvers, ScriptingEngines scriptingEngines)
-
-
Method Detail
-
execute
public java.lang.Object execute(ExecutableScript script, VariableScope scope)
execute a given script in the environment- Parameters:
script
- theExecutableScript
to executescope
- the scope in which to execute the script- Returns:
- the result of the script evaluation
-
execute
public java.lang.Object execute(ExecutableScript script, VariableScope scope, javax.script.Bindings bindings, javax.script.ScriptEngine scriptEngine)
-
getEnv
protected java.util.Map<java.lang.String,java.util.List<ExecutableScript>> getEnv(java.lang.String language)
-
getPaEnvScripts
protected java.util.Map<java.lang.String,java.util.List<ExecutableScript>> getPaEnvScripts(ProcessApplicationReference pa)
-
getEnvScripts
protected java.util.List<ExecutableScript> getEnvScripts(ExecutableScript script, javax.script.ScriptEngine scriptEngine)
-
getEnvScripts
protected java.util.List<ExecutableScript> getEnvScripts(java.lang.String scriptLanguage)
Returns the env scripts for the given language. Performs lazy initialization of the env scripts.- Parameters:
scriptLanguage
- the language- Returns:
- a list of executable environment scripts. Never null.
-
initEnvForLanguage
protected java.util.List<ExecutableScript> initEnvForLanguage(java.lang.String language)
Initializes the env scripts for a given language.- Parameters:
language
- the language- Returns:
- the list of env scripts. Never null.
-
-