Package org.eclipse.ease
Class AbstractScriptEngine
java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.eclipse.core.internal.jobs.InternalJob
org.eclipse.core.runtime.jobs.Job
org.eclipse.ease.AbstractScriptEngine
- All Implemented Interfaces:
Comparable,org.eclipse.core.runtime.IAdaptable,IScriptEngine
- Direct Known Subclasses:
AbstractReplScriptEngine,ArchiveEngine,JVMCompiledScriptEngine,TestSuiteScriptEngine
public abstract class AbstractScriptEngine extends org.eclipse.core.runtime.jobs.Job implements IScriptEngine
Base implementation for a script engine. Handles Job implementation of script engine, adding script code for execution, module loading support and a basic
online help system.
-
Field Summary
Fields inherited from class org.eclipse.core.runtime.jobs.Job
ASYNC_FINISH, BUILD, DECORATE, INTERACTIVE, LONG, NONE, RUNNING, SHORT, SLEEPING, WAITINGFields inherited from interface org.eclipse.ease.IScriptEngine
TRACE_SCRIPT_ENGINE -
Constructor Summary
Constructors Constructor Description AbstractScriptEngine(String name)Constructor. -
Method Summary
Modifier and Type Method Description voidaddExecutionListener(IExecutionListener listener)voidaddSecurityCheck(ISecurityCheck.ActionType type, ISecurityCheck check)Add a dedicated security check for a certain script action.ScriptResultexecute(Object content)Execute script code.static IScriptEnginegetCurrentScriptEngine()Get the current script engine.EngineDescriptiongetDescription()Get engine description for current engine.PrintStreamgetErrorStream()ObjectgetExecutedFile()Get the currently executed file instance.InputStreamgetInputStream()org.eclipse.debug.core.ILaunchgetLaunch()Get the launch that was used to create this engine.org.eclipse.core.runtime.IProgressMonitorgetMonitor()Get the monitor of the current running engine.PrintStreamgetOutputStream()ScriptStackTracegetStackTrace()ObjectgetVariable(String name)Get a script variable.Map<String,Object>getVariables()Get all variables from the scope.booleanhasVariable(String name)Check if a variable exists within the scope of the engine.Objectinject(Object content, boolean uiThread)Inject script code and execute synchronously.booleanisFinished()Verify that engine was started and terminated.voidjoinEngine()Join engine execution thread.voidjoinEngine(long timeout)Join engine execution thread.voidremoveExecutionListener(IExecutionListener listener)voidsetCloseStreamsOnTerminate(boolean closeStreams)Set marker to automatically close I/O streams when engine is terminated.voidsetEngineDescription(EngineDescription description)voidsetErrorStream(OutputStream errorStream)Set the default error stream for the interpreter.voidsetExecutionRootFile(Object executionRootFile)voidsetInputStream(InputStream inputStream)Set the default input stream for the interpreter.voidsetLaunch(org.eclipse.debug.core.ILaunch launch)voidsetOutputStream(OutputStream outputStream)Set the default output stream for the interpreter.voidsetVariable(String name, Object content)Set a variable in the script engine.voidterminate()Terminate this interpreter.Methods inherited from class org.eclipse.core.runtime.jobs.Job
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, yieldRuleMethods inherited from class org.eclipse.core.internal.jobs.InternalJob
compareToMethods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapterMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.ease.IScriptEngine
getName, registerJar, schedule, terminateCurrent
-
Constructor Details
-
AbstractScriptEngine
Constructor. Sets the name for the underlying job.- Parameters:
name- name of script engine job
-
-
Method Details
-
getCurrentScriptEngine
Get the current script engine. Works only if executed from the script engine thread.- Returns:
- script engine or
null
-
getDescription
Description copied from interface:IScriptEngineGet engine description for current engine.- Specified by:
getDescriptionin interfaceIScriptEngine- Returns:
- engine description
-
execute
Description copied from interface:IScriptEngineExecute script code. The code provided will be scheduled and executed as soon as all previously scheduled code is executed. If content is aReaderobject, or aFilespecial treatment is done, otherwise the toString() method is used to extract script code. This is a non-blocking call.- Specified by:
executein interfaceIScriptEngine- Parameters:
content- content to be executed.- Returns:
- execution result
-
inject
Description copied from interface:IScriptEngineInject script code and execute synchronously. Code passed to this method will be invoked immediately. It might interrupt a currently running execution requested asynchronously.- Specified by:
injectin interfaceIScriptEngine- Parameters:
content- content to be executed.uiThread- execute code in UI thread- Returns:
- execution result
- Throws:
ExecutionException- when code execution failed
-
terminate
public void terminate()Description copied from interface:IScriptEngineTerminate this interpreter. Addresses a request to terminate current script execution. When the request will be handled is implementation specific.- Specified by:
terminatein interfaceIScriptEngine
-
isFinished
public boolean isFinished()Description copied from interface:IScriptEngineVerify that engine was started and terminated.- Specified by:
isFinishedin interfaceIScriptEngine- Returns:
truewhen engine ran and terminated
-
joinEngine
Description copied from interface:IScriptEngineJoin engine execution thread. Waits for engine termination.- Specified by:
joinEnginein interfaceIScriptEngine- Throws:
InterruptedException- when join command got interrupted
-
joinEngine
Description copied from interface:IScriptEngineJoin engine execution thread. Waits for engine execution up to timeout milliseconds.- Specified by:
joinEnginein interfaceIScriptEngine- Parameters:
timeout- command timeout in milliseconds- Throws:
InterruptedException- when join command got interrupted
-
getMonitor
public org.eclipse.core.runtime.IProgressMonitor getMonitor()Description copied from interface:IScriptEngineGet the monitor of the current running engine. The monitor is only valid while the script engine is running.- Specified by:
getMonitorin interfaceIScriptEngine- Returns:
- current monitor or
null
-
setCloseStreamsOnTerminate
public void setCloseStreamsOnTerminate(boolean closeStreams)Description copied from interface:IScriptEngineSet marker to automatically close I/O streams when engine is terminated.- Specified by:
setCloseStreamsOnTerminatein interfaceIScriptEngine- Parameters:
closeStreams-trueto close streams
-
getOutputStream
- Specified by:
getOutputStreamin interfaceIScriptEngine
-
setOutputStream
Description copied from interface:IScriptEngineSet the default output stream for the interpreter.- Specified by:
setOutputStreamin interfaceIScriptEngine- Parameters:
outputStream- default output stream
-
getInputStream
- Specified by:
getInputStreamin interfaceIScriptEngine
-
setInputStream
Description copied from interface:IScriptEngineSet the default input stream for the interpreter.- Specified by:
setInputStreamin interfaceIScriptEngine- Parameters:
inputStream- default input stream
-
getErrorStream
- Specified by:
getErrorStreamin interfaceIScriptEngine
-
setErrorStream
Description copied from interface:IScriptEngineSet the default error stream for the interpreter.- Specified by:
setErrorStreamin interfaceIScriptEngine- Parameters:
errorStream- default error stream
-
addExecutionListener
- Specified by:
addExecutionListenerin interfaceIScriptEngine
-
removeExecutionListener
- Specified by:
removeExecutionListenerin interfaceIScriptEngine
-
getStackTrace
-
getExecutedFile
Description copied from interface:IScriptEngineGet the currently executed file instance.- Specified by:
getExecutedFilein interfaceIScriptEngine- Returns:
- currently executed file
-
setExecutionRootFile
-
setEngineDescription
-
setVariable
Description copied from interface:IScriptEngineSet a variable in the script engine. This variable will be stored in the global script scope- Specified by:
setVariablein interfaceIScriptEngine- Parameters:
name- variable namecontent- variable content
-
getVariable
Description copied from interface:IScriptEngineGet a script variable. Retrieve a variable from the global script scope.- Specified by:
getVariablein interfaceIScriptEngine- Parameters:
name- variable name- Returns:
- variable content or
null
-
hasVariable
Description copied from interface:IScriptEngineCheck if a variable exists within the scope of the engine. As a variable content may benull,IScriptEngine.getVariable(String)might not be sufficient to query.- Specified by:
hasVariablein interfaceIScriptEngine- Parameters:
name- variable name- Returns:
truewhen variable exists
-
getVariables
Description copied from interface:IScriptEngineGet all variables from the scope.- Specified by:
getVariablesin interfaceIScriptEngine- Returns:
- map of variables
-
addSecurityCheck
Description copied from interface:IScriptEngineAdd a dedicated security check for a certain script action. If the check was already registered for this action, no further check will be added.- Specified by:
addSecurityCheckin interfaceIScriptEngine- Parameters:
type- action type to add check forcheck- check to register
-
setLaunch
public void setLaunch(org.eclipse.debug.core.ILaunch launch) -
getLaunch
public org.eclipse.debug.core.ILaunch getLaunch()Description copied from interface:IScriptEngineGet the launch that was used to create this engine.- Specified by:
getLaunchin interfaceIScriptEngine- Returns:
- launch or
nullin case this engine was created without launch configuration
-