public abstract class ScriptRunnerBase
extends java.lang.Object
Constructor and Description |
---|
ScriptRunnerBase() |
Modifier and Type | Method and Description |
---|---|
void |
addBean(java.lang.String key,
java.lang.Object bean)
Add a single object into the script context.
|
void |
addBeans(java.util.Map dictionary)
Add a list of named objects to the list to be exported to the script
|
void |
addText(java.lang.String text)
Set the script text.
|
void |
bindToComponent(ProjectComponent component)
Bind the runner to a project component.
|
void |
bindToComponentMinimum(ProjectComponent component)
Bind the runner to a project component.
|
protected void |
checkLanguage()
Check if the language attribute is set.
|
void |
clearScript()
Clear the current script text content.
|
abstract java.lang.Object |
evaluateScript(java.lang.String execName)
Evaluate the script.
|
abstract void |
executeScript(java.lang.String execName)
Do the work.
|
protected java.util.Map |
getBeans()
Get the beans used for the script.
|
boolean |
getKeepEngine()
Get the keep engine attribute.
|
java.lang.String |
getLanguage()
Get the script language
|
abstract java.lang.String |
getManagerName()
Get the name of the manager prefix used for this
scriptrunner.
|
Project |
getProject()
Get the project for this runner.
|
java.lang.String |
getScript()
Get the current script text content.
|
protected java.lang.ClassLoader |
getScriptClassLoader()
Get the classloader used to load the script engine.
|
void |
loadResource(Resource sourceResource)
Add a resource to the source list.
|
void |
loadResources(ResourceCollection collection)
Add all resources in a resource collection to the source list.
|
protected java.lang.ClassLoader |
replaceContextLoader()
Replace the current context classloader with the
script context classloader.
|
protected void |
restoreContextLoader(java.lang.ClassLoader origLoader)
Restore the context loader with the original context classloader.
|
void |
setKeepEngine(boolean keepEngine)
Whether to keep the script engine between calls.
|
void |
setLanguage(java.lang.String language)
Defines the language (required).
|
void |
setProject(Project project)
Set the project for this runner.
|
void |
setScriptClassLoader(java.lang.ClassLoader classLoader)
Set the script classloader.
|
void |
setSrc(java.io.File file)
Load the script from an external file; optional.
|
abstract boolean |
supportsLanguage()
Check if a script engine can be created for
this language.
|
public void addBeans(java.util.Map dictionary)
dictionary
- a map of objects to be placed into the script context
indexed by String names.public void addBean(java.lang.String key, java.lang.Object bean)
key
- the name in the context this object is to stored under.bean
- the object to be stored in the script context.protected java.util.Map getBeans()
public abstract void executeScript(java.lang.String execName)
execName
- the name that will be passed to BSF for this script
execution.public abstract java.lang.Object evaluateScript(java.lang.String execName)
execName
- the name that will be passed to the
scripting engine for this script execution.public abstract boolean supportsLanguage()
public abstract java.lang.String getManagerName()
public void setLanguage(java.lang.String language)
language
- the scripting language name for the script.public java.lang.String getLanguage()
public void setScriptClassLoader(java.lang.ClassLoader classLoader)
classLoader
- the classloader to use.protected java.lang.ClassLoader getScriptClassLoader()
public void setKeepEngine(boolean keepEngine)
keepEngine
- if true, keep the engine.public boolean getKeepEngine()
public void setSrc(java.io.File file)
file
- the file containing the script source.public void loadResource(Resource sourceResource)
sourceResource
- the resource to loadBuildException
- if the resource cannot be readpublic void loadResources(ResourceCollection collection)
collection
- the resource to loadBuildException
- if a resource cannot be readpublic void addText(java.lang.String text)
text
- a component of the script text to be added.public java.lang.String getScript()
public void clearScript()
public void setProject(Project project)
project
- the project.public Project getProject()
public void bindToComponent(ProjectComponent component)
component
- to become self
public void bindToComponentMinimum(ProjectComponent component)
component
- to become self
protected void checkLanguage()
BuildException
- if it is not.protected java.lang.ClassLoader replaceContextLoader()
protected void restoreContextLoader(java.lang.ClassLoader origLoader)
origLoader
- the original context classloader.