org.springframework.scripting.ScriptFactory implementation based
on the JSR-223 script engine abstraction (as included in Java).
Supports JavaScript, Groovy, JRuby, and other JSR-223 compliant engines.
Typically used in combination with a
org.;
see the latter's javadoc for a configuration example.
ScriptFactoryPostProcessor
| Modifier and Type | Field and Description |
|---|---|
| private ClassLoader | |
| private volatile ScriptEngine | |
| private final String | |
| private final Class | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public | StandardScriptFactory(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 StandardScriptFactory for the given script source. |
| public | StandardScriptFactory(String
a locator that points to the source of the script.
Interpreted by the post-processor that actually creates the script. scriptSourceLocator, Class<?>... the Java interfaces that the scripted object
is supposed to implement scriptInterfaces)Create a new StandardScriptFactory for the given script source. |
| public | StandardScriptFactory(String
the name of the JSR-223 ScriptEngine to use
(explicitly given instead of inferred from the script source) scriptEngineName, 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 StandardScriptFactory for the given script source. |
| public | StandardScriptFactory(String
the name of the JSR-223 ScriptEngine to use
(explicitly given instead of inferred from the script source) scriptEngineName, String a locator that points to the source of the script.
Interpreted by the post-processor that actually creates the script. scriptSourceLocator, Class<?>... the Java interfaces that the scripted object
is supposed to implement scriptInterfaces)Create a new StandardScriptFactory for the given script source. |
| Modifier and Type | Method and Description |
|---|---|
| protected Object | |
| protected Object | |
| 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. Load and parse the script via JSR-223's ScriptEngine. |
| 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 | getScriptInterfaces()
Implements org. Return the business interfaces that the script is supposed to implement. |
| public String | getScriptSourceLocator()
Implements org. Return a locator that points to the source of the script. |
| public boolean | requiresConfigInterface()
Implements org. Return whether the script requires a config interface to be generated for it. |
| 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 |
| protected ScriptEngine | |
| public void | setBeanClassLoader(ClassLoader
the owning class loader classLoader)Implements org. Callback that supplies the bean |
| public String |
| beanClassLoader | back to summary |
|---|---|
| private ClassLoader beanClassLoader
| |
| scriptEngine | back to summary |
|---|---|
| private volatile ScriptEngine scriptEngine
| |
| scriptEngineName | back to summary |
|---|---|
| private final String scriptEngineName
| |
| scriptInterfaces | back to summary |
|---|---|
| private final Class<?>[] scriptInterfaces
| |
| scriptSourceLocator | back to summary |
|---|---|
| private final String scriptSourceLocator | |
| StandardScriptFactory | back to summary |
|---|---|
| public StandardScriptFactory(String scriptSourceLocator) Create a new StandardScriptFactory for the given script source.
| |
| StandardScriptFactory | back to summary |
|---|---|
| public StandardScriptFactory(String scriptSourceLocator, Class<?>... scriptInterfaces) Create a new StandardScriptFactory for the given script source. | |
| StandardScriptFactory | back to summary |
|---|---|
| public StandardScriptFactory(String scriptEngineName, String scriptSourceLocator) Create a new StandardScriptFactory for the given script source. | |
| StandardScriptFactory | back to summary |
|---|---|
| public StandardScriptFactory(String scriptEngineName, String scriptSourceLocator, Class<?>... scriptInterfaces) Create a new StandardScriptFactory for the given script source.
| |
| adaptToInterfaces | back to summary |
|---|---|
protected Object adaptToInterfaces(Object script, ScriptSource scriptSource, Class<?>... actualInterfaces)
| |
| evaluateScript | back to summary |
|---|---|
| protected Object evaluateScript(ScriptSource scriptSource) | |
| getScriptedObject | back to summary |
|---|---|
| public Object getScriptedObject(ScriptSource scriptSource, Class<?>... actualInterfaces) throws IOException, ScriptCompilationException Implements org. Load and parse the script via JSR-223's ScriptEngine.
| |
| 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. Doc from org. Return the business interfaces that the script is supposed to implement. Can return | |
| 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. Doc from org. Return whether the script requires a config interface to be
generated for it. This is typically the case for scripts that
do not determine Java signatures themselves, with no appropriate
config interface specified in
| |
| 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
| |
| retrieveScriptEngine | back to summary |
|---|---|
protected ScriptEngine retrieveScriptEngine(ScriptSource scriptSource)
| |
| 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
| |
| 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- | |