spring-framework / org.springframework.scripting.groovy / GroovyScriptFactory

GroovyScriptFactory

open class GroovyScriptFactory : ScriptFactory, BeanFactoryAware, BeanClassLoaderAware

org.springframework.scripting.ScriptFactory implementation for a Groovy script.

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

Note: Spring 4.0 supports Groovy 1.8 and higher.

Author
Juergen Hoeller

Author
Rob Harrop

Author
Rod Johnson

Since
2.0

See Also
groovy.lang.GroovyClassLoaderorg.springframework.scripting.support.ScriptFactoryPostProcessor

Constructors

<init>

GroovyScriptFactory(scriptSourceLocator: String)

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.

GroovyScriptFactory(scriptSourceLocator: String, groovyObjectCustomizer: GroovyObjectCustomizer)
GroovyScriptFactory(scriptSourceLocator: String, 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.

GroovyScriptFactory(scriptSourceLocator: String, vararg compilationCustomizers: CompilationCustomizer)

Create a new GroovyScriptFactory for the given script source, specifying a strategy interface that can customize Groovy's compilation process within the underlying GroovyClassLoader.

Functions

getGroovyClassLoader

open fun getGroovyClassLoader(): GroovyClassLoader

Return the GroovyClassLoader used by this script factory.

getScriptInterfaces

open fun getScriptInterfaces(): Array<Class<*>>

Groovy scripts determine their interfaces themselves, hence we don't need to explicitly expose interfaces here.

getScriptSourceLocator

open fun getScriptSourceLocator(): String

getScriptedObject

open fun getScriptedObject(scriptSource: ScriptSource, vararg actualInterfaces: Class<*>): Any

Loads and parses the Groovy script via the GroovyClassLoader.

getScriptedObjectType

open fun getScriptedObjectType(scriptSource: ScriptSource): Class<*>

requiresConfigInterface

open fun requiresConfigInterface(): Boolean

Groovy scripts do not need a config interface, since they expose their setters as public methods.

requiresScriptedObjectRefresh

open fun requiresScriptedObjectRefresh(scriptSource: ScriptSource): Boolean

setBeanClassLoader

open fun setBeanClassLoader(classLoader: ClassLoader): Unit

setBeanFactory

open fun setBeanFactory(beanFactory: BeanFactory): Unit

toString

open fun toString(): String