Engine
Overview
Module
- package:
org.eclipse.dirigible.sdk.platform - source: platform/Engine.java
Invokes another scripting engine on a file in the registry — most often GraalJS, occasionally Python or another GraalVM polyglot engine. The parameters map is forwarded into the engine's global scope and the engine's natural return value is propagated back.
Useful for hybrid workflows where a Java controller delegates a step to a script in another language (or vice versa) — Dirigible's polyglot runtime lets every language share the same in-process services. For pure in-Java composition prefer regular method calls; spinning up an engine has non-trivial cost compared to invoking a Component bean directly.
Key Features
- Polyglot dispatch: Run a registry-hosted script (JavaScript, TypeScript, Python, …) from Java without an HTTP hop.
- Parameter passing: The supplied
Mapis exposed in the engine's global scope. - Debug flag: The full overload supports a
debugtoggle for breakpoint-friendly execution. - Engine discovery:
listEngines()returns the registered engine type names.
Example Usage
import java.util.Map;
import org.eclipse.dirigible.sdk.platform.Engine;
// Run a registry script in another language with a parameter map:
Object result = Engine.execute(
"javascript",
"demo",
"demo/handlers/hello.ts",
Map.of("name", "world")
);
// List the registered engine types:
String types = Engine.listEngines();Methods
execute()
Executes a registry file under the given engine type with an empty parameter map.
javapublic static Object execute(String type, String project, String filePath) throws Exception;
Parameter Type Description typeStringThe engine type — e.g. "javascript","python".projectStringThe project name under /registry/public/.filePathStringThe path to the script file inside the project. Returns
- Type:
Object- Description: The engine's natural return value.
execute()
Executes a registry file under the given engine type, passing a parameter map into the engine's global scope.
javapublic static Object execute(String type, String project, String filePath, Map<Object, Object> parameters) throws Exception;
Parameter Type Description typeStringThe engine type — e.g. "javascript","python".projectStringThe project name under /registry/public/.filePathStringThe path to the script file inside the project. parametersMap<Object, Object>Values to expose in the engine's global scope. Returns
- Type:
Object- Description: The engine's natural return value.
execute()
Full-form execute with a path parameter, parameter map, and a debug toggle.
javapublic static Object execute(String type, String project, String filePath, String pathParam, Map<Object, Object> parameters, boolean debug) throws Exception;
Parameter Type Description typeStringThe engine type — e.g. "javascript","python".projectStringThe project name under /registry/public/.filePathStringThe path to the script file inside the project. pathParamStringAn optional path parameter forwarded into the engine. parametersMap<Object, Object>Values to expose in the engine's global scope. debugbooleanWhen true, runs the engine in debug mode (breakpoints honoured).Returns
- Type:
Object- Description: The engine's natural return value.
listEngines()
Returns the set of registered scripting-engine type names.
javapublic static String listEngines();Returns
- Type:
String- Description: A serialized list of engine type identifiers (e.g.
"javascript","python").