public abstract class ScriptRunnerBase extends Object
Constructor and Description |
---|
ScriptRunnerBase() |
Modifier and Type | Method and Description |
---|---|
void |
addBean(String key,
Object bean)
Add a single object into the script context.
|
void |
addBeans(Map dictionary)
Add a list of named objects to the list to be exported to the script
|
void |
addText(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 Object |
evaluateScript(String execName)
Evaluate the script.
|
abstract void |
executeScript(String execName)
Do the work.
|
protected Map |
getBeans()
Get the beans used for the script.
|
boolean |
getKeepEngine()
Get the keep engine attribute.
|
String |
getLanguage()
Get the script language
|
abstract String |
getManagerName()
Get the name of the manager prefix used for this
scriptrunner.
|
Project |
getProject()
Get the project for this runner.
|
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(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(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 addBean(String key, Object bean)
key
- the name in the context this object is to stored under.bean
- the object to be stored in the script context.public void addBeans(Map dictionary)
dictionary
- a map of objects to be placed into the script context
indexed by String names.public void addText(String text)
text
- a component of the script text to be added.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.public void clearScript()
public abstract Object evaluateScript(String execName)
execName
- the name that will be passed to the
scripting engine for this script execution.public abstract void executeScript(String execName)
execName
- the name that will be passed to BSF for this script
execution.protected Map getBeans()
public boolean getKeepEngine()
public String getLanguage()
public abstract String getManagerName()
public Project getProject()
public String getScript()
protected java.lang.ClassLoader getScriptClassLoader()
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 readprotected java.lang.ClassLoader replaceContextLoader()
protected void restoreContextLoader(java.lang.ClassLoader origLoader)
origLoader
- the original context classloader.public void setKeepEngine(boolean keepEngine)
keepEngine
- if true, keep the engine.public void setLanguage(String language)
language
- the scripting language name for the script.public void setProject(Project project)
project
- the project.public void setScriptClassLoader(java.lang.ClassLoader classLoader)
classLoader
- the classloader to use.public void setSrc(File file)
file
- the file containing the script source.public abstract boolean supportsLanguage()