Class Task<T>
java.lang.Object
java.util.concurrent.CompletableFuture<T>
nl.bimbase.bimworks.client.Task<T>
- All Implemented Interfaces:
CompletionStage<T>, Future<T>
- Direct Known Subclasses:
AddModelCheckDefinition, AddModelCheckDefinitionSet, DownloadCheckResultsAsBcfDirect, DownloadCheckResultsAsBcfInput, GetModelCheckDefinitionByName, GetModelCheckDefinitionSetByNameInput, GetModelCheckResultsTask, GetModelReportByModelCheckSetUuidTask, GetModelReportTask, ListModelCheckDefinitionsInput, ListModelCheckResultsTask, ModelChecksAvailabilityTask, RunChecksTask, RunCheckTask, RunIdsCheckTask, UpdateModelCheckDefinition
A server task exposed as a
CompletableFuture. Call executeAsync() to send the
request; the future is completed from the transport callbacks when the response (or an error)
arrives, so the full CompletableFuture API works: get(), get(long, TimeUnit),
join(), CompletableFuture.isDone(), thenApply, whenComplete, etc.
Failure is reported through the future: a server error or transport failure completes the
future exceptionally (typically with an ExecuteException carrying the server's error
code), which get() surfaces as an ExecutionException and join() as a
CompletionException. A send failure in executeAsync() completes the future
immediately — it is never silently swallowed.
The blocking get() and join() do not wait forever: they are bounded by the
request's own timeout (settable via setTimeOut(long, TimeUnit), with a per-task default
from createRequest()), after which they fail with a TaskTimeoutException cause.
CompletableFuture.cancel(boolean) only completes this future; it does not abort the
task on the server.
-
Nested Class Summary
Nested classes/interfaces inherited from class CompletableFuture
CompletableFuture.AsynchronousCompletionTask -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Tconvert(nl.sascom.backplane.common.Response response) Converts the rawResponseinto this task's result type.nl.sascom.backplane.common.ClientTaskcreateAsyncTask(BimWorksClient bimWorksClient) nl.sascom.backplane.common.Requestnl.sascom.backplane.common.RequestcreateRequest(int defaultTimeOut, TimeUnit defaultTimeUnit) Sends the request.get()Waits for the result, bounded by the request's own timeout.nl.sascom.backplane.client.AsyncTasknl.sascom.backplane.common.Requestjoin()LikeCompletableFuture.join(), but bounded by the request's own timeout (seeget()) and responsive to interrupts, which are rethrown wrapped in aCompletionExceptionafter restoring the interrupt flag.voidsetProgressListener(nl.sascom.backplane.common.ProgressListener progressListener) voidsetTimeOut(long timeOutValue, TimeUnit timeOutUnit) Methods inherited from class CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, failedFuture, failedStage, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
-
Constructor Details
-
Task
-
-
Method Details
-
createRequest
public nl.sascom.backplane.common.Request createRequest() -
createRequest
public nl.sascom.backplane.common.Request createRequest(int defaultTimeOut, TimeUnit defaultTimeUnit) -
setTimeOut
-
createAsyncTask
-
getRequest
public nl.sascom.backplane.common.Request getRequest() -
setProgressListener
public void setProgressListener(nl.sascom.backplane.common.ProgressListener progressListener) -
convert
Converts the rawResponseinto this task's result type. Called once, on the thread that delivers the response. The default implementation returns the response's object output; tasks with a differently shaped result override this. Throwing here completes the future exceptionally.- Throws:
Exception
-
executeAsync
Sends the request. Idempotent: the request is sent once, no matter how often (or from how many threads) this is called. The returned future completes when the response arrives; if sending fails, it completes exceptionally right away instead of leaving callers to run into the request timeout. -
get
Waits for the result, bounded by the request's own timeout. On timeout the future is failed with aTaskTimeoutException(surfaced as this method'sExecutionExceptioncause), unless the response arrived in the meantime.- Specified by:
getin interfaceFuture<T>- Overrides:
getin classCompletableFuture<T>- Throws:
InterruptedExceptionExecutionException
-
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
getin interfaceFuture<T>- Overrides:
getin classCompletableFuture<T>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
join
LikeCompletableFuture.join(), but bounded by the request's own timeout (seeget()) and responsive to interrupts, which are rethrown wrapped in aCompletionExceptionafter restoring the interrupt flag.- Overrides:
joinin classCompletableFuture<T>
-
getClientTask
- Throws:
BimWorksException
-
getBimWorksClient
-