This is a common abstract base case for script runners.
These classes need to implement executeScript, evaluateScript
and supportsLanguage.
addBean
public void addBean(String key,
Object bean)
Add a single object into the script context.
key
- the name in the context this object is to stored under.bean
- the object to be stored in the script context.
addBeans
public void addBeans(Map dictionary)
Add a list of named objects to the list to be exported to the script
dictionary
- a map of objects to be placed into the script context
indexed by String names.
addText
public void addText(String text)
Set the script text.
text
- a component of the script text to be added.
bindToComponent
public void bindToComponent(ProjectComponent component)
Bind 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.
component
- to become self
bindToComponentMinimum
public void bindToComponentMinimum(ProjectComponent component)
Bind the runner to a project component.
The project and self are the only beans set.
component
- to become self
checkLanguage
protected void checkLanguage()
Check if the language attribute is set.
clearScript
public void clearScript()
Clear the current script text content.
evaluateScript
public abstract Object evaluateScript(String execName)
Evalulate the script.
execName
- the name that will be passed to BSF for this script
execution.
- the result of evalulating the script.
executeScript
public abstract void executeScript(String execName)
Do the work.
execName
- the name that will be passed to BSF for this script
execution.
getBeans
protected Map getBeans()
Get the beans used for the script.
getKeepEngine
public boolean getKeepEngine()
Get the keep engine attribute.
getLanguage
public String getLanguage()
Get the script language
getManagerName
public abstract String getManagerName()
Get the name of the manager prefix used for this
scriptrunner.
getProject
public Project getProject()
Get the project for this runner.
getScript
public String getScript()
Get the current script text content.
getScriptClassLoader
protected ClassLoader getScriptClassLoader()
Get the classloader used to load the script engine.
replaceContextLoader
protected ClassLoader replaceContextLoader()
Replace the current context classloader with the
script context classloader.
- the current context classloader.
restoreContextLoader
protected void restoreContextLoader(ClassLoader origLoader)
Restore the context loader with the original context classloader.
script context loader.
origLoader
- the original context classloader.
setKeepEngine
public void setKeepEngine(boolean keepEngine)
Whether to keep the script engine between calls.
keepEngine
- if true, keep the engine.
setLanguage
public void setLanguage(String language)
Defines the language (required).
language
- the scripting language name for the script.
setProject
public void setProject(Project project)
Set the project for this runner.
setScriptClassLoader
public void setScriptClassLoader(ClassLoader classLoader)
Set the script classloader.
classLoader
- the classloader to use.
setSrc
public void setSrc(File file)
Load the script from an external file; optional.
file
- the file containing the script source.
supportsLanguage
public abstract boolean supportsLanguage()
Check if a script engine can be created for
this language.
- true if a script engine can be created, false
otherwise.