Package org.apache.tools.ant.util
Class ScriptRunnerBase
java.lang.Object
org.apache.tools.ant.util.ScriptRunnerBase
- Direct Known Subclasses:
- JavaxScriptRunner,- ScriptRunner
This is a common abstract base case for script runners.
 These classes need to implement executeScript, evaluateScript
 and supportsLanguage.
- Since:
- Ant 1.7.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.abstract ObjectevaluateScript(String execName) Evaluate the script.abstract voidexecuteScript(String execName) Do the work.getBeans()Get the beans used for the script.final booleanGet the compiled attribute.booleanGet the keep engine attribute.Get the script languageabstract StringGet the name of the manager prefix used for this scriptrunner.Get 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.abstract booleanCheck if a script engine can be created for this language.
- 
Constructor Details- 
ScriptRunnerBasepublic ScriptRunnerBase()
 
- 
- 
Method Details- 
addBeansAdd a list of named objects to the list to be exported to the script- Parameters:
- dictionary- a map of objects to be placed into the script context indexed by String names.
 
- 
addBeanAdd a single object into the script context.- Parameters:
- key- the name in the context this object is to stored under.
- bean- the object to be stored in the script context.
 
- 
getBeansGet the beans used for the script.- Returns:
- the map of beans.
 
- 
executeScriptDo the work.- Parameters:
- execName- the name that will be passed to BSF for this script execution.
 
- 
evaluateScriptEvaluate the script.- Parameters:
- execName- the name that will be passed to the scripting engine for this script execution.
- Returns:
- the result of evaluating the script.
 
- 
supportsLanguagepublic abstract boolean supportsLanguage()Check if a script engine can be created for this language.- Returns:
- true if a script engine can be created, false otherwise.
 
- 
getManagerNameGet the name of the manager prefix used for this scriptrunner.- Returns:
- the prefix string.
 
- 
setLanguageDefines the language (required).- Parameters:
- language- the scripting language name for the script.
 
- 
getLanguageGet the script language- Returns:
- the script language
 
- 
setScriptClassLoaderSet the script classloader.- Parameters:
- classLoader- the classloader to use.
 
- 
getScriptClassLoaderGet the classloader used to load the script engine.- Returns:
- the classloader.
 
- 
setKeepEnginepublic void setKeepEngine(boolean keepEngine) Whether to keep the script engine between calls.- Parameters:
- keepEngine- if true, keep the engine.
 
- 
getKeepEnginepublic boolean getKeepEngine()Get the keep engine attribute.- Returns:
- the attribute.
 
- 
setCompiledpublic final void setCompiled(boolean compiled) Whether to use script compilation if available.- Parameters:
- compiled- if true, compile the script if possible.
- Since:
- Ant 1.10.2
 
- 
getCompiledpublic final boolean getCompiled()Get the compiled attribute.- Returns:
- the attribute.
- Since:
- Ant 1.10.2
 
- 
setEncodingSet encoding of the script from an external file; optional.- Parameters:
- encoding- encoding of the external file containing the script source.
- Since:
- Ant 1.10.2
 
- 
setSrcLoad the script from an external file; optional.- Parameters:
- file- the file containing the script source.
 
- 
loadResourceAdd a resource to the source list.- Parameters:
- sourceResource- the resource to load
- Throws:
- BuildException- if the resource cannot be read
- Since:
- Ant 1.7.1
 
- 
loadResourcesAdd all resources in a resource collection to the source list.- Parameters:
- collection- the resource to load
- Throws:
- BuildException- if a resource cannot be read
- Since:
- Ant 1.7.1
 
- 
addTextSet the script text. Properties in the text are not expanded!- Parameters:
- text- a component of the script text to be added.
 
- 
getScriptGet the current script text content.- Returns:
- the script text.
 
- 
clearScriptpublic void clearScript()Clear the current script text content.
- 
setProjectSet the project for this runner.- Parameters:
- project- the project.
 
- 
getProjectGet the project for this runner.- Returns:
- the project.
 
- 
bindToComponentBind the runner to a project component. Properties, targets and references are all added as beans; project is bound to project, and self to the component.- Parameters:
- component- to become- self
 
- 
bindToComponentMinimumBind the runner to a project component. The project and self are the only beans set.- Parameters:
- component- to become- self
 
- 
checkLanguageprotected void checkLanguage()Check if the language attribute is set.- Throws:
- BuildException- if it is not.
 
- 
replaceContextLoaderReplace the current context classloader with the script context classloader.- Returns:
- the current context classloader.
 
- 
restoreContextLoaderRestore the context loader with the original context classloader. script context loader.- Parameters:
- origLoader- the original context classloader.
 
 
-