public interface ScriptService
SCRIPT_ALIAS
as property name and value pointing to the script 'alias' under which their service is
wished to be bound.
interface MyScriptService extends ScriptService {
public void String hello();
}
interface MyScriptServiceImpl implements MyScriptService {
public void String hello() {
return "Hello from MyScriptService!";
}
}
(registering as service):
BundleContex bc;
Dictionary props = new Hashtable(1);
props.put(ScriptService.SCRIPT_ALIAS, "myService");
bc.registerService(MyScriptService.class.getName(), new MyScriptServiceImpl(), props);
(Usage in groovy scripts):
myService.hello()
Once registered, the service is granted so called call back to the system init(ScriptEngineCallback),
through which the Script Service can get addition context information of each method executions as well as to push
back to the system results to asynchronous methods.
AsyncResult as last method argument. Asynchronous methods may return/exit without
completing fully their intended job and apply their completion result at a later moment via this AsyncResult argument.
Note, that AsyncResult objects are not necessarily needed to be kept in memory by the Script Service implementations:,
they can be restored by id via the ScriptEngineCallback (granted through the init(ScriptEngineCallback) method) at any time. See:
AsyncResult.getId() and ScriptEngineCallback.getAsyncResult(String).
ReportToUser annotation placed:
before the service class declaration to override the behavior for all service methods,
before concrete method declaration to override the behavior for this exact method.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
SCRIPT_ALIAS
Service registration property defining the script service alias name, i.e., the alias with which the service will be bound in the groovy scripts.
|
| Modifier and Type | Method and Description |
|---|---|
void |
init(ScriptEngineCallback callback)
Invoked by the system to grant to the Script Service a call back to the system.
|
static final java.lang.String SCRIPT_ALIAS
"myService", or
String[], for instance: {"myService", "my"} in case more than one possible aliases is wished to be available.void init(ScriptEngineCallback callback)
callback - system-provided callback.Copyright © 2019 Bosch Software Innovations GmbH. All Rights Reserved.