public class StandardScriptEvaluator extends java.lang.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(java.lang.ClassLoader classLoader)
Construct a new StandardScriptEvaluator.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
evaluate(ScriptSource script)
Evaluate the given script.
|
java.lang.Object |
evaluate(ScriptSource script,
java.util.Map<java.lang.String,java.lang.Object> arguments)
Evaluate the given script with the given arguments.
|
protected javax.script.ScriptEngine |
getScriptEngine(ScriptSource script)
Obtain the JSR-223 ScriptEngine to use for the given script.
|
void |
setBeanClassLoader(java.lang.ClassLoader classLoader) |
void |
setLanguage(java.lang.String language)
Set the name of language meant for evaluation the scripts (e.g.
|
public StandardScriptEvaluator()
public StandardScriptEvaluator(java.lang.ClassLoader classLoader)
classLoader
- the class loader to use for script engine detectionpublic void setBeanClassLoader(java.lang.ClassLoader classLoader)
setBeanClassLoader
in interface org.springframework.beans.factory.BeanClassLoaderAware
public void setLanguage(java.lang.String language)
public java.lang.Object evaluate(ScriptSource script)
ScriptEvaluator
evaluate
in interface ScriptEvaluator
script
- the ScriptSource for the script to evaluatepublic java.lang.Object evaluate(ScriptSource script, java.util.Map<java.lang.String,java.lang.Object> arguments)
ScriptEvaluator
evaluate
in interface ScriptEvaluator
script
- the ScriptSource for the script to evaluatearguments
- the key-value pairs to expose to the script,
typically as script variables. May be null
.protected javax.script.ScriptEngine getScriptEngine(ScriptSource script)
script
- the script to evaluatenull
)