diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/events/EmittedEventDecorator.java b/impl/core/src/main/java/io/serverlessworkflow/impl/events/EmittedEventDecorator.java index 728b100d..c73dce1a 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/events/EmittedEventDecorator.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/events/EmittedEventDecorator.java @@ -20,6 +20,15 @@ import io.serverlessworkflow.impl.TaskContext; import io.serverlessworkflow.impl.WorkflowContext; +/** + * Interface for decorating {@link CloudEventBuilder} objects. + * + *

Implementations should be loaded via ServiceLoader and are sorted by priority in ascending + * order (lower priority numbers executed first). Decorators are applied in sequence, where later + * decorators can override configurations set by earlier decorators. + * + * @see ServicePriority + */ public interface EmittedEventDecorator extends ServicePriority { void decorate( diff --git a/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/HttpExecutor.java b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/HttpExecutor.java index b237393f..7c40d5a9 100644 --- a/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/HttpExecutor.java +++ b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/HttpExecutor.java @@ -77,11 +77,10 @@ public CompletableFuture apply( Builder request = target.request(); for (RequestDecorator requestDecorator : requestDecorators) { - requestDecorator.decorate(request, workflow, taskContext, input); + requestDecorator.decorate(request, workflow, taskContext); } - headersMap.ifPresent( - h -> h.apply(workflow, taskContext, input).forEach((k, v) -> request.header(k, v))); + headersMap.ifPresent(h -> h.apply(workflow, taskContext, input).forEach(request::header)); return CompletableFuture.supplyAsync( () -> requestFunction.apply(request, uri, workflow, taskContext, input), workflow.definition().application().executorService()); diff --git a/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/RequestDecorator.java b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/RequestDecorator.java index bf7ce631..c770e2cf 100644 --- a/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/RequestDecorator.java +++ b/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/RequestDecorator.java @@ -18,7 +18,6 @@ import io.serverlessworkflow.impl.ServicePriority; import io.serverlessworkflow.impl.TaskContext; import io.serverlessworkflow.impl.WorkflowContext; -import io.serverlessworkflow.impl.WorkflowModel; import jakarta.ws.rs.client.Invocation; /** @@ -38,11 +37,7 @@ public interface RequestDecorator extends ServicePriority { * @param requestBuilder the request builder to decorate * @param workflowContext the workflow context * @param taskContext the task context - * @param workflowModel the input data */ void decorate( - Invocation.Builder requestBuilder, - WorkflowContext workflowContext, - TaskContext taskContext, - WorkflowModel workflowModel); + Invocation.Builder requestBuilder, WorkflowContext workflowContext, TaskContext taskContext); }