public class StandardScriptEvaluator extends Object implements ScriptEvaluator, org.springframework.beans.factory.BeanClassLoaderAware
javax.script (JSR-223) based implementation of Spring's ScriptEvaluator
strategy interface.ScriptEngine.eval(String)| Constructor and Description |
|---|
StandardScriptEvaluator()
Construct a new
StandardScriptEvaluator. |
StandardScriptEvaluator(ClassLoader classLoader)
Construct a new
StandardScriptEvaluator for the given class loader. |
StandardScriptEvaluator(ScriptEngineManager scriptEngineManager)
Construct a new
StandardScriptEvaluator for the given JSR-223
ScriptEngineManager to obtain script engines from. |
| Modifier and Type | Method and Description |
|---|---|
Object |
evaluate(ScriptSource script)
Evaluate the given script.
|
Object |
evaluate(ScriptSource script,
Map<String,Object> argumentBindings)
Evaluate the given script with the given arguments.
|
protected ScriptEngine |
getScriptEngine(ScriptSource script)
Obtain the JSR-223 ScriptEngine to use for the given script.
|
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setEngineName(String engineName)
Set the name of the script engine for evaluating the scripts (e.g.
|
void |
setGlobalBindings(Map<String,Object> globalBindings)
Set the globally scoped bindings on the underlying script engine manager,
shared by all scripts, as an alternative to script argument bindings.
|
void |
setLanguage(String language)
Set the name of the language meant for evaluating the scripts (e.g.
|
public StandardScriptEvaluator()
StandardScriptEvaluator.public StandardScriptEvaluator(ClassLoader classLoader)
StandardScriptEvaluator for the given class loader.classLoader - the class loader to use for script engine detectionpublic StandardScriptEvaluator(ScriptEngineManager scriptEngineManager)
StandardScriptEvaluator for the given JSR-223
ScriptEngineManager to obtain script engines from.scriptEngineManager - the ScriptEngineManager (or subclass thereof) to usepublic void setLanguage(String language)
This is effectively an alias for "engineName",
potentially (but not yet) providing common abbreviations for certain languages
beyond what the JSR-223 script engine factory exposes.
setEngineName(java.lang.String)public void setEngineName(String engineName)
setLanguage(java.lang.String)public void setGlobalBindings(Map<String,Object> globalBindings)
evaluate(ScriptSource, Map),
ScriptEngineManager.setBindings(Bindings),
SimpleBindingspublic void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAwarepublic Object evaluate(ScriptSource script)
ScriptEvaluatorevaluate in interface ScriptEvaluatorscript - the ScriptSource for the script to evaluatepublic Object evaluate(ScriptSource script, Map<String,Object> argumentBindings)
ScriptEvaluatorevaluate in interface ScriptEvaluatorscript - the ScriptSource for the script to evaluateargumentBindings - the key-value pairs to expose to the script,
typically as script variables (may be null or empty)protected ScriptEngine getScriptEngine(ScriptSource script)
script - the script to evaluatenull)