Class GroovyScriptEvaluator
java.lang.Object
org.springframework.scripting.groovy.GroovyScriptEvaluator
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,ScriptEvaluator
Groovy-based implementation of Spring's
ScriptEvaluator
strategy interface.- Since:
- 4.0
- Author:
- Juergen Hoeller
- See Also:
-
GroovyShell.evaluate(String, String)
-
Constructor Summary
ConstructorDescriptionConstruct a new GroovyScriptEvaluator.GroovyScriptEvaluator
(ClassLoader classLoader) Construct a new GroovyScriptEvaluator. -
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.org.codehaus.groovy.control.CompilerConfiguration
Return this evaluator's compiler configuration (nevernull
).void
setBeanClassLoader
(ClassLoader classLoader) Callback that supplies the beanclass loader
to a bean instance.void
setCompilationCustomizers
(org.codehaus.groovy.control.customizers.CompilationCustomizer... compilationCustomizers) Set one or more customizers to be applied to this evaluator's compiler configuration.void
setCompilerConfiguration
(org.codehaus.groovy.control.CompilerConfiguration compilerConfiguration) Set a custom compiler configuration for this evaluator.
-
Constructor Details
-
GroovyScriptEvaluator
public GroovyScriptEvaluator()Construct a new GroovyScriptEvaluator. -
GroovyScriptEvaluator
Construct a new GroovyScriptEvaluator.- Parameters:
classLoader
- the ClassLoader to use as a parent for theGroovyShell
-
-
Method Details
-
setCompilerConfiguration
public void setCompilerConfiguration(@Nullable org.codehaus.groovy.control.CompilerConfiguration compilerConfiguration) Set a custom compiler configuration for this evaluator.- Since:
- 4.3.3
- See Also:
-
getCompilerConfiguration
public org.codehaus.groovy.control.CompilerConfiguration getCompilerConfiguration()Return this evaluator's compiler configuration (nevernull
).- Since:
- 4.3.3
- See Also:
-
setCompilationCustomizers
public void setCompilationCustomizers(org.codehaus.groovy.control.customizers.CompilationCustomizer... compilationCustomizers) Set one or more customizers to be applied to this evaluator's compiler configuration.Note that this modifies the shared compiler configuration held by this evaluator.
- Since:
- 4.3.3
- See Also:
-
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
-