public abstract class AbstractScriptEngine extends Job implements IScriptEngine
ASYNC_FINISH, BUILD, DECORATE, INTERACTIVE, LONG, NONE, RUNNING, SHORT, SLEEPING, WAITING
TRACE_SCRIPT_ENGINE
Constructor and Description |
---|
AbstractScriptEngine(java.lang.String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addExecutionListener(IExecutionListener listener) |
void |
addSecurityCheck(ISecurityCheck.ActionType type,
ISecurityCheck check)
Add a dedicated security check for a certain script action.
|
ScriptResult |
executeAsync(java.lang.Object content)
Execute script code asynchronously.
|
ScriptResult |
executeSync(java.lang.Object content)
Execute script code synchronously.
|
static java.lang.String[] |
extractArguments(java.lang.String arguments)
Split a string with comma separated arguments.
|
static IScriptEngine |
getCurrentScriptEngine()
Get the current script engine.
|
EngineDescription |
getDescription()
Get engine description for current engine.
|
java.io.PrintStream |
getErrorStream() |
java.lang.Object |
getExecutedFile()
Get the currently executed file instance.
|
java.io.InputStream |
getInputStream() |
ILaunch |
getLaunch()
Get the launch that was used to create this engine.
|
IProgressMonitor |
getMonitor()
Get the monitor of the current running engine.
|
java.io.PrintStream |
getOutputStream() |
ScriptStackTrace |
getStackTrace() |
java.lang.Object |
getVariable(java.lang.String name)
Get a script variable.
|
java.util.Map<java.lang.String,java.lang.Object> |
getVariables()
Get all variables from the scope.
|
boolean |
hasVariable(java.lang.String name)
Check if a variable exists within the scope of the engine.
|
java.lang.Object |
inject(java.lang.Object content)
Inject script code and execute synchronously.
|
java.lang.Object |
injectUI(java.lang.Object content)
Inject script code and execute synchronously within the UI thread.
|
boolean |
isFinished()
Verify that engine was started and terminated.
|
void |
join(long timeout)
Join engine execution thread.
|
void |
removeExecutionListener(IExecutionListener listener) |
void |
removeSecurityCheck(ISecurityCheck check)
Remove registered security check for all actions.
|
void |
setCloseStreamsOnTerminate(boolean closeStreams)
Set marker to automatically close I/O streams when engine is terminated.
|
void |
setEngineDescription(EngineDescription description) |
void |
setErrorStream(java.io.OutputStream errorStream)
Set the default error stream for the interpreter.
|
void |
setExecutionRootFile(java.lang.Object executionRootFile) |
void |
setInputStream(java.io.InputStream inputStream)
Set the default input stream for the interpreter.
|
void |
setLaunch(ILaunch launch) |
void |
setOutputStream(java.io.OutputStream outputStream)
Set the default output stream for the interpreter.
|
void |
setVariable(java.lang.String name,
java.lang.Object content)
Set a variable in the script engine.
|
void |
terminate()
Terminate this interpreter.
|
addJobChangeListener, belongsTo, cancel, create, create, createSystem, createSystem, createSystem, done, getJobGroup, getJobManager, getName, getPriority, getProperty, getResult, getRule, getState, getThread, isBlocking, isSystem, isUser, join, join, removeJobChangeListener, schedule, schedule, setJobGroup, setName, setPriority, setProgressGroup, setProperty, setRule, setSystem, setThread, setUser, shouldRun, shouldSchedule, sleep, toString, wakeUp, wakeUp, yieldRule
getAdapter
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getName, registerJar, schedule, terminateCurrent
getAdapter
public AbstractScriptEngine(java.lang.String name)
name
- name of script engine jobpublic static IScriptEngine getCurrentScriptEngine()
null
public EngineDescription getDescription()
IScriptEngine
getDescription
in interface IScriptEngine
public final ScriptResult executeAsync(java.lang.Object content)
IScriptEngine
Reader
object, or a File
special treatment is done, otherwise the toString() method is used to extract script code.executeAsync
in interface IScriptEngine
content
- content to be executed.public final ScriptResult executeSync(java.lang.Object content) throws java.lang.InterruptedException
IScriptEngine
Reader
object, or a File
special treatment is done, otherwise the toString() method is used to extract script code.
In case the engine was not started yet, it will be automatically started by this call. This is a blocking call.executeSync
in interface IScriptEngine
content
- content to be executed.java.lang.InterruptedException
- when execution is interruptedpublic final java.lang.Object inject(java.lang.Object content)
IScriptEngine
inject
in interface IScriptEngine
content
- content to be executed.public final java.lang.Object injectUI(java.lang.Object content)
IScriptEngine
injectUI
in interface IScriptEngine
content
- content to be executed.public IProgressMonitor getMonitor()
IScriptEngine
getMonitor
in interface IScriptEngine
null
public void setCloseStreamsOnTerminate(boolean closeStreams)
IScriptEngine
setCloseStreamsOnTerminate
in interface IScriptEngine
closeStreams
- true
to close streamspublic java.io.PrintStream getOutputStream()
getOutputStream
in interface IScriptEngine
public void setOutputStream(java.io.OutputStream outputStream)
IScriptEngine
setOutputStream
in interface IScriptEngine
outputStream
- default output streampublic java.io.InputStream getInputStream()
getInputStream
in interface IScriptEngine
public void setInputStream(java.io.InputStream inputStream)
IScriptEngine
setInputStream
in interface IScriptEngine
inputStream
- default input streampublic java.io.PrintStream getErrorStream()
getErrorStream
in interface IScriptEngine
public void setErrorStream(java.io.OutputStream errorStream)
IScriptEngine
setErrorStream
in interface IScriptEngine
errorStream
- default error streampublic void addExecutionListener(IExecutionListener listener)
addExecutionListener
in interface IScriptEngine
public void removeExecutionListener(IExecutionListener listener)
removeExecutionListener
in interface IScriptEngine
public void terminate()
IScriptEngine
terminate
in interface IScriptEngine
public ScriptStackTrace getStackTrace()
public java.lang.Object getExecutedFile()
IScriptEngine
getExecutedFile
in interface IScriptEngine
public void setExecutionRootFile(java.lang.Object executionRootFile)
public void setEngineDescription(EngineDescription description)
public void setVariable(java.lang.String name, java.lang.Object content)
IScriptEngine
setVariable
in interface IScriptEngine
name
- variable namecontent
- variable contentpublic java.lang.Object getVariable(java.lang.String name)
IScriptEngine
getVariable
in interface IScriptEngine
name
- variable namenull
public boolean hasVariable(java.lang.String name)
IScriptEngine
null
, IScriptEngine.getVariable(String)
might not be
sufficient to query.hasVariable
in interface IScriptEngine
name
- variable nametrue
when variable existspublic java.util.Map<java.lang.String,java.lang.Object> getVariables()
IScriptEngine
getVariables
in interface IScriptEngine
public static final java.lang.String[] extractArguments(java.lang.String arguments)
arguments
- comma separated argumentspublic boolean isFinished()
IScriptEngine
isFinished
in interface IScriptEngine
true
when engine ran and terminatedpublic void join(long timeout) throws java.lang.InterruptedException
IScriptEngine
join
in interface IScriptEngine
timeout
- command timeout in millisecondsjava.lang.InterruptedException
- when join command got interruptedpublic void addSecurityCheck(ISecurityCheck.ActionType type, ISecurityCheck check)
IScriptEngine
addSecurityCheck
in interface IScriptEngine
type
- action type to add check forcheck
- check to registerpublic void removeSecurityCheck(ISecurityCheck check)
IScriptEngine
removeSecurityCheck
in interface IScriptEngine
check
- check to be removedpublic void setLaunch(ILaunch launch)
public ILaunch getLaunch()
IScriptEngine
getLaunch
in interface IScriptEngine
null
in case this engine was created without launch configuration