Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Java SDK for Serverless Workflow

License

NotificationsYou must be signed in to change notification settings

serverlessworkflow/sdk-java

Repository files navigation

Verify JAVA SDKDeploy JAVA SDKGitpod ready-to-code

Serverless Workflow Specification - Java SDK

Provides the Java API for theServerless Workflow Specification

With the SDK you can:

  • Read workflow JSON and YAML definitions
  • Write workflow definitions in JSON and YAML formats.
  • Test your workflow definitions using the reference implementation.

Status

Latest ReleasesConformance to spec version
7.0.0.Finalv1.0.0
5.0.0.Finalv0.8
4.0.5.Finalv0.8
3.0.0.Finalv0.7
2.0.0.Finalv0.6
1.0.3.Finalv0.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.

JDK Version

SDK VersionJDK Version
7.0.0 and after17
5.0.0 and after11
4.0.x and before8

Getting Started

Building SNAPSHOT locally

To build project and run tests locally:

git clone https://github.com/serverlessworkflow/sdk-java.gitmvn clean install

The project usesGoogle's code styleguide.Your changes should be automatically formatted during the build.

Maven projects:

Add the following dependencies to your pom.xmldependencies section:

<dependency>    <groupId>io.serverlessworkflow</groupId>    <artifactId>serverlessworkflow-api</artifactId>    <version>7.0.0.Final</version></dependency>

Gradle projects:

Add the following dependencies to your build.gradledependencies section:

implementation("io.serverlessworkflow:serverlessworkflow-api:7.0.0.Final")

How to Use

There are, roughly speaking, two kind of users of this SDK:

  • Those ones interested on implementing their own runtime using Java.
  • Those ones interested on using the provided runtime reference implementation.

Implementing your own runtime

For those ones interested on implementing their own runtime, this SDK provides an easy way to load an in memory representation of a given workflow definition.This in-memory representation consists of a hierarchy of POJOS directly generated from the Serverless Workflow specificationschema, which ensures the internal representation is aligned with the specification schema. The root of the hierarchy isio.serverlessworkflow.api.types.Workflow class

Reading workflow definition from JSON/YAML source

You can read a Workflow definition from JSON/YAML source:

Let's say you have a simple YAML based workflow definition in a file namesimple.yaml located in your working dir:

document:dsl:1.0.0-alpha1namespace:defaultname:implicit-sequencedo:setRed:set:colors:'${ .colors + [ "red" ] }'setGreen:set:colors:'${ .colors + [ "green" ] }'setBlue:set:colors:'${ .colors + [ "blue" ] }'

To parse it and get a Workflow instance you can do:

try (InputStreamin =newFileInputStream("simple.yaml")) {Workflowworkflow =WorkflowReader.readWorkflow (in,WorkflowFormat.YAML);// Once you have the Workflow instance you can use its API to inspect it}

By default, Workflows are not validated against the schema (performance being the priority). If you want to enable validation, you can do that by using:

try (InputStreamin =newFileInputStream("simple.yaml")) {Workflowworkflow =WorkflowReader.validation().readWorkflow (in,WorkflowFormat.YAML);// Once you have the Workflow instance you can use its API to inspect it}

For additional reading helper methods, including the one to read a workflow definition from classpath, checkWorkflowReader class.

Writing workflow definition to a JSON/YAML target

Given a Workflow instance, you can store it using JSON or YAML format.For example, to store a workflow using json format in a file calledsimple.json, you write

try (OutputStreamout =newFileOutputStream("simple.json")) {WorkflowWriter.writeWorkflow(out,workflow,WorkflowFormat.JSON);}

For additional writing helper methods, checkWorkflowWriter class.

Reference implementation

The reference implementation provides a ready-to-use runtime that supports the Serverless Workflow Specification. It includes a workflow execution engine, validation utilities, and illustrative examples to help you quickly test and deploy your workflows. For details on usage, configuration, and supported features, seereadme.


[8]ページ先頭

©2009-2025 Movatter.jp