Top Description Methods
org.springframework.scripting

public Interface ScriptFactory

Known Direct Implementers
org.springframework.scripting.bsh.BshScriptFactory, org.springframework.scripting.groovy.GroovyScriptFactory, org.springframework.scripting.support.StandardScriptFactory
Imports
java.io.IOException, org.springframework.lang.Nullable

Script definition interface, encapsulating the configuration of a specific script as well as a factory method for creating the actual scripted Java Object.
Authors
Juergen Hoeller, Rob Harrop
Since
2.0
See Also
getScriptSourceLocator, getScriptedObject

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the scripted Java object
getScriptedObject
(ScriptSource
the actual ScriptSource to retrieve the script source text from (never null)
scriptSource
,
Class<?>...
the actual interfaces to expose, including script interfaces as well as a generated config interface (if applicable; may be null)
actualInterfaces
)

Factory method for creating the scripted Java object.

public Class<?>

Returns:

the type of the scripted Java object, or null if none could be determined
getScriptedObjectType
(ScriptSource
the actual ScriptSource to retrieve the script source text from (never null)
scriptSource
)

Determine the type of the scripted Java object.

public Class<?>[]

Returns:

the interfaces for the script
getScriptInterfaces
()

Return the business interfaces that the script is supposed to implement.

public String

Returns:

the script source locator
getScriptSourceLocator
()

Return a locator that points to the source of the script.

public boolean

Returns:

whether the script requires a generated config interface
requiresConfigInterface
()

Return whether the script requires a config interface to be generated for it.

public boolean

Returns:

whether a fresh getScriptedObject call is required
requiresScriptedObjectRefresh
(ScriptSource
the actual ScriptSource to retrieve the script source text from (never null)
scriptSource
)

Determine whether a refresh is required (e.g. through ScriptSource's isModified() method).

Method Detail

getScriptedObjectback to summary
public Object getScriptedObject(ScriptSource scriptSource, Class<?>... actualInterfaces) throws IOException, ScriptCompilationException

Factory method for creating 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.

Parameters
scriptSource:ScriptSource

the actual ScriptSource to retrieve the script source text from (never null)

actualInterfaces:Class<?>[]

the actual interfaces to expose, including script interfaces as well as a generated config interface (if applicable; may be null)

Returns:Object

the scripted Java object

Annotations
@Nullable
Exceptions
IOException:
if script retrieval failed
ScriptCompilationException:
if script compilation failed
getScriptedObjectTypeback to summary
public Class<?> getScriptedObjectType(ScriptSource scriptSource) throws IOException, ScriptCompilationException

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.

Parameters
scriptSource:ScriptSource

the actual ScriptSource to retrieve the script source text from (never null)

Returns:Class<?>

the type of the scripted Java object, or null if none could be determined

Annotations
@Nullable
Exceptions
IOException:
if script retrieval failed
ScriptCompilationException:
if script compilation failed
Since
2.0.3
getScriptInterfacesback to summary
public Class<?>[] getScriptInterfaces()

Return the business interfaces that the script is supposed to implement.

Can return null if the script itself determines its Java interfaces (such as in the case of Groovy).

Returns:Class<?>[]

the interfaces for the script

Annotations
@Nullable
getScriptSourceLocatorback to summary
public String getScriptSourceLocator()

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...").

Returns:String

the script source locator

See Also
org.springframework.scripting.support.ScriptFactoryPostProcessor#convertToScriptSource, org.springframework.core.io.ResourceLoader
requiresConfigInterfaceback to summary
public boolean requiresConfigInterface()

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 getScriptInterfaces().

Returns:boolean

whether the script requires a generated config interface

See Also
getScriptInterfaces()
requiresScriptedObjectRefreshback to summary
public boolean requiresScriptedObjectRefresh(ScriptSource scriptSource)

Determine whether a refresh is required (e.g. through ScriptSource's isModified() method).

Parameters
scriptSource:ScriptSource

the actual ScriptSource to retrieve the script source text from (never null)

Returns:boolean

whether a fresh getScriptedObject call is required

Since
2.5.2
See Also
ScriptSource#isModified()