Top Description Fields Constructors Methods
org.springframework.scripting.groovy

public Class GroovyScriptEvaluator

extends Object
implements ScriptEvaluator, BeanClassLoaderAware
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.Aware, org.springframework.scripting.ScriptEvaluator
Imports
java.io.IOException, java.util.Map, groovy.lang.Binding, .GroovyRuntimeException, .GroovyShell, org.codehaus.groovy.control.CompilerConfiguration, org.codehaus.groovy.control.customizers.CompilationCustomizer, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.lang.Nullable, org.springframework.scripting.ScriptCompilationException, .ScriptEvaluator, .ScriptSource, org.springframework.scripting.support.ResourceScriptSource

Groovy-based implementation of Spring's ScriptEvaluator strategy interface.
Author
Juergen Hoeller
Since
4.0
See Also
GroovyShell#evaluate(String, String)

Field Summary

Modifier and TypeField and Description
private ClassLoader
private CompilerConfiguration

Constructor Summary

AccessConstructor and Description
public
GroovyScriptEvaluator()

Construct a new GroovyScriptEvaluator.

public
GroovyScriptEvaluator(ClassLoader
the ClassLoader to use as a parent for the GroovyShell
classLoader
)

Construct a new GroovyScriptEvaluator.

Method Summary

Modifier and TypeMethod and Description
public Object
evaluate(ScriptSource
the ScriptSource for the script to evaluate
script
)

Implements org.springframework.scripting.ScriptEvaluator.evaluate.

Evaluate the given script.
public Object
evaluate(ScriptSource
the ScriptSource for the script to evaluate
script
,
Map<String, Object>
the key-value pairs to expose to the script, typically as script variables (may be null or empty)
arguments
)

Implements org.springframework.scripting.ScriptEvaluator.evaluate.

Evaluate the given script with the given arguments.
public CompilerConfiguration
getCompilerConfiguration()

Return this evaluator's compiler configuration (never null).

public void
setBeanClassLoader(ClassLoader
the owning class loader
classLoader
)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class loader to a bean instance.
public void
setCompilationCustomizers(CompilationCustomizer... compilationCustomizers)

Set one or more customizers to be applied to this evaluator's compiler configuration.

public void
setCompilerConfiguration(CompilerConfiguration compilerConfiguration)

Set a custom compiler configuration for this evaluator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoaderback to summary
private ClassLoader classLoader
Annotations
@Nullable
compilerConfigurationback to summary
private CompilerConfiguration compilerConfiguration

Constructor Detail

GroovyScriptEvaluatorback to summary
public GroovyScriptEvaluator()

Construct a new GroovyScriptEvaluator.

GroovyScriptEvaluatorback to summary
public GroovyScriptEvaluator(ClassLoader classLoader)

Construct a new GroovyScriptEvaluator.

Parameters
classLoader:ClassLoader

the ClassLoader to use as a parent for the GroovyShell

Method Detail

evaluateback to summary
public Object evaluate(ScriptSource script)

Implements org.springframework.scripting.ScriptEvaluator.evaluate.

Doc from org.springframework.scripting.ScriptEvaluator.evaluate.

Evaluate the given script.

Parameters
script:ScriptSource

the ScriptSource for the script to evaluate

Returns:Object

the return value of the script, if any

Annotations
@Override
@Nullable
evaluateback to summary
public Object evaluate(ScriptSource script, Map<String, Object> arguments)

Implements org.springframework.scripting.ScriptEvaluator.evaluate.

Doc from org.springframework.scripting.ScriptEvaluator.evaluate.

Evaluate the given script with the given arguments.

Parameters
script:ScriptSource

the ScriptSource for the script to evaluate

arguments:Map<String, Object>

the key-value pairs to expose to the script, typically as script variables (may be null or empty)

Returns:Object

the return value of the script, if any

Annotations
@Override
@Nullable
getCompilerConfigurationback to summary
public CompilerConfiguration getCompilerConfiguration()

Return this evaluator's compiler configuration (never null).

Since
4.3.3
See Also
setCompilerConfiguration
setBeanClassLoaderback to summary
public void setBeanClassLoader(ClassLoader classLoader)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Doc from org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class 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.

Parameters
classLoader:ClassLoader

the owning class loader

Annotations
@Override
setCompilationCustomizersback to summary
public void setCompilationCustomizers(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
setCompilerConfiguration
setCompilerConfigurationback to summary
public void setCompilerConfiguration(CompilerConfiguration compilerConfiguration)

Set a custom compiler configuration for this evaluator.

Since
4.3.3
See Also
setCompilationCustomizers