Class BshScriptEvaluator
java.lang.Object
org.springframework.scripting.bsh.BshScriptEvaluator
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,ScriptEvaluator
BeanShell-based implementation of Spring's
ScriptEvaluator
strategy interface.- Since:
- 4.0
- Author:
- Juergen Hoeller
- See Also:
-
Interpreter.eval(String)
-
Constructor Summary
ConstructorDescriptionConstruct a new BshScriptEvaluator.BshScriptEvaluator
(ClassLoader classLoader) Construct a new BshScriptEvaluator. -
Method Summary
Modifier and TypeMethodDescriptionevaluate
(ScriptSource script) Evaluate the given script.evaluate
(ScriptSource script, Map<String, Object> arguments) Evaluate the given script with the given arguments.void
setBeanClassLoader
(ClassLoader classLoader) Callback that supplies the beanclass loader
to a bean instance.
-
Constructor Details
-
BshScriptEvaluator
public BshScriptEvaluator()Construct a new BshScriptEvaluator. -
BshScriptEvaluator
Construct a new BshScriptEvaluator.- Parameters:
classLoader
- the ClassLoader to use for theInterpreter
-
-
Method Details
-
setBeanClassLoader
Description copied from interface:BeanClassLoaderAware
Callback that supplies the beanclass loader
to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean's
InitializingBean.afterPropertiesSet()
method or a custom init-method.- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
- Parameters:
classLoader
- the owning class loader
-
evaluate
Description copied from interface:ScriptEvaluator
Evaluate the given script.- Specified by:
evaluate
in interfaceScriptEvaluator
- Parameters:
script
- the ScriptSource for the script to evaluate- Returns:
- the return value of the script, if any
-
evaluate
Description copied from interface:ScriptEvaluator
Evaluate the given script with the given arguments.- Specified by:
evaluate
in interfaceScriptEvaluator
- Parameters:
script
- the ScriptSource for the script to evaluatearguments
- the key-value pairs to expose to the script, typically as script variables (may benull
or empty)- Returns:
- the return value of the script, if any
-