diff --git a/spec/src/main/asciidoc/microprofile-lra-spec.adoc b/spec/src/main/asciidoc/microprofile-lra-spec.adoc index 8601cf1a..6453f009 100644 --- a/spec/src/main/asciidoc/microprofile-lra-spec.adoc +++ b/spec/src/main/asciidoc/microprofile-lra-spec.adoc @@ -635,6 +635,8 @@ MUST adhere to these predefined signatures: ** <> ** `javax.ws.rs.core.Response`: handled similarly as for <> +** `java.util.concurrent.CompletionStage`: with the parameter of any of the previously +defined types * *Arguments*: up to 2 arguments of types in this order: ** `java.net.URI`: representing current LRA context identification ** `java.net.URI`: representing potentional parent LRA context identification @@ -652,10 +654,10 @@ Examples of valid signatures: public void compensate(URI lraId, URI parentId) @Complete -public Response complete() +public Response complete(URI lraId) @Status -public ParticipantStatus status(URI lraId) +public CompletionStage status(URI lraId) ---- Examples of invalid signatures: diff --git a/tck/src/main/java/org/eclipse/microprofile/lra/tck/participant/nonjaxrs/ValidLRAParticipant.java b/tck/src/main/java/org/eclipse/microprofile/lra/tck/participant/nonjaxrs/ValidLRAParticipant.java index e73420c2..d30731ac 100644 --- a/tck/src/main/java/org/eclipse/microprofile/lra/tck/participant/nonjaxrs/ValidLRAParticipant.java +++ b/tck/src/main/java/org/eclipse/microprofile/lra/tck/participant/nonjaxrs/ValidLRAParticipant.java @@ -38,6 +38,8 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.net.URI; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; @@ -93,13 +95,15 @@ public void completeWithException(URI lraId, URI parentId) { } @Compensate - public ParticipantStatus compensate(URI lraId) { - verifyLRAId(lraId); + public CompletionStage compensate(URI lraId) { + return CompletableFuture.supplyAsync(() -> { + verifyLRAId(lraId); - compensatedCount.incrementAndGet(); + compensatedCount.incrementAndGet(); - LOGGER.info(String.format("LRA id '%s' was compensated", lraId)); - return ParticipantStatus.Compensating; + LOGGER.info(String.format("LRA id '%s' was compensated", lraId)); + return ParticipantStatus.Compensating; + }); } @Status