Provides the Java API for the Serverless Workflow Specification
With the SDK you can:
Serverless Workflow Java SDK is not a workflow runtime implementation but can be used by Java runtime implementations to parse workflow definitions.
Latest Releases | Conformance to spec version |
---|---|
7.0.0.Final | v1.0.0 |
5.0.0.Final | v0.8 |
4.0.5.Final | v0.8 |
3.0.0.Final | v0.7 |
2.0.0.Final | v0.6 |
1.0.3.Final | v0.5 |
Note that 6.0.0.Final, which will be the one for specification version 0.9, is skipped intentionally in case someone want to work on it.
SDK Version | JDK Version |
---|---|
5.0.0 and after | 11 |
4.0.x and before | 8 |
To build project and run tests locally:
git clone https://github.com/serverlessworkflow/sdk-java.git
mvn clean install
The project uses Google's code styleguide. Your changes should be automatically formatted during the build.
Add the following dependencies to your pom.xml dependencies
section:
<dependency>
<groupId>io.serverlessworkflow</groupId>
<artifactId>serverlessworkflow-api</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
Add the following dependencies to your build.gradle dependencies
section:
implementation("io.serverlessworkflow:serverlessworkflow-api:7.0.0-SNAPSHOT")
You can create a Workflow instance from JSON/YAML source:
Let's say you have a simple YAML based workflow definition in a file name simple.yaml
located in your working dir:
document:
dsl: 1.0.0-alpha1
namespace: default
name: implicit-sequence
do:
setRed:
set:
colors: '${ .colors + [ "red" ] }'
setGreen:
set:
colors: '${ .colors + [ "green" ] }'
setBlue:
set:
colors: '${ .colors + [ "blue" ] }'
To parse it and create a Workflow instance you can do:
try (InputStream in = new FileInputStream("simple.yaml")) {
Workflow workflow = WorkflowReader.readWorkflow (in, WorkflowFormat.YAML);
// Once you have the Workflow instance you can use its API to inspect it
}
Given a workflow definition, you can store it using JSON or YAML format.
For example, to store a workflow using json format in a file called simple.json
, you write
try (OutputStream out = new FileOutputStream("simple.json")) {
WorkflowWriter.writeWorkflow(out, workflow, WorkflowFormat.JSON);
}