Package org.springframework.scripting.groovy

# Class GroovyScriptEvaluator

java.lang.Object
org.springframework.scripting.groovy.GroovyScriptEvaluator

All Implemented Interfaces:
  `org.springframework.beans.factory.Aware`, `org.springframework.beans.factory.BeanClassLoaderAware`, `ScriptEvaluator`

public class GroovyScriptEvaluator extends Object implements ScriptEvaluator, org.springframework.beans.factory.BeanClassLoaderAware
Groovy-based implementation of Spring's `ScriptEvaluator` strategy interface.

Since:
  4.0
Author:
  Juergen Hoeller
See Also:
  - `GroovyShell.evaluate(String, String)`

## Constructor Summary

Constructors
Constructor
Description
`GroovyScriptEvaluator()`
Construct a new GroovyScriptEvaluator.
`GroovyScriptEvaluator(ClassLoader classLoader)`
Construct a new GroovyScriptEvaluator.

## Method Summary

Modifier and Type
Method
Description
`Object`
`evaluate(ScriptSource script)`
Evaluate the given script.
`Object`
`evaluate(ScriptSource script, Map<String,Object> arguments)`
Evaluate the given script with the given arguments.
`org.codehaus.groovy.control.CompilerConfiguration`
`getCompilerConfiguration()`
Return this evaluator's compiler configuration (never `null`).
`void`
`setBeanClassLoader(ClassLoader classLoader)`
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### GroovyScriptEvaluator

public GroovyScriptEvaluator()
Construct a new GroovyScriptEvaluator.

### GroovyScriptEvaluator

public GroovyScriptEvaluator(@Nullable ClassLoader classLoader)
Construct a new GroovyScriptEvaluator.

Parameters:
  `classLoader` - the ClassLoader to use as a parent for the `GroovyShell`

## 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:
  - `setCompilationCustomizers(org.codehaus.groovy.control.customizers.CompilationCustomizer...)`

### getCompilerConfiguration

public org.codehaus.groovy.control.CompilerConfiguration getCompilerConfiguration()
Return this evaluator's compiler configuration (never `null`).

Since:
  4.3.3
See Also:
  - `setCompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration)`

### 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:
  - `setCompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration)`

### setBeanClassLoader

public void setBeanClassLoader(ClassLoader classLoader)

Specified by:
  `setBeanClassLoader` in interface `org.springframework.beans.factory.BeanClassLoaderAware`

### evaluate

@Nullable public Object evaluate(ScriptSource script)
Description copied from interface: `ScriptEvaluator`
Evaluate the given script.

Specified by:
  `evaluate` in interface `ScriptEvaluator`
Parameters:
  `script` - the ScriptSource for the script to evaluate
Returns:
  the return value of the script, if any

### evaluate

@Nullable public Object evaluate(ScriptSource script, @Nullable Map<String,Object> arguments)
Description copied from interface: `ScriptEvaluator`
Evaluate the given script with the given arguments.

Specified by:
  `evaluate` in interface `ScriptEvaluator`
Parameters:
  `script` - the ScriptSource for the script to evaluate
  `arguments` - the key-value pairs to expose to the script, typically as script variables (may be `null` or empty)
Returns:
  the return value of the script, if any