org.schmant
Interface ScriptExecutor

All Known Implementing Classes:
GroovyExecutor, JRubyExecutor, JythonExecutor, MozillaRhinoExecutor, SunJavaScriptExecutor

public interface ScriptExecutor

This interface defines something that Launcher can use to run a build script with. The launcher class looks up a ScriptExecutorFactory that it uses to create a script executor.

A script executor often registers itself with different Schmant extension points to be able to run closures, flatten lists, etc. See init(NamedReadableFile, LauncherSettings, Report).

Since:
1.1
Author:
Karl Gustafsson
See Also:
Launcher, ScriptExecutorFactory

Method Summary
 void init(NamedReadableFile scriptFile, LauncherSettings ls, Report r)
          Initialize the script executor.
 void runDefaultPreparationScript(Report r)
          Run the default environment preparation script.
 void runPreparationScript(File script, Report r)
          Run the preparation script in the file.
 Object runWithDefaultWrapperScript()
          Run the script using the default wrapper script, if any.
 void setBindings(Bindings bnd, int scope)
          Set the variables stored in the bindings in the specified scope.
 void setGlobalVariable(String name, Object value)
          Set the value of a global variable in the script.
 void tearDown()
          Tear down the script executor when Schmant terminates.
 

Method Detail

init

void init(NamedReadableFile scriptFile,
          LauncherSettings ls,
          Report r)
          throws IOException
Initialize the script executor. This method is responsible for registering the script executor with different Schmant extension points such as FlatteningList.registerDecorator(org.schmant.support.util.FlatteningListDecorator), TaskExecutorThreadFactory.registerThreadContextInitializer(org.schmant.run.ThreadContextInitializer) and ClosureSupport.registerClosureRunner(org.schmant.lang.ClosureRunner).

Parameters:
scriptFile - The script file that is run.
ls - The command line settings.
r - The report.
Throws:
IOException
See Also:
tearDown()

tearDown

void tearDown()
Tear down the script executor when Schmant terminates. This method should deregister the script executor from the extension points that init(NamedReadableFile, LauncherSettings, Report) registered with.


setGlobalVariable

void setGlobalVariable(String name,
                       Object value)
Set the value of a global variable in the script.

Parameters:
name - The name of the variable.
value - The variable value.

setBindings

void setBindings(Bindings bnd,
                 int scope)
Set the variables stored in the bindings in the specified scope. For now the scope is always global.

Parameters:
bnd - The bindings containing a map of variables to set.
scope - The scope to set the variables in. See ScriptContext. For now this parameter can be ignored and all variables set to the global scope.

runDefaultPreparationScript

void runDefaultPreparationScript(Report r)
                                 throws SchmantException,
                                        IOException
Run the default environment preparation script. This should register global functions that the build script may use.

Parameters:
r - A report to log to.
Throws:
SchmantException - On errors.
WrappedIOException - On I/O errors.
IOException

runPreparationScript

void runPreparationScript(File script,
                          Report r)
                          throws SchmantException,
                                 IOException
Run the preparation script in the file.

Parameters:
script - The script file.
r - A report to log to.
Throws:
SchmantException - On errors.
WrappedIOException - On I/O errors.
IOException

runWithDefaultWrapperScript

Object runWithDefaultWrapperScript()
                                   throws SchmantException,
                                          IOException
Run the script using the default wrapper script, if any.

Returns:
The value returned from the script.
Throws:
SchmantException - On errors.
WrappedIOException - On I/O errors.
IOException