Reference·Java · nl.bimbase.bimworks.clientJava

Task

CLASS in nl.bimbase.bimworks.client.

API catalogue · nl.bimbase.bimworks.client · CLASS

Java#
abstract public class Task<T>

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(), #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.

Type parameters#

Name Constraint Description
T java.lang.Object

Inheritance and interfaces#

  • java.util.concurrent.CompletableFuture<T>

Members#

Member Kind Description
Task(BimWorksClient) CONSTRUCTOR
createRequest() METHOD
createRequest(int, TimeUnit) METHOD
setTimeOut(long, TimeUnit) METHOD
createAsyncTask(BimWorksClient) METHOD
getRequest() METHOD
setProgressListener(ProgressListener) METHOD
convert(Response) METHOD Converts the raw Response into this task's result type. Called once, on the thread that delivers the response. The default implementation returns the respons…
executeAsync() METHOD 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 th…
get() METHOD Waits for the result, bounded by the request's own timeout. On timeout the future is failed with a TaskTimeoutException (surfaced as this method's ExecutionE…
get(long, TimeUnit) METHOD
join() METHOD Like CompletableFuture#join(), but bounded by the request's own timeout (see #get()) and responsive to interrupts, which are rethrown wrapped in a Completion…
getClientTask() METHOD
getBimWorksClient() METHOD

Task(BimWorksClient)#

Java#
public Task(nl.bimbase.bimworks.client.BimWorksClient bimWorksClient)

Parameters#

Name Type Description
bimWorksClient BimWorksClient

createRequest()#

Java#
public nl.sascom.backplane.common.Request createRequest()

createRequest(int, TimeUnit)#

Java#
public nl.sascom.backplane.common.Request createRequest(int defaultTimeOut, java.util.concurrent.TimeUnit defaultTimeUnit)

Parameters#

Name Type Description
defaultTimeOut int
defaultTimeUnit java.util.concurrent.TimeUnit

setTimeOut(long, TimeUnit)#

Java#
public synchronized void setTimeOut(long timeOutValue, java.util.concurrent.TimeUnit timeOutUnit)

Parameters#

Name Type Description
timeOutValue long
timeOutUnit java.util.concurrent.TimeUnit

createAsyncTask(BimWorksClient)#

Java#
public nl.sascom.backplane.common.ClientTask createAsyncTask(nl.bimbase.bimworks.client.BimWorksClient bimWorksClient)

Parameters#

Name Type Description
bimWorksClient BimWorksClient

getRequest()#

Java#
public nl.sascom.backplane.common.Request getRequest()

setProgressListener(ProgressListener)#

Java#
public synchronized void setProgressListener(nl.sascom.backplane.common.ProgressListener progressListener)

Parameters#

Name Type Description
progressListener nl.sascom.backplane.common.ProgressListener

convert(Response)#

Java#
@java.lang.SuppressWarnings({"unchecked"})
protected T convert(nl.sascom.backplane.common.Response response) throws java.lang.Exception

Converts the raw Response into 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.

Parameters#

Name Type Description
response nl.sascom.backplane.common.Response

executeAsync()#

Java#
public synchronized nl.bimbase.bimworks.client.Task<T> 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()#

Java#
@java.lang.Override
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException

Waits for the result, bounded by the request's own timeout. On timeout the future is failed with a TaskTimeoutException (surfaced as this method's ExecutionException cause), unless the response arrived in the meantime.

get(long, TimeUnit)#

Java#
@java.lang.Override
public T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException

Parameters#

Name Type Description
timeout long
unit java.util.concurrent.TimeUnit

join()#

Java#
@java.lang.Override
public T join()

Like CompletableFuture#join(), but bounded by the request's own timeout (see #get()) and responsive to interrupts, which are rethrown wrapped in a CompletionException after restoring the interrupt flag.

getClientTask()#

Java#
public synchronized nl.sascom.backplane.client.AsyncTask getClientTask() throws nl.bimbase.bimworks.client.BimWorksException

getBimWorksClient()#

Java#
public nl.bimbase.bimworks.client.BimWorksClient getBimWorksClient()

Inherited members#

  • java.lang.Object#equals(java.lang.Object)
  • java.lang.Object#wait(long)
  • java.lang.Object#wait(long,int)
  • java.lang.Object#wait()
  • java.lang.Object#finalize()
  • java.lang.Object#getClass()
  • java.lang.Object#hashCode()
  • java.lang.Object#clone()
  • java.lang.Object#notify()
  • java.lang.Object#notifyAll()
  • java.util.concurrent.CompletableFuture#supplyAsync(java.util.function.Supplier<U>)
  • java.util.concurrent.CompletableFuture#supplyAsync(java.util.function.Supplier<U>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#runAsync(java.lang.Runnable)
  • java.util.concurrent.CompletableFuture#runAsync(java.lang.Runnable,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#completedFuture(U)
  • java.util.concurrent.CompletableFuture#isDone()
  • java.util.concurrent.CompletableFuture#getNow(T)
  • java.util.concurrent.CompletableFuture#complete(T)
  • java.util.concurrent.CompletableFuture#completeExceptionally(java.lang.Throwable)
  • java.util.concurrent.CompletableFuture#thenApply(java.util.function.Function<? super T,? extends U>)
  • java.util.concurrent.CompletableFuture#thenApplyAsync(java.util.function.Function<? super T,? extends U>)
  • java.util.concurrent.CompletableFuture#thenApplyAsync(java.util.function.Function<? super T,? extends U>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#thenAccept(java.util.function.Consumer<? super T>)
  • java.util.concurrent.CompletableFuture#thenAcceptAsync(java.util.function.Consumer<? super T>)
  • java.util.concurrent.CompletableFuture#thenAcceptAsync(java.util.function.Consumer<? super T>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#thenRun(java.lang.Runnable)
  • java.util.concurrent.CompletableFuture#thenRunAsync(java.lang.Runnable)
  • java.util.concurrent.CompletableFuture#thenRunAsync(java.lang.Runnable,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#thenCombine(java.util.concurrent.CompletionStage<? extends U>,java.util.function.BiFunction<? super T,? super U,? extends V>)
  • java.util.concurrent.CompletableFuture#thenCombineAsync(java.util.concurrent.CompletionStage<? extends U>,java.util.function.BiFunction<? super T,? super U,? extends V>)
  • java.util.concurrent.CompletableFuture#thenCombineAsync(java.util.concurrent.CompletionStage<? extends U>,java.util.function.BiFunction<? super T,? super U,? extends V>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#thenAcceptBoth(java.util.concurrent.CompletionStage<? extends U>,java.util.function.BiConsumer<? super T,? super U>)
  • java.util.concurrent.CompletableFuture#thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U>,java.util.function.BiConsumer<? super T,? super U>)
  • java.util.concurrent.CompletableFuture#thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U>,java.util.function.BiConsumer<? super T,? super U>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#runAfterBoth(java.util.concurrent.CompletionStage<?>,java.lang.Runnable)
  • java.util.concurrent.CompletableFuture#runAfterBothAsync(java.util.concurrent.CompletionStage<?>,java.lang.Runnable)
  • java.util.concurrent.CompletableFuture#runAfterBothAsync(java.util.concurrent.CompletionStage<?>,java.lang.Runnable,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#applyToEither(java.util.concurrent.CompletionStage<? extends T>,java.util.function.Function<? super T,U>)
  • java.util.concurrent.CompletableFuture#applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T>,java.util.function.Function<? super T,U>)
  • java.util.concurrent.CompletableFuture#applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T>,java.util.function.Function<? super T,U>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#acceptEither(java.util.concurrent.CompletionStage<? extends T>,java.util.function.Consumer<? super T>)
  • java.util.concurrent.CompletableFuture#acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T>,java.util.function.Consumer<? super T>)
  • java.util.concurrent.CompletableFuture#acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T>,java.util.function.Consumer<? super T>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#runAfterEither(java.util.concurrent.CompletionStage<?>,java.lang.Runnable)
  • java.util.concurrent.CompletableFuture#runAfterEitherAsync(java.util.concurrent.CompletionStage<?>,java.lang.Runnable)
  • java.util.concurrent.CompletableFuture#runAfterEitherAsync(java.util.concurrent.CompletionStage<?>,java.lang.Runnable,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#thenCompose(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>>)
  • java.util.concurrent.CompletableFuture#thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>>)
  • java.util.concurrent.CompletableFuture#thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#whenComplete(java.util.function.BiConsumer<? super T,? super java.lang.Throwable>)
  • java.util.concurrent.CompletableFuture#whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable>)
  • java.util.concurrent.CompletableFuture#whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#handle(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U>)
  • java.util.concurrent.CompletableFuture#handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U>)
  • java.util.concurrent.CompletableFuture#handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#toCompletableFuture()
  • java.util.concurrent.CompletableFuture#exceptionally(java.util.function.Function<java.lang.Throwable,? extends T>)
  • java.util.concurrent.CompletableFuture#allOf(java.util.concurrent.CompletableFuture<?>[])
  • java.util.concurrent.CompletableFuture#anyOf(java.util.concurrent.CompletableFuture<?>[])
  • java.util.concurrent.CompletableFuture#cancel(boolean)
  • java.util.concurrent.CompletableFuture#isCancelled()
  • java.util.concurrent.CompletableFuture#isCompletedExceptionally()
  • java.util.concurrent.CompletableFuture#obtrudeValue(T)
  • java.util.concurrent.CompletableFuture#obtrudeException(java.lang.Throwable)
  • java.util.concurrent.CompletableFuture#getNumberOfDependents()
  • java.util.concurrent.CompletableFuture#toString()
  • java.util.concurrent.CompletableFuture#newIncompleteFuture()
  • java.util.concurrent.CompletableFuture#defaultExecutor()
  • java.util.concurrent.CompletableFuture#copy()
  • java.util.concurrent.CompletableFuture#minimalCompletionStage()
  • java.util.concurrent.CompletableFuture#completeAsync(java.util.function.Supplier<? extends T>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#completeAsync(java.util.function.Supplier<? extends T>)
  • java.util.concurrent.CompletableFuture#orTimeout(long,java.util.concurrent.TimeUnit)
  • java.util.concurrent.CompletableFuture#completeOnTimeout(T,long,java.util.concurrent.TimeUnit)
  • java.util.concurrent.CompletableFuture#delayedExecutor(long,java.util.concurrent.TimeUnit,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#delayedExecutor(long,java.util.concurrent.TimeUnit)
  • java.util.concurrent.CompletableFuture#completedStage(U)
  • java.util.concurrent.CompletableFuture#failedFuture(java.lang.Throwable)
  • java.util.concurrent.CompletableFuture#failedStage(java.lang.Throwable)
  • java.util.concurrent.CompletableFuture#exceptionallyAsync(java.util.function.Function<java.lang.Throwable,? extends T>)
  • java.util.concurrent.CompletableFuture#exceptionallyAsync(java.util.function.Function<java.lang.Throwable,? extends T>,java.util.concurrent.Executor)
  • java.util.concurrent.CompletableFuture#exceptionallyCompose(java.util.function.Function<java.lang.Throwable,? extends java.util.concurrent.CompletionStage<T>>)
  • java.util.concurrent.CompletableFuture#exceptionallyComposeAsync(java.util.function.Function<java.lang.Throwable,? extends java.util.concurrent.CompletionStage<T>>)
  • java.util.concurrent.CompletableFuture#exceptionallyComposeAsync(java.util.function.Function<java.lang.Throwable,? extends java.util.concurrent.CompletionStage<T>>,java.util.concurrent.Executor)