Class ScriptingModule
java.lang.Object
org.eclipse.ease.modules.AbstractScriptModule
org.eclipse.ease.modules.platform.ScriptingModule
- All Implemented Interfaces:
IScriptModule
public class ScriptingModule extends AbstractScriptModule
Commands to launch additional script engines.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ScriptingModule()
-
Method Summary
Modifier and Type Method Description static IScriptEngine
createScriptEngine(String identifier)
Create a new script engine instance.Object
executeSync(Object monitor, Object code)
Run a code fragment in a synchronized block.ScriptResult
fork(Object resource, String arguments, String engineIdOrExtension)
Fork a new script engine and execute provided resource.Object
getSharedObject(String key)
Get an object from the shared object store.static boolean
join(IScriptEngine engine, long timeout)
Wait for a script engine to shut down.static String[]
listScriptEngines()
Retrieve a list of available script engines.static void
notify(Object monitor)
Wakes up a single thread that is waiting on the monitor.static void
notifyAll(Object monitor)
Wakes up all threads that are waiting on the monitor.void
setSharedObject(String key, Object object, boolean permanent, boolean writable)
Add an object to the shared object store.static void
wait(Object monitor, long timeout)
Causes the current thread to wait until either another thread invokes theObject.notify()
method or theObject.notifyAll()
method for this object, or a specified amount of time has elapsed.Methods inherited from class org.eclipse.ease.modules.AbstractScriptModule
getScriptEngine, initialize
-
Field Details
-
MODULE_ID
Module identifier.- See Also:
- Constant Field Values
-
-
Constructor Details
-
ScriptingModule
public ScriptingModule()
-
-
Method Details
-
createScriptEngine
Create a new script engine instance.- Parameters:
identifier
- engine ID, literal engine name or accepted file extension- Returns:
- script engine instance (not started) or
null
-
listScriptEngines
Retrieve a list of available script engines.- Returns:
- array of engine IDs
-
fork
public ScriptResult fork(Object resource, @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") String arguments, @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null") String engineIdOrExtension)Fork a new script engine and execute provided resource.- Parameters:
resource
- resource to execute (path, URI or file instance)arguments
- optional script arguments delimited by commas ','. When the string arguments contains commas ',', or for arguments that are not string, the caller may set a shared object with and pass the key here. The callee can then retrieve it with the method.engineIdOrExtension
- engine ID to be used or a file extension to look for engines (eg: js)- Returns:
- execution result
-
join
Wait for a script engine to shut down. If timeout is set to 0 this method will wait endlessly.- Parameters:
engine
- script engine to wait fortimeout
- time to wait for shutdown [ms]- Returns:
true
when engine is shut down
-
executeSync
Run a code fragment in a synchronized block. Executes code within a synchronized block on the monitor object. The code object might be aString
,File
,IFile
or any other object that can be adapted toIScriptable
.- Parameters:
monitor
- monitor to synchronize oncode
- code to run.- Returns:
- execution result of executed code
- Throws:
ExecutionException
- when execution of code fails
-
wait
public static void wait(Object monitor, @ScriptParameter(defaultValue="0") long timeout) throws InterruptedExceptionCauses the current thread to wait until either another thread invokes theObject.notify()
method or theObject.notifyAll()
method for this object, or a specified amount of time has elapsed. Calls the java method monitor.wait(timeout).- Parameters:
monitor
- monitor to wait fortimeout
- max timeout (0 does not time out)- Throws:
InterruptedException
- when wait gets interrupted
-
notify
Wakes up a single thread that is waiting on the monitor. Calls the java method monitor.notify().- Parameters:
monitor
- monitor to notify
-
notifyAll
Wakes up all threads that are waiting on the monitor. Calls the java method monitor.notifyAll().- Parameters:
monitor
- monitor to notify
-