From 51a97d8000ff9f16cc4df0876736a0eea84f0293 Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Tue, 12 Sep 2023 14:17:00 -0400 Subject: [PATCH] start adding content for java how to Signed-off-by: Hannah Hunter --- .../workflow/howto-author-workflow.md | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md index 3ca68fde5..eaf16c8cf 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/howto-author-workflow.md @@ -122,33 +122,36 @@ public class ProcessPaymentActivity : WorkflowActivity -Define the workflow activities you'd like your workflow to perform. - -The activities called in the example below are: -- `need`: Receive notification of a new order. - -### [activity] +Define the workflow activities you'd like your workflow to perform. Activities are wrapped in an `ActivityWrapper` class for the `TaskActivityFactory`. In the following example, the activity wrapper and its constructor are defined: ```java -todo +public class ActivityWrapper implements TaskActivityFactory { + private final Constructor activityConstructor; + private final String name; + + public ActivityWrapper(Class clazz) { + this.name = clazz.getCanonicalName(); + try { + this.activityConstructor = clazz.getDeclaredConstructor(); + } catch (NoSuchMethodException e) { + throw new RuntimeException( + String.format("No constructor found for activity class '%s'.", this.name), e + ); + } + } ``` -[See the full `todo` workflow activity example.](todo) - -### [activity] +Register a workflow activity object: ```java -todo -``` -[See the full `todo` workflow activity example.](todo) - -### [todo] - -```java -todo + public void registerActivity(Class clazz) { + this.builder = this.builder.addActivity( + new ActivityWrapper<>(clazz) + ); + } ``` -[See the full `todo` workflow activity example.](todo) +[See a full Java SDK workflow activity example.](https://github.com/dapr/java-sdk/blob/master/sdk-workflows/src/main/java/io/dapr/workflows) {{% /codetab %}}