The Spring Framework

org.springframework.scripting
Interface ScriptFactory

All Known Implementing Classes:
BshScriptFactory, GroovyScriptFactory, JRubyScriptFactory

public interface ScriptFactory

Script definition interface, encapsulating the configuration of a specific script as well as a factory method for creating the actual scripted Java Object.

Since:
2.0
Author:
Juergen Hoeller, Rob Harrop

Method Summary
 Object getScriptedObject(ScriptSource actualScriptSource, Class[] actualInterfaces)
          Factory method for creating a scripted Java object.
 Class[] getScriptInterfaces()
          Return the business interfaces that the script is supposed to implement.
 String getScriptSourceLocator()
          Return a locator that points to the source of the script.
 boolean requiresConfigInterface()
          Return whether the script requires a config interface to be generated for it.
 

Method Detail

getScriptSourceLocator

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

See Also:
ScriptFactoryPostProcessor.convertToScriptSource(java.lang.String, org.springframework.core.io.ResourceLoader), ResourceLoader

getScriptInterfaces

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


requiresConfigInterface

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

See Also:
getScriptInterfaces()

getScriptedObject

Object getScriptedObject(ScriptSource actualScriptSource,
                         Class[] actualInterfaces)
                         throws IOException,
                                ScriptCompilationException
Factory method for creating a scripted Java object.

Parameters:
actualScriptSource - 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, can be null)
Returns:
the scripted Java object
Throws:
IOException - if script retrieval failed
ScriptCompilationException - if script compilation failed

The Spring Framework

Copyright © 2002-2006 The Spring Framework.