public abstract class AbstractScriptEngine extends Job implements IScriptEngine
ASYNC_FINISH, BUILD, DECORATE, INTERACTIVE, LONG, NONE, RUNNING, SHORT, SLEEPING, WAITINGTRACE_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() |
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 |
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, 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, yieldRulegetAdapterequals, getClass, hashCode, notify, notifyAll, wait, wait, waitgetName, registerJar, schedule, terminateCurrentgetAdapterpublic AbstractScriptEngine(java.lang.String name)
name - name of script engine jobpublic static IScriptEngine getCurrentScriptEngine()
nullpublic EngineDescription getDescription()
IScriptEnginegetDescription in interface IScriptEnginepublic final ScriptResult executeAsync(java.lang.Object content)
IScriptEngineReader object, or a File special treatment is done, otherwise the toString() method is used to extract script code.executeAsync in interface IScriptEnginecontent - content to be executed.public final ScriptResult executeSync(java.lang.Object content) throws java.lang.InterruptedException
IScriptEngineReader 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 IScriptEnginecontent - content to be executed.java.lang.InterruptedException - when execution is interruptedpublic final java.lang.Object inject(java.lang.Object content)
IScriptEngineinject in interface IScriptEnginecontent - content to be executed.public final java.lang.Object injectUI(java.lang.Object content)
IScriptEngineinjectUI in interface IScriptEnginecontent - content to be executed.public void setCloseStreamsOnTerminate(boolean closeStreams)
IScriptEnginesetCloseStreamsOnTerminate in interface IScriptEnginecloseStreams - true to close streamspublic java.io.PrintStream getOutputStream()
getOutputStream in interface IScriptEnginepublic void setOutputStream(java.io.OutputStream outputStream)
IScriptEnginesetOutputStream in interface IScriptEngineoutputStream - default output streampublic java.io.InputStream getInputStream()
getInputStream in interface IScriptEnginepublic void setInputStream(java.io.InputStream inputStream)
IScriptEnginesetInputStream in interface IScriptEngineinputStream - default input streampublic java.io.PrintStream getErrorStream()
getErrorStream in interface IScriptEnginepublic void setErrorStream(java.io.OutputStream errorStream)
IScriptEnginesetErrorStream in interface IScriptEngineerrorStream - default error streampublic void addExecutionListener(IExecutionListener listener)
addExecutionListener in interface IScriptEnginepublic void removeExecutionListener(IExecutionListener listener)
removeExecutionListener in interface IScriptEnginepublic void terminate()
IScriptEngineterminate in interface IScriptEnginepublic ScriptStackTrace getStackTrace()
public java.lang.Object getExecutedFile()
IScriptEnginegetExecutedFile in interface IScriptEnginepublic void setExecutionRootFile(java.lang.Object executionRootFile)
public void setEngineDescription(EngineDescription description)
public void setVariable(java.lang.String name,
java.lang.Object content)
IScriptEnginesetVariable in interface IScriptEnginename - variable namecontent - variable contentpublic java.lang.Object getVariable(java.lang.String name)
IScriptEnginegetVariable in interface IScriptEnginename - variable namenullpublic boolean hasVariable(java.lang.String name)
IScriptEnginenull, IScriptEngine.getVariable(String) might not be
sufficient to query.hasVariable in interface IScriptEnginename - variable nametrue when variable existspublic java.util.Map<java.lang.String,java.lang.Object> getVariables()
IScriptEnginegetVariables in interface IScriptEnginepublic static final java.lang.String[] extractArguments(java.lang.String arguments)
arguments - comma separated argumentspublic boolean isFinished()
IScriptEngineisFinished in interface IScriptEnginetrue when engine ran and terminatedpublic void join(long timeout)
throws java.lang.InterruptedException
IScriptEnginejoin in interface IScriptEnginetimeout - command timeout in millisecondsjava.lang.InterruptedException - when join command got interruptedpublic void addSecurityCheck(ISecurityCheck.ActionType type, ISecurityCheck check)
IScriptEngineaddSecurityCheck in interface IScriptEnginetype - action type to add check forcheck - check to registerpublic void removeSecurityCheck(ISecurityCheck check)
IScriptEngineremoveSecurityCheck in interface IScriptEnginecheck - check to be removed