# Scripting Module

Commands to launch additional script engines.

## Method Overview

Method | Description
--- | ---
createScriptEngine() | Create a new script engine instance.
executeSync() | Run a code fragment in a synchronized block.
fork() | Fork a new script engine and execute provided resource.
getSharedObject() | Get an object from the shared object store.
join() | Wait for a script engine to shut down.
listScriptEngines() | Retrieve a list of available script engines.
notify() | Wakes up a single thread that is waiting on the monitor.
notifyAll() | Wakes up all threads that are waiting on the monitor.
setSharedObject() | Add an object to the shared object store.
wait() | Causes the current thread to wait until either another thread invokes the {@link java.

## Methods

### createScriptEngine

org.eclipse.ease.IScriptEngine createScriptEngine(java.lang.String identifier)

Create a new script engine instance.

Parameter | Type | Description
--- | --- | ---
identifier | java.lang.String | engine ID, literal engine name or accepted file extension

Returns:org.eclipse.ease.IScriptEngine ... script engine instance (not started) or `null`

### executeSync

java.lang.Object executeSync(java.lang.Object monitor, java.lang.Object code)

Run a code fragment in a synchronized block. Executes code within a synchronized block on the monitor object. The code object might be a String, File, IFile or any other object that can be adapted to IScriptable.

Parameter | Type | Description
--- | --- | ---
monitor | java.lang.Object | monitor to synchronize on
code | java.lang.Object | code to run.

Returns:java.lang.Object ...

### fork

org.eclipse.ease.IScriptEngine fork(java.lang.Object resource, [java.lang.String arguments], [java.lang.String engineID])

Fork a new script engine and execute provided resource.

Parameter | Type | Description
--- | --- | ---
resource | java.lang.Object | resource to execute (path, URI or file instance)
arguments | java.lang.String | optional script arguments delimited by commas ',' Optional: defaults to <null>.
engineID | java.lang.String | engine ID to be used Optional: defaults to <null>.

Returns:org.eclipse.ease.IScriptEngine ... script engine instance or `null` in case of error

### getSharedObject

java.lang.Object getSharedObject(java.lang.String key)

Get an object from the shared object store.

Parameter | Type | Description
--- | --- | ---
key | java.lang.String | key to retrieve object for

Returns:java.lang.Object ... shared object or `null`

### join

boolean join(org.eclipse.ease.IScriptEngine engine, [long timeout])

Wait for a script engine to shut down. If timeout is set to 0 this method will wait endlessly.

Parameter | Type | Description
--- | --- | ---
engine | org.eclipse.ease.IScriptEngine | script engine to wait for
timeout | long | time to wait for shutdown [ms] Optional: defaults to <0>.

Returns:boolean ... `true` when engine is shut down

### listScriptEngines

java.lang.String listScriptEngines()

Retrieve a list of available script engines.

Returns:java.lang.String ... array of engine IDs

### notify

void notify(java.lang.Object monitor)

Wakes up a single thread that is waiting on the monitor. Calls the java method monitor.notify().

Parameter | Type | Description
--- | --- | ---
monitor | java.lang.Object | monitor to notify

### notifyAll

void notifyAll(java.lang.Object monitor)

Wakes up all threads that are waiting on the monitor. Calls the java method monitor.notifyAll().

Parameter | Type | Description
--- | --- | ---
monitor | java.lang.Object | monitor to notify

### setSharedObject

void setSharedObject(java.lang.String key, java.lang.Object object, [boolean permanent], [boolean writable])

Add an object to the shared object store. The shared object store allows to share java instances between several script engines. By default objects are stored until the script engine providing it is terminated. This helps to avoid polluting the java heap. When permanent is set to `true` , this object will be stored forever.

Parameter | Type | Description
--- | --- | ---
key | java.lang.String | key to store the object
object | java.lang.Object | instance to store
permanent | boolean | flag indicating permanent storage Optional: defaults to <false>.
writable | boolean | flag indicating that any engine may write this value Optional: defaults to <false>.

### wait

void wait(java.lang.Object monitor, [long timeout])

Causes the current thread to wait until either another thread invokes the java.lang.Objectnotify() method or the java.lang.ObjectnotifyAll() method for this object, or a specified amount of time has elapsed. Calls the java method monitor.wait(timeout).

Parameter | Type | Description
--- | --- | ---
monitor | java.lang.Object | monitor to wait for
timeout | long | max timeout (0 does not time out) Optional: defaults to <0>.