Class GroovyScriptFactory

java.lang.Object
org.springframework.scripting.groovy.GroovyScriptFactory
All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryAware, ScriptFactory

public class GroovyScriptFactory extends Object implements ScriptFactory, BeanFactoryAware, BeanClassLoaderAware
ScriptFactory implementation for a Groovy script.

Typically used in combination with a ScriptFactoryPostProcessor; see the latter's javadoc for a configuration example.

Note: Spring 4.0 supports Groovy 1.8 and higher.

Since:
2.0
Author:
Juergen Hoeller, Rob Harrop, Rod Johnson
See Also:
  • Constructor Details

    • GroovyScriptFactory

      public GroovyScriptFactory(String scriptSourceLocator)
      Create a new GroovyScriptFactory for the given script source.

      We don't need to specify script interfaces here, since a Groovy script defines its Java interfaces itself.

      Parameters:
      scriptSourceLocator - a locator that points to the source of the script. Interpreted by the post-processor that actually creates the script.
    • GroovyScriptFactory

      public GroovyScriptFactory(String scriptSourceLocator, @Nullable GroovyObjectCustomizer groovyObjectCustomizer)
      Create a new GroovyScriptFactory for the given script source, specifying a strategy interface that can create a custom MetaClass to supply missing methods and otherwise change the behavior of the object.
      Parameters:
      scriptSourceLocator - a locator that points to the source of the script. Interpreted by the post-processor that actually creates the script.
      groovyObjectCustomizer - a customizer that can set a custom metaclass or make other changes to the GroovyObject created by this factory (may be null)
      See Also:
    • GroovyScriptFactory

      public GroovyScriptFactory(String scriptSourceLocator, @Nullable org.codehaus.groovy.control.CompilerConfiguration compilerConfiguration)
      Create a new GroovyScriptFactory for the given script source, specifying a strategy interface that can create a custom MetaClass to supply missing methods and otherwise change the behavior of the object.
      Parameters:
      scriptSourceLocator - a locator that points to the source of the script. Interpreted by the post-processor that actually creates the script.
      compilerConfiguration - a custom compiler configuration to be applied to the GroovyClassLoader (may be null)
      Since:
      4.3.3
      See Also:
      • GroovyClassLoader(ClassLoader, CompilerConfiguration)
    • GroovyScriptFactory

      public GroovyScriptFactory(String scriptSourceLocator, org.codehaus.groovy.control.customizers.CompilationCustomizer... compilationCustomizers)
      Create a new GroovyScriptFactory for the given script source, specifying a strategy interface that can customize Groovy's compilation process within the underlying GroovyClassLoader.
      Parameters:
      scriptSourceLocator - a locator that points to the source of the script. Interpreted by the post-processor that actually creates the script.
      compilationCustomizers - one or more customizers to be applied to the GroovyClassLoader compiler configuration
      Since:
      4.3.3
      See Also:
      • CompilerConfiguration.addCompilationCustomizers(org.codehaus.groovy.control.customizers.CompilationCustomizer...)
      • ImportCustomizer
  • Method Details