Class ScriptRunner
java.lang.Object
org.apache.tools.ant.util.ScriptRunnerBase
org.apache.tools.ant.util.optional.ScriptRunner
- Direct Known Subclasses:
ScriptRunner
This class is used to run BSF scripts
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionevaluateScript(String execName) Evaluate the script.voidexecuteScript(String execName) Do the work.Get the name of the manager prefix.booleanCheck if bsf supports the language.Methods inherited from class ScriptRunnerBase
addBean, addBeans, addText, bindToComponent, bindToComponentMinimum, checkLanguage, clearScript, getBeans, getCompiled, getKeepEngine, getLanguage, getProject, getScript, getScriptClassLoader, loadResource, loadResources, replaceContextLoader, restoreContextLoader, setCompiled, setEncoding, setKeepEngine, setLanguage, setProject, setScriptClassLoader, setSrcModifier and TypeMethodDescriptionvoidAdd a single object into the script context.voidAdd a list of named objects to the list to be exported to the scriptvoidSet the script text.voidbindToComponent(ProjectComponent component) Bind the runner to a project component.voidbindToComponentMinimum(ProjectComponent component) Bind the runner to a project component.protected voidCheck if the language attribute is set.voidClear the current script text content.getBeans()Get the beans used for the script.final booleanGet the compiled attribute.booleanGet the keep engine attribute.Get the script languageGet the project for this runner.Get the current script text content.protected ClassLoaderGet the classloader used to load the script engine.voidloadResource(Resource sourceResource) Add a resource to the source list.voidloadResources(ResourceCollection collection) Add all resources in a resource collection to the source list.protected ClassLoaderReplace the current context classloader with the script context classloader.protected voidrestoreContextLoader(ClassLoader origLoader) Restore the context loader with the original context classloader.final voidsetCompiled(boolean compiled) Whether to use script compilation if available.voidsetEncoding(String encoding) Set encoding of the script from an external file; optional.voidsetKeepEngine(boolean keepEngine) Whether to keep the script engine between calls.voidsetLanguage(String language) Defines the language (required).voidsetProject(Project project) Set the project for this runner.voidsetScriptClassLoader(ClassLoader classLoader) Set the script classloader.voidLoad the script from an external file; optional.
-
Constructor Details
-
ScriptRunner
public ScriptRunner()
-
-
Method Details
-
getManagerName
Get the name of the manager prefix.- Specified by:
getManagerNamein classScriptRunnerBase- Returns:
- "bsf"
-
supportsLanguage
public boolean supportsLanguage()Check if bsf supports the language.- Specified by:
supportsLanguagein classScriptRunnerBase- Returns:
- true if bsf can create an engine for this language.
-
executeScript
Do the work.- Specified by:
executeScriptin classScriptRunnerBase- Parameters:
execName- the name that will be passed to BSF for this script execution.- Throws:
BuildException- if something goes wrong executing the script.
-
evaluateScript
Evaluate the script.- Specified by:
evaluateScriptin classScriptRunnerBase- Parameters:
execName- the name that will be passed to BSF for this script execution.- Returns:
- the result of the evaluation
- Throws:
BuildException- if something goes wrong executing the script.
-