java.lang.Object | |
↳ | org.springframework.scripting.groovy.GroovyScriptFactory |
ScriptFactory
implementation
for a Groovy script.
Typically used in combination with a
ScriptFactoryPostProcessor
;
see the latter's javadoc} for a configuration example.
ScriptFactoryPostProcessor
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new GroovyScriptFactory for the given script source.
| |||||||||||
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.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the GroovyClassLoader used by this script factory.
| |||||||||||
Groovy scripts determine their interfaces themselves,
hence we don't need to explicitly expose interfaces here.
| |||||||||||
Return a locator that points to the source of the script.
| |||||||||||
Loads and parses the Groovy script via the GroovyClassLoader.
| |||||||||||
Determine the type of the scripted Java object.
| |||||||||||
Groovy scripts do not need a config interface,
since they expose their setters as public methods.
| |||||||||||
Determine whether a refresh is required (e.g.
| |||||||||||
Callback that supplies the bean
class loader to
a bean instance. | |||||||||||
Callback that supplies the owning factory to a bean instance.
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Instantiate the given Groovy script class and run it if necessary.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanClassLoaderAware
| |||||||||||
From interface
org.springframework.beans.factory.BeanFactoryAware
| |||||||||||
From interface
org.springframework.scripting.ScriptFactory
|
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.
scriptSourceLocator | a locator that points to the source of the script. Interpreted by the post-processor that actually creates the script. |
---|
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.
We don't need to specify script interfaces here, since a Groovy script defines its Java interfaces itself.
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 )
|
Return the GroovyClassLoader used by this script factory.
Groovy scripts determine their interfaces themselves, hence we don't need to explicitly expose interfaces here.
null
always
Return a locator that points to the source of the script. Interpreted by the post-processor that actually creates the script.
Typical supported locators are Spring resource locations (such as "file:C:/myScript.bsh" or "classpath:myPackage/myScript.bsh") and inline scripts ("inline:myScriptText...").
Loads and parses the Groovy script via the GroovyClassLoader.
scriptSource | the actual ScriptSource to retrieve
the script source text from (never null ) |
---|---|
actualInterfaces | the actual interfaces to expose,
including script interfaces as well as a generated config interface
(if applicable; may be null ) |
Determine the type of the scripted Java object.
Implementations are encouraged to cache script metadata such as a generated script class. Note that this method may be invoked concurrently and must be implemented in a thread-safe fashion.
scriptSource | the actual ScriptSource to retrieve
the script source text from (never null ) |
---|
null
if none could be determinedGroovy scripts do not need a config interface, since they expose their setters as public methods.
Determine whether a refresh is required (e.g. through
ScriptSource's isModified()
method).
scriptSource | the actual ScriptSource to retrieve
the script source text from (never null ) |
---|
getScriptedObject(ScriptSource, Class[])
call is requiredCallback 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
afterPropertiesSet()
method or a custom init-method.
classLoader | the owning class loader; may be null in
which case a default ClassLoader must be used, for example
the ClassLoader obtained via
getDefaultClassLoader()
|
---|
Callback that supplies the owning factory to a bean instance.
Invoked after the population of normal bean properties
but before an initialization callback such as
afterPropertiesSet()
or a custom init-method.
beanFactory | owning BeanFactory (never null ).
The bean can immediately call methods on the factory. |
---|
BeansException |
---|
Instantiate the given Groovy script class and run it if necessary.
scriptSource | the source for the underlying script |
---|---|
scriptClass | the Groovy script class |
ScriptCompilationException | in case of instantiation failure |
---|