Skip to content

Commit 8190b0c

Browse files
committed
2 parents a719061 + f1f7aa8 commit 8190b0c

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# spark-docker-executor-java
2+
Script Task Executor Engine with Java Runtime
3+
4+
This docker image provides a sandboxed protected environment to run custom Java scripts that are written in ProcessMaker Spark.
5+
6+
## How to use
7+
The execution requires a data.json, config.json and an output.json file be present on the host system. The data.json represents the
8+
Request instance data. The config.json represents configuration specific for this Script Task. And the output.json should be a blank
9+
file that will be populated by the successful output of the script task. The script task is represented by a script.Java file.
10+
It is the responsibility of the caller to have these files prepared before executing the engine via command line (or docker API).
11+
12+
13+
### Example data.json
14+
```json
15+
{
16+
"x": 100,
17+
"y": 200
18+
}
19+
```
20+
21+
### Example Script Task
22+
```Java
23+
import ProcessMaker_Client.ApiClient;
24+
import java.io.*;
25+
import java.util.Map;
26+
27+
public class Script implements BaseScript {
28+
29+
/**
30+
* This code receives a data.x and data.y and returns data.z = data.x + data.y
31+
*/
32+
public void execute(Map<String, Object> data, Map<String, Object> config, Map<String, Object> output) {
33+
//Map<String, Object> data = Spark.data();
34+
Double x = (Double) data.get("x");
35+
Double y = (Double) data.get("y");
36+
Double z = x + y;
37+
output.put("z", z);
38+
}
39+
}
40+
```
41+
42+
### Example output.json
43+
```json
44+
{"z":300.0}
45+
```
46+
47+
## Command Line Usage
48+
```bash
49+
$ docker run -v <path to local data.json>:/opt/executor/data.json \
50+
-v <path to local config.json>:/opt/executor/config.json \
51+
-v <path to local script.Java>:/opt/executor/script.Java \
52+
-v <path to local output.json>:/opt/executor/output.json \
53+
processmaker/spark-docker-executor-java:dev-master \
54+
/opt/executor/run.sh
55+
```

0 commit comments

Comments
 (0)