org.springframework.scripting.ScriptFactory implementation
for a Groovy script.
Typically used in combination with a
org.;
see the latter's javadoc for a configuration example.
Note
Spring 4.0 supports Groovy 1.8 and higher.
groovy.lang.GroovyClassLoader , org.springframework.scripting.support.ScriptFactoryPostProcessor
| Modifier and Type | Class and Description |
|---|---|
| private static class | GroovyScriptFactory.
Wrapper that holds a temporarily cached result object. |
| Modifier and Type | Field and Description |
|---|---|
| private GroovyScriptFactory. | |
| private CompilerConfiguration | |
| private GroovyClassLoader | |
| private GroovyObjectCustomizer | |
| private Class | |
| private final Object | |
| private Class | |
| private final String | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | GroovyScriptFactory(String
a locator that points to the source of the script.
Interpreted by the post-processor that actually creates the script. scriptSourceLocator)Create a new GroovyScriptFactory for the given script source. |
| public | GroovyScriptFactory(String
a locator that points to the source of the script.
Interpreted by the post-processor that actually creates the script. scriptSourceLocator, GroovyObjectCustomizer a customizer that can set a custom metaclass
or make other changes to the GroovyObject created by this factory
(may be groovyObjectCustomizer)null)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 | GroovyScriptFactory(String
a locator that points to the source of the script.
Interpreted by the post-processor that actually creates the script. scriptSourceLocator, CompilerConfiguration a custom compiler configuration to be applied
to the GroovyClassLoader (may be compilerConfiguration)null)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 | GroovyScriptFactory(String
a locator that points to the source of the script.
Interpreted by the post-processor that actually creates the script. scriptSourceLocator, CompilationCustomizer... one or more customizers to be applied to the
GroovyClassLoader compiler configuration 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. |
| Modifier and Type | Method and Description |
|---|---|
| protected GroovyClassLoader | buildGroovyClassLoader(ClassLoader
the ClassLoader to build a GroovyClassLoader for classLoader)Build a |
| protected Object | Returns: the result object (either an instance of the script class or the result of running the script instance)the source for the underlying script scriptSource, Class<?> the Groovy script class scriptClass)Instantiate the given Groovy script class and run it if necessary. |
| public GroovyClassLoader | |
| public Object | getScriptedObject(ScriptSource
the actual ScriptSource to retrieve
the script source text from (never scriptSource, Class<?>... null)the actual interfaces to expose,
including script interfaces as well as a generated config interface
(if applicable; may be actualInterfaces)null)Implements org. Loads and parses the Groovy script via the GroovyClassLoader. |
| public Class | getScriptedObjectType(ScriptSource
the actual ScriptSource to retrieve
the script source text from (never scriptSource)null)Implements org. Determine the type of the scripted Java object. |
| public Class | Returns: null alwaysImplements org. Groovy scripts determine their interfaces themselves, hence we don't need to explicitly expose interfaces here. |
| public String | getScriptSourceLocator()
Implements org. Return a locator that points to the source of the script. |
| public boolean | requiresConfigInterface()
Implements org. Groovy scripts do not need a config interface, since they expose their setters as public methods. |
| public boolean | requiresScriptedObjectRefresh(ScriptSource
the actual ScriptSource to retrieve
the script source text from (never scriptSource)null)Implements org. Determine whether a refresh is required (e.g. through
ScriptSource's |
| public void | setBeanClassLoader(ClassLoader
the owning class loader classLoader)Implements org. Callback that supplies the bean |
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Implements org. Callback that supplies the owning factory to a bean instance. |
| public String |
| cachedResult | back to summary |
|---|---|
| private GroovyScriptFactory. | |
| compilerConfiguration | back to summary |
|---|---|
| private CompilerConfiguration compilerConfiguration
| |
| groovyClassLoader | back to summary |
|---|---|
| private GroovyClassLoader groovyClassLoader
| |
| groovyObjectCustomizer | back to summary |
|---|---|
| private GroovyObjectCustomizer groovyObjectCustomizer
| |
| scriptClass | back to summary |
|---|---|
| private Class<?> scriptClass
| |
| scriptClassMonitor | back to summary |
|---|---|
| private final Object scriptClassMonitor | |
| scriptResultClass | back to summary |
|---|---|
| private Class<?> scriptResultClass
| |
| scriptSourceLocator | back to summary |
|---|---|
| private final String scriptSourceLocator | |
| wasModifiedForTypeCheck | back to summary |
|---|---|
| private boolean wasModifiedForTypeCheck | |
| GroovyScriptFactory | back to summary |
|---|---|
| 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.
| |
| GroovyScriptFactory | back to summary |
|---|---|
| public GroovyScriptFactory(String scriptSourceLocator, 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.
| |
| GroovyScriptFactory | back to summary |
|---|---|
| public GroovyScriptFactory(String scriptSourceLocator, 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 | back to summary |
|---|---|
| public GroovyScriptFactory(String scriptSourceLocator, 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.
| |
| buildGroovyClassLoader | back to summary |
|---|---|
| protected GroovyClassLoader buildGroovyClassLoader(ClassLoader classLoader) Build a
| |
| executeScript | back to summary |
|---|---|
| protected Object executeScript(ScriptSource scriptSource, Class<?> scriptClass) throws ScriptCompilationException Instantiate the given Groovy script class and run it if necessary.
| |
| getGroovyClassLoader | back to summary |
|---|---|
| public GroovyClassLoader getGroovyClassLoader() Return the GroovyClassLoader used by this script factory. | |
| getScriptedObject | back to summary |
|---|---|
| public Object getScriptedObject(ScriptSource scriptSource, Class<?>... actualInterfaces) throws IOException, ScriptCompilationException Implements org. Loads and parses the Groovy script via the GroovyClassLoader.
| |
| getScriptedObjectType | back to summary |
|---|---|
| public Class Implements org. Doc from org. 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.
| |
| getScriptInterfaces | back to summary |
|---|---|
| public Class Implements org. Groovy scripts determine their interfaces themselves, hence we don't need to explicitly expose interfaces here. | |
| getScriptSourceLocator | back to summary |
|---|---|
| public String getScriptSourceLocator() Implements org. Doc from org. 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..."). | |
| requiresConfigInterface | back to summary |
|---|---|
| public boolean requiresConfigInterface() Implements org. Groovy scripts do not need a config interface, since they expose their setters as public methods.
| |
| requiresScriptedObjectRefresh | back to summary |
|---|---|
| public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource) Implements org. Doc from org. Determine whether a refresh is required (e.g. through
ScriptSource's
| |
| setBeanClassLoader | back to summary |
|---|---|
| public void setBeanClassLoader(ClassLoader classLoader) Implements org. Doc from org. Callback that supplies the bean Invoked after the population of normal bean properties but
before an initialization callback such as
| |
| setBeanFactory | back to summary |
|---|---|
| public void setBeanFactory(BeanFactory beanFactory) Implements org. Doc from org. 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
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Access | Constructor and Description |
|---|---|
| public |
| object | back to summary |
|---|---|
| public final Object object
| |
| CachedResultHolder | back to summary |
|---|---|
| public CachedResultHolder(Object object) | |