Class ScriptingModule
java.lang.Object
org.eclipse.ease.modules.AbstractScriptModule
org.eclipse.ease.modules.platform.ScriptingModule
- All Implemented Interfaces:
IScriptModule
- Direct Known Subclasses:
PlatformModule
Commands to launch additional script engines.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IScriptEngine
createScriptEngine
(String identifier) Create a new script engine instance.executeSync
(Object monitor, Object code) Run a code fragment in a synchronized block.static final String[]
extractArguments
(String arguments) Split a string with comma separated arguments.Fork a new script engine and execute provided resource.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[]
Retrieve a list of available script engines.static void
Wakes up a single thread that is waiting on the monitor.static void
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
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
initialize
-
Field Details
-
MODULE_ID
Module identifier.- See Also:
-
-
Constructor Details
-
ScriptingModule
public ScriptingModule()
-
-
Method Details
-
extractArguments
Split a string with comma separated arguments.- Parameters:
arguments
- comma separated arguments- Returns:
- trimmed list of arguments
-
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 InterruptedException 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. 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
-