From 556f7f3ce14bfbd772f5bf9675543a2f533551ec Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Thu, 14 Mar 2024 17:50:53 +0100 Subject: [PATCH 01/14] [KOGITO-9454] Documenting java flow library --- serverlessworkflow/modules/ROOT/nav.adoc | 1 + .../java-embedded-workflows.adoc | 106 ++++++++++++++++++ .../modules/ROOT/pages/index.adoc | 8 ++ 3 files changed, 115 insertions(+) create mode 100644 serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc diff --git a/serverlessworkflow/modules/ROOT/nav.adoc b/serverlessworkflow/modules/ROOT/nav.adoc index f4e96b381..9f1b9ebc5 100644 --- a/serverlessworkflow/modules/ROOT/nav.adoc +++ b/serverlessworkflow/modules/ROOT/nav.adoc @@ -23,6 +23,7 @@ * Getting Started ** xref:getting-started/getting-familiar-with-our-tooling.adoc[] ** xref:getting-started/create-your-first-workflow-service-with-kn-cli-and-vscode.adoc[] +** xref:getting-started/java-embedded-workflows.adoc[] * Core Concepts ** xref:core/cncf-serverless-workflow-specification-support.adoc[] ** xref:core/handling-events-on-workflows.adoc[Events] diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc new file mode 100644 index 000000000..778ea8ebc --- /dev/null +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -0,0 +1,106 @@ += Workflow embedded execution in Java + +This guide show cases how to execute a link:{spec_doc_url}[CNCF Serverless Workflow] definition using a standard java virtual machine and a small set of Maven dependencies. Therefore, it is assumed you are fluent both in Java and Maven. +The workflow definition to be executed can be read from a .json or .yaml file or programatically defined using the {product_name} fluent API. + +[[embedded-file-quick-start]] +== Hello world (using existing definition file) + +First step is to setup an empty Maven project with the following dependency. + +[source,xml] +---- + + org.kie.kogito + kogito-serverless-workflow-executor-core + RELEASE + +---- + +Also, you might optionally add `simple logger for java` dependency to avoid using `System.out.println` + +[source,xml] +---- + + org.slf4j + slf4j-simple + 1.7.36 + +---- + +Let's assume you already have a workflow definition written in a JSON file in your project root. For example, link:{kogito_sw_examples_url}/serverless-workflow-hello-world/src/main/resources/hello.sw.json[Hello World] definition. To execute it, you need to write the following main java class (standard imports and java package declaration are intentionally skipped for brevity) + +[source,java] +---- +import org.kie.kogito.serverless.workflow.executor.StaticWorkflowApplication; +import org.kie.kogito.serverless.workflow.models.JsonNodeModel; +import org.kie.kogito.serverless.workflow.utils.ServerlessWorkflowUtils; +import org.kie.kogito.serverless.workflow.utils.WorkflowFormat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.serverlessworkflow.api.Workflow; + +public class DefinitionFileExecutor { + private static final Logger logger = LoggerFactory.getLogger(DefinitionFileExecutor.class); + + public static void main(String[] args) throws IOException { + try (Reader reader = new FileReader("hello.sw.json"); <1> + StaticWorkflowApplication application = StaticWorkflowApplication.create()) { <2> + Workflow workflow = ServerlessWorkflowUtils.getWorkflow(reader, WorkflowFormat.JSON); <3> + JsonNodeModel result = application.execute(workflow, Collections.emptyMap()); <4> + logger.info("Workflow execution result is {}", result.getWorkflowdata()); <5> + } + } +} +---- +<1> Reads the workflow file definition from the project root directory +<2> Creates a static workflow application object. It is done within the try block since the instance is `Closeable`. This is the reference that allow you to execute workflow definitions. +<3> Reads the Serverless Workflow Java SDK `Workflow` object from the file. +<4> Execute the workflow, passing `Workflow` reference and no parameters (an empty Map). The result of the workflow execution: process instance id and workflow output model, can accessed using `result` variable. +<5> Prints the workflow model in the configured standard output. + +If you compile and execute this java class, you will see the following log in your configured standard output +---- +Workflow execution result is {"greeting":"Hello World","mantra":"Serverless Workflow is awesome!"} +---- + +[[embedded-fluent-quick-start]] +== Hello world (using fluent API) + +Using the same Maven setup than in the previous section, you can programatically generate that workflow definition rather than loading it from a file definition by using link:{kogito_runtimes_url}/kogito-serverless-workflow/kogito-serverless-workflow-fluent/src/main/java/org/kie/kogito/serverless/workflow/fluent[fluent API] + +Therefore, you can modify the previous example in a way that generates exactly the same output when it is executed, but rather creating a `FileReader` that reads the `Workflow` object, we create the `Workflow` object using java statements. The resulting modified main method is the following + +[source,java] +---- + try (StaticWorkflowApplication application = StaticWorkflowApplication.create()) { + Workflow workflow = workflow("HelloWorld"). <1> + start( <2> + inject( <3> + jsonObject().put("greeting", "Hello World").put("mantra","Serverless Workflow is awesome!"))) <4> + .end() <5> + .build(); <6> + logger.info("Workflow execution result is {}",application.execute(workflow, Collections.emptyMap()).getWorkflowdata()); <7> + } +---- +<1> Creates a workflow which name is `HelloWorld` +<2> Indicate that you are going to specify the start state +<3> A Inject state is the start state +<4> Inject state accepts static json, therefore this line creates the JSON data +<5> End the workflow definition +<6> Build the workflow definition +<7> Execute and print as in previous example + + +== Further reading + +You can find additional and commented examples of fluent API usage (including jq expression evaluation and orchestration of rest services) link:{{kogito_sw_examples_url}/sonata-workflow-fluent[here] + +== Additional resources + +include::../../pages/_common-content/report-issue.adoc[] + +ifeval::["{kogito_version_redhat}" != ""] +include::../../pages/_common-content/downstream-project-setup-instructions.adoc[] +endif::[] \ No newline at end of file diff --git a/serverlessworkflow/modules/ROOT/pages/index.adoc b/serverlessworkflow/modules/ROOT/pages/index.adoc index dd64217f4..2797c1ff4 100644 --- a/serverlessworkflow/modules/ROOT/pages/index.adoc +++ b/serverlessworkflow/modules/ROOT/pages/index.adoc @@ -54,6 +54,14 @@ xref:getting-started/create-your-first-workflow-service-with-kn-cli-and-vscode.a An all-in-one starting guide. Learn how to create, run & deploy your first {product_name} project on your local environment. -- +[.card] +-- +[.card-title] +xref:getting-started/java-embedded-workflows.adoc[] +[.card-description] +Learn about how to executed your workflows (existing files or define them programatically) using Java and Maven. +-- + [.card-section] == Core Concepts From 08bdadefd18e1b6a85161e091364a45e721131d0 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:49:10 +0100 Subject: [PATCH 02/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc Co-authored-by: Kalyani Desai <43639538+kaldesai@users.noreply.github.com> --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index 778ea8ebc..b7d9de1a9 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -17,7 +17,7 @@ First step is to setup an empty Maven project with the following dependency. ---- -Also, you might optionally add `simple logger for java` dependency to avoid using `System.out.println` +Also, you might optionally add a `simple logger for java` dependency to avoid using `System.out.println` [source,xml] ---- From 66078f69a90d39de6daf0d6792bc290aba03d2e9 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:50:00 +0100 Subject: [PATCH 03/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc Co-authored-by: Kalyani Desai <43639538+kaldesai@users.noreply.github.com> --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index b7d9de1a9..2d5a673c1 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -28,7 +28,7 @@ Also, you might optionally add a `simple logger for java` dependency to avoid us ---- -Let's assume you already have a workflow definition written in a JSON file in your project root. For example, link:{kogito_sw_examples_url}/serverless-workflow-hello-world/src/main/resources/hello.sw.json[Hello World] definition. To execute it, you need to write the following main java class (standard imports and java package declaration are intentionally skipped for brevity) +Let's assume you already have a workflow definition written in a JSON file in your root project. For example, link:{kogito_sw_examples_url}/serverless-workflow-hello-world/src/main/resources/hello.sw.json[Hello World] definition. To execute it, you must write the following main Java class (standard imports and Java package declaration are intentionally skipped for briefness) [source,java] ---- From 42514ce4e86b400aef9ae7c6c43ddaf53192bcdb Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:50:18 +0100 Subject: [PATCH 04/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc Co-authored-by: Kalyani Desai <43639538+kaldesai@users.noreply.github.com> --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index 2d5a673c1..6ac397ca0 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -1,6 +1,6 @@ = Workflow embedded execution in Java -This guide show cases how to execute a link:{spec_doc_url}[CNCF Serverless Workflow] definition using a standard java virtual machine and a small set of Maven dependencies. Therefore, it is assumed you are fluent both in Java and Maven. +This guide uses a standard Java virtual machine and a small set of Maven dependencies to execute a link:{spec_doc_url}[CNCF Serverless Workflow] definition. Therefore, it is assumed you are fluent both in Java and Maven. The workflow definition to be executed can be read from a .json or .yaml file or programatically defined using the {product_name} fluent API. [[embedded-file-quick-start]] From 27f9a30f9ced850e00e1097f07211e918425abdb Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:50:34 +0100 Subject: [PATCH 05/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc Co-authored-by: Kalyani Desai <43639538+kaldesai@users.noreply.github.com> --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index 6ac397ca0..5c9150dc0 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -1,7 +1,7 @@ = Workflow embedded execution in Java This guide uses a standard Java virtual machine and a small set of Maven dependencies to execute a link:{spec_doc_url}[CNCF Serverless Workflow] definition. Therefore, it is assumed you are fluent both in Java and Maven. -The workflow definition to be executed can be read from a .json or .yaml file or programatically defined using the {product_name} fluent API. +The workflow definition to be executed can be read from a `.json` or `.yaml` file or programmatically defined using the {product_name} fluent API. [[embedded-file-quick-start]] == Hello world (using existing definition file) From 1630f4678a8bc933f66cd2ec72cbb785a15e9efe Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:50:44 +0100 Subject: [PATCH 06/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc Co-authored-by: Kalyani Desai <43639538+kaldesai@users.noreply.github.com> --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index 5c9150dc0..6dbdbfaae 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -6,7 +6,7 @@ The workflow definition to be executed can be read from a `.json` or `.yaml` fil [[embedded-file-quick-start]] == Hello world (using existing definition file) -First step is to setup an empty Maven project with the following dependency. +The first step is to set up an empty Maven project with the following dependency: [source,xml] ---- From 5cc615f2057386492acec3f2f8c8281e16817f5f Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:50:54 +0100 Subject: [PATCH 07/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc Co-authored-by: Kalyani Desai <43639538+kaldesai@users.noreply.github.com> --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index 6dbdbfaae..a909ad4c9 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -60,7 +60,7 @@ public class DefinitionFileExecutor { <4> Execute the workflow, passing `Workflow` reference and no parameters (an empty Map). The result of the workflow execution: process instance id and workflow output model, can accessed using `result` variable. <5> Prints the workflow model in the configured standard output. -If you compile and execute this java class, you will see the following log in your configured standard output +If you compile and execute this Java class, you will see the following log in your configured standard output: ---- Workflow execution result is {"greeting":"Hello World","mantra":"Serverless Workflow is awesome!"} ---- From ed5f24c7a497bebe0516e4d89d1251ce0518891c Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:51:08 +0100 Subject: [PATCH 08/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc Co-authored-by: Kalyani Desai <43639538+kaldesai@users.noreply.github.com> --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index a909ad4c9..e03961ef4 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -68,7 +68,7 @@ Workflow execution result is {"greeting":"Hello World","mantra":"Serverless Work [[embedded-fluent-quick-start]] == Hello world (using fluent API) -Using the same Maven setup than in the previous section, you can programatically generate that workflow definition rather than loading it from a file definition by using link:{kogito_runtimes_url}/kogito-serverless-workflow/kogito-serverless-workflow-fluent/src/main/java/org/kie/kogito/serverless/workflow/fluent[fluent API] +Using the same Maven setup as in the previous section, you can programmatically generate that workflow definition rather than loading it from a file definition by using the link:{kogito_runtimes_url}/kogito-serverless-workflow/kogito-serverless-workflow-fluent/src/main/java/org/kie/kogito/serverless/workflow/fluent[fluent API] Therefore, you can modify the previous example in a way that generates exactly the same output when it is executed, but rather creating a `FileReader` that reads the `Workflow` object, we create the `Workflow` object using java statements. The resulting modified main method is the following From 44ef97df0c59f2a6df7b16559508b0dc94788f9e Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:51:26 +0100 Subject: [PATCH 09/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc Co-authored-by: Kalyani Desai <43639538+kaldesai@users.noreply.github.com> --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index e03961ef4..d14cb3c3b 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -70,7 +70,7 @@ Workflow execution result is {"greeting":"Hello World","mantra":"Serverless Work Using the same Maven setup as in the previous section, you can programmatically generate that workflow definition rather than loading it from a file definition by using the link:{kogito_runtimes_url}/kogito-serverless-workflow/kogito-serverless-workflow-fluent/src/main/java/org/kie/kogito/serverless/workflow/fluent[fluent API] -Therefore, you can modify the previous example in a way that generates exactly the same output when it is executed, but rather creating a `FileReader` that reads the `Workflow` object, we create the `Workflow` object using java statements. The resulting modified main method is the following +Therefore, you can modify the previous example to generate the same output when it is executed, but rather than creating a `FileReader` that reads the `Workflow` object, we create the `Workflow` object using Java statements. The resulting modified main method is the following [source,java] ---- From ce55ec9c3f9faf0f6f69a692f34ae7bcab210a3b Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Tue, 19 Mar 2024 12:04:43 +0100 Subject: [PATCH 10/14] [KOGITO-9454] Minor correction --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index d14cb3c3b..1b099af2a 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -28,7 +28,7 @@ Also, you might optionally add a `simple logger for java` dependency to avoid us ---- -Let's assume you already have a workflow definition written in a JSON file in your root project. For example, link:{kogito_sw_examples_url}/serverless-workflow-hello-world/src/main/resources/hello.sw.json[Hello World] definition. To execute it, you must write the following main Java class (standard imports and Java package declaration are intentionally skipped for briefness) +Let's assume you already have a workflow definition written in a JSON file in your project root directory. For example, link:{kogito_sw_examples_url}/serverless-workflow-hello-world/src/main/resources/hello.sw.json[Hello World] definition. To execute it, you must write the following main Java class (standard Java imports and package declaration are intentionally skipped for briefness) [source,java] ---- From a696561a4986171d830655ae1b234010bda4a1b1 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:06:01 +0100 Subject: [PATCH 11/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dominik Hanák --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index 1b099af2a..d73571aaf 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -17,7 +17,7 @@ The first step is to set up an empty Maven project with the following dependency ---- -Also, you might optionally add a `simple logger for java` dependency to avoid using `System.out.println` +This guide uses [slf4j dependency](https://mvnrepository.com/artifact/org.slf4j/slf4j-simple). Consider using any other logger for java to avoid using `System.out.println` [source,xml] ---- From 82de3061121181294aaa4b50dae5f5c0e99064a3 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:06:10 +0100 Subject: [PATCH 12/14] Update serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dominik Hanák --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index d73571aaf..66bb1817b 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -2,6 +2,9 @@ This guide uses a standard Java virtual machine and a small set of Maven dependencies to execute a link:{spec_doc_url}[CNCF Serverless Workflow] definition. Therefore, it is assumed you are fluent both in Java and Maven. The workflow definition to be executed can be read from a `.json` or `.yaml` file or programmatically defined using the {product_name} fluent API. +.Prerequisites +. Install https://openjdk.org/[OpenJDK] {java_min_version} +. Install https://maven.apache.org/index.html[Apache Maven] {maven_min_version}. [[embedded-file-quick-start]] == Hello world (using existing definition file) From 34aa8290e27a717c78fa08ddcff10c47aa9b7fb4 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Wed, 20 Mar 2024 15:39:20 +0100 Subject: [PATCH 13/14] [KOGITO-9454] Dominik comments --- serverlessworkflow/antora.yml | 1 + .../java-embedded-workflows.adoc | 22 ++----------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/serverlessworkflow/antora.yml b/serverlessworkflow/antora.yml index a92f79b68..0aff48584 100644 --- a/serverlessworkflow/antora.yml +++ b/serverlessworkflow/antora.yml @@ -135,3 +135,4 @@ asciidoc: workflow_instance: workflow instance workflow_instances: workflow instances sonataflow_devmode_devui_url: /q/dev/org.kie.kogito.kogito-quarkus-serverless-workflow-devui/ + swf_executor_core_maven_repo: https://mvnrepository.com/artifact/org.kie.kogito/kogito-serverless-workflow-executor-core diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index 66bb1817b..f10af3533 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -9,27 +9,9 @@ The workflow definition to be executed can be read from a `.json` or `.yaml` fil [[embedded-file-quick-start]] == Hello world (using existing definition file) -The first step is to set up an empty Maven project with the following dependency: +The first step is to set up an empty Maven project that includes link:{swf_executor_core_maven_repo}[Workflow executor core] dependency. -[source,xml] ----- - - org.kie.kogito - kogito-serverless-workflow-executor-core - RELEASE - ----- - -This guide uses [slf4j dependency](https://mvnrepository.com/artifact/org.slf4j/slf4j-simple). Consider using any other logger for java to avoid using `System.out.println` - -[source,xml] ----- - - org.slf4j - slf4j-simple - 1.7.36 - ----- +This guide also uses [slf4j dependency](https://mvnrepository.com/artifact/org.slf4j/slf4j-simple) to avoid using `System.out.println` Let's assume you already have a workflow definition written in a JSON file in your project root directory. For example, link:{kogito_sw_examples_url}/serverless-workflow-hello-world/src/main/resources/hello.sw.json[Hello World] definition. To execute it, you must write the following main Java class (standard Java imports and package declaration are intentionally skipped for briefness) From 7eee314520f2c5ace694559663e4d1daabc11bea Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Wed, 20 Mar 2024 17:42:28 +0100 Subject: [PATCH 14/14] [KOGITO-9454] Update example reference --- .../ROOT/pages/getting-started/java-embedded-workflows.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc index f10af3533..575b289c9 100644 --- a/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc +++ b/serverlessworkflow/modules/ROOT/pages/getting-started/java-embedded-workflows.adoc @@ -80,7 +80,7 @@ Therefore, you can modify the previous example to generate the same output when == Further reading -You can find additional and commented examples of fluent API usage (including jq expression evaluation and orchestration of rest services) link:{{kogito_sw_examples_url}/sonata-workflow-fluent[here] +You can find additional and commented examples of fluent API usage (including jq expression evaluation and orchestration of rest services) link:{{kogito_sw_examples_url}/sonataflow-fluent[here] == Additional resources