public class ContextAwareCompletableFuture<T>
extends java.util.concurrent.CompletableFuture<T>
CompletableFuture that was introduced in java version 8.
The class is a 'normal' Completable Future, but every successive call made on the result will be made within the
context during creation of this ContextAwareCompletableFuture.
| Constructor | Description |
|---|---|
ContextAwareCompletableFuture() |
Creates a new
ContextSnapshot and remembers that in this completable future,
running all completion methods within this snapshot. |
ContextAwareCompletableFuture(ContextSnapshot snapshot) |
Creates a new
CompletableFuture where all completion methods are run within the specified
snapshot context. |
| Modifier and Type | Method | Description |
|---|---|---|
java.util.concurrent.CompletableFuture<java.lang.Void> |
acceptEither(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Consumer<? super T> action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Consumer<? super T> action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Consumer<? super T> action,
java.util.concurrent.Executor executor) |
|
<U> java.util.concurrent.CompletableFuture<U> |
applyToEither(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Function<? super T,U> fn) |
|
<U> java.util.concurrent.CompletableFuture<U> |
applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Function<? super T,U> fn) |
|
<U> java.util.concurrent.CompletableFuture<U> |
applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Function<? super T,U> fn,
java.util.concurrent.Executor executor) |
|
java.util.concurrent.CompletableFuture<T> |
exceptionally(java.util.function.Function<java.lang.Throwable,? extends T> fn) |
|
<U> java.util.concurrent.CompletableFuture<U> |
handle(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn) |
|
<U> java.util.concurrent.CompletableFuture<U> |
handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn) |
|
<U> java.util.concurrent.CompletableFuture<U> |
handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn,
java.util.concurrent.Executor executor) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
runAfterBoth(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
runAfterBothAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
runAfterBothAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action,
java.util.concurrent.Executor executor) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
runAfterEither(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
runAfterEitherAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
runAfterEitherAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action,
java.util.concurrent.Executor executor) |
|
static ContextAwareCompletableFuture<java.lang.Void> |
runAsync(java.lang.Runnable runnable) |
Runs the
runnable task in the common ForkJoinPool
within the current context and also applies that context to all successive
calls to the CompletableFuture. |
static ContextAwareCompletableFuture<java.lang.Void> |
runAsync(java.lang.Runnable runnable,
java.util.concurrent.Executor executor) |
Runs the
runnable task in the specified executor
within the current context and also applies that context to all successive
calls to the CompletableFuture. |
static ContextAwareCompletableFuture<java.lang.Void> |
runAsync(java.lang.Runnable runnable,
java.util.concurrent.Executor executor,
ContextSnapshot snapshot) |
Runs the
runnable task in the specified executor
within the specified context snapshot and also applies that context
to all successive calls to the CompletableFuture. |
static <U> ContextAwareCompletableFuture<U> |
supplyAsync(java.util.function.Supplier<U> supplier) |
Runs the
supplier task in the common ForkJoinPool
within the current context and also applies that context to all successive
calls to the CompletableFuture. |
static <U> ContextAwareCompletableFuture<U> |
supplyAsync(java.util.function.Supplier<U> supplier,
java.util.concurrent.Executor executor) |
Runs the
supplier task in the specified executor
within the current context and also applies that context to all successive
calls to the CompletableFuture. |
static <U> ContextAwareCompletableFuture<U> |
supplyAsync(java.util.function.Supplier<U> supplier,
java.util.concurrent.Executor executor,
ContextSnapshot snapshot) |
Runs the
supplier task in the specified executor
within the specified context snapshot and also applies that context
to all successive calls to the CompletableFuture. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
thenAccept(java.util.function.Consumer<? super T> action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
thenAcceptAsync(java.util.function.Consumer<? super T> action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
thenAcceptAsync(java.util.function.Consumer<? super T> action,
java.util.concurrent.Executor executor) |
|
<U> java.util.concurrent.CompletableFuture<java.lang.Void> |
thenAcceptBoth(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiConsumer<? super T,? super U> action) |
|
<U> java.util.concurrent.CompletableFuture<java.lang.Void> |
thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiConsumer<? super T,? super U> action) |
|
<U> java.util.concurrent.CompletableFuture<java.lang.Void> |
thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiConsumer<? super T,? super U> action,
java.util.concurrent.Executor executor) |
|
<U> java.util.concurrent.CompletableFuture<U> |
thenApply(java.util.function.Function<? super T,? extends U> fn) |
|
<U> java.util.concurrent.CompletableFuture<U> |
thenApplyAsync(java.util.function.Function<? super T,? extends U> fn) |
|
<U> java.util.concurrent.CompletableFuture<U> |
thenApplyAsync(java.util.function.Function<? super T,? extends U> fn,
java.util.concurrent.Executor executor) |
|
<U,V> java.util.concurrent.CompletableFuture<V> |
thenCombine(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends V> fn) |
|
<U,V> java.util.concurrent.CompletableFuture<V> |
thenCombineAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends V> fn) |
|
<U,V> java.util.concurrent.CompletableFuture<V> |
thenCombineAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends V> fn,
java.util.concurrent.Executor executor) |
|
<U> java.util.concurrent.CompletableFuture<U> |
thenCompose(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn) |
|
<U> java.util.concurrent.CompletableFuture<U> |
thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn) |
|
<U> java.util.concurrent.CompletableFuture<U> |
thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn,
java.util.concurrent.Executor executor) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
thenRun(java.lang.Runnable action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
thenRunAsync(java.lang.Runnable action) |
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
thenRunAsync(java.lang.Runnable action,
java.util.concurrent.Executor executor) |
|
java.util.concurrent.CompletableFuture<T> |
whenComplete(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action) |
|
java.util.concurrent.CompletableFuture<T> |
whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action) |
|
java.util.concurrent.CompletableFuture<T> |
whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action,
java.util.concurrent.Executor executor) |
allOf, anyOf, cancel, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, toCompletableFuture, toStringpublic ContextAwareCompletableFuture()
ContextSnapshot and remembers that in this completable future,
running all completion methods within this snapshot.ContextManagers.createContextSnapshot()public ContextAwareCompletableFuture(ContextSnapshot snapshot)
CompletableFuture where all completion methods are run within the specified
snapshot context.snapshot - The snapshot to run completion methods in.
Optional, the completable future will take a new snaphot if null is provided.ContextManagers.createContextSnapshot()public static <U> ContextAwareCompletableFuture<U> supplyAsync(java.util.function.Supplier<U> supplier)
supplier task in the common ForkJoinPool
within the current context and also applies that context to all successive
calls to the CompletableFuture.U - the function's return typesupplier - a function to be performed asynchronously returning the result of the CompletableFutureCompletableFuture.supplyAsync(Supplier),
supplyAsync(Supplier, Executor, ContextSnapshot)public static <U> ContextAwareCompletableFuture<U> supplyAsync(java.util.function.Supplier<U> supplier, java.util.concurrent.Executor executor)
supplier task in the specified executor
within the current context and also applies that context to all successive
calls to the CompletableFuture.U - the function's return typesupplier - a function returning the value to be used to complete the returned CompletableFutureexecutor - the executor to use for asynchronous executionCompletableFuture.supplyAsync(Supplier, Executor),
supplyAsync(Supplier, Executor, ContextSnapshot)public static <U> ContextAwareCompletableFuture<U> supplyAsync(java.util.function.Supplier<U> supplier, java.util.concurrent.Executor executor, ContextSnapshot snapshot)
supplier task in the specified executor
within the specified context snapshot and also applies that context
to all successive calls to the CompletableFuture.
This method is lenient to null values for executor and snapshot:
If executor == null the common ForkJoinPool is used as
specified by CompletableFuture.supplyAsync(Supplier).
If snapshot == null a new context snapshot is
created for all successive calls to the CompletableFuture and the Supplier
(if not already a SupplierWithContext).
U - the function's return typesupplier - a function returning the value to be used to complete the returned CompletableFutureexecutor - the executor to use for asynchronous executionsnapshot - a snapshot of the context to be propagated in the supplier function
and all successive calls of this completable futureCompletableFuture.supplyAsync(Supplier, Executor)public static ContextAwareCompletableFuture<java.lang.Void> runAsync(java.lang.Runnable runnable)
runnable task in the common ForkJoinPool
within the current context and also applies that context to all successive
calls to the CompletableFuture.runnable - the action to run before completing the returned CompletableFutureCompletableFuture.runAsync(Runnable),
runAsync(Runnable, Executor, ContextSnapshot)public static ContextAwareCompletableFuture<java.lang.Void> runAsync(java.lang.Runnable runnable, java.util.concurrent.Executor executor)
runnable task in the specified executor
within the current context and also applies that context to all successive
calls to the CompletableFuture.runnable - the action to run before completing the returned CompletableFutureexecutor - the executor to use for asynchronous executionCompletableFuture.runAsync(Runnable, Executor),
runAsync(Runnable, Executor, ContextSnapshot)public static ContextAwareCompletableFuture<java.lang.Void> runAsync(java.lang.Runnable runnable, java.util.concurrent.Executor executor, ContextSnapshot snapshot)
runnable task in the specified executor
within the specified context snapshot and also applies that context
to all successive calls to the CompletableFuture.
This method is lenient to null values for executor and snapshot:
If executor == null the common ForkJoinPool is used as
specified by CompletableFuture.supplyAsync(Supplier).
If snapshot == null a new context snapshot is
created for all successive calls to the CompletableFuture and the Supplier
(if not already a SupplierWithContext).
runnable - the action to run before completing the returned CompletableFutureexecutor - the executor to use for asynchronous executionsnapshot - the context snapshot to apply to the runnable actionCompletableFuture.runAsync(Runnable, Executor)public <U> java.util.concurrent.CompletableFuture<U> thenApply(java.util.function.Function<? super T,? extends U> fn)
thenApply in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> thenApplyAsync(java.util.function.Function<? super T,? extends U> fn)
thenApplyAsync in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> thenApplyAsync(java.util.function.Function<? super T,? extends U> fn, java.util.concurrent.Executor executor)
thenApplyAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> thenAccept(java.util.function.Consumer<? super T> action)
thenAccept in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> thenAcceptAsync(java.util.function.Consumer<? super T> action)
thenAcceptAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> thenAcceptAsync(java.util.function.Consumer<? super T> action, java.util.concurrent.Executor executor)
thenAcceptAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> thenRun(java.lang.Runnable action)
thenRun in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> thenRunAsync(java.lang.Runnable action)
thenRunAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> thenRunAsync(java.lang.Runnable action,
java.util.concurrent.Executor executor)
thenRunAsync in class java.util.concurrent.CompletableFuture<T>public <U,V> java.util.concurrent.CompletableFuture<V> thenCombine(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends V> fn)
thenCombine in class java.util.concurrent.CompletableFuture<T>public <U,V> java.util.concurrent.CompletableFuture<V> thenCombineAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends V> fn)
thenCombineAsync in class java.util.concurrent.CompletableFuture<T>public <U,V> java.util.concurrent.CompletableFuture<V> thenCombineAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends V> fn,
java.util.concurrent.Executor executor)
thenCombineAsync in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<java.lang.Void> thenAcceptBoth(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiConsumer<? super T,? super U> action)
thenAcceptBoth in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<java.lang.Void> thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiConsumer<? super T,? super U> action)
thenAcceptBothAsync in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<java.lang.Void> thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiConsumer<? super T,? super U> action,
java.util.concurrent.Executor executor)
thenAcceptBothAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> runAfterBoth(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action)
runAfterBoth in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> runAfterBothAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action)
runAfterBothAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> runAfterBothAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action,
java.util.concurrent.Executor executor)
runAfterBothAsync in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> applyToEither(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Function<? super T,U> fn)
applyToEither in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Function<? super T,U> fn)
applyToEitherAsync in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Function<? super T,U> fn, java.util.concurrent.Executor executor)
applyToEitherAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> acceptEither(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Consumer<? super T> action)
acceptEither in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Consumer<? super T> action)
acceptEitherAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Consumer<? super T> action, java.util.concurrent.Executor executor)
acceptEitherAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> runAfterEither(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action)
runAfterEither in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> runAfterEitherAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action)
runAfterEitherAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<java.lang.Void> runAfterEitherAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action,
java.util.concurrent.Executor executor)
runAfterEitherAsync in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> thenCompose(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn)
thenCompose in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn)
thenComposeAsync in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn, java.util.concurrent.Executor executor)
thenComposeAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<T> whenComplete(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action)
whenComplete in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<T> whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action)
whenCompleteAsync in class java.util.concurrent.CompletableFuture<T>public java.util.concurrent.CompletableFuture<T> whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action, java.util.concurrent.Executor executor)
whenCompleteAsync in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> handle(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn)
handle in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn)
handleAsync in class java.util.concurrent.CompletableFuture<T>public <U> java.util.concurrent.CompletableFuture<U> handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn, java.util.concurrent.Executor executor)
handleAsync in class java.util.concurrent.CompletableFuture<T>Copyright © 2016–2018 Talsma ICT. All rights reserved.