public class ContextAwareCompletableFuture<T> extends 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.
CompletableFuture.AsynchronousCompletionTask| Constructor and 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 and Description |
|---|---|
CompletableFuture<Void> |
acceptEither(CompletionStage<? extends T> other,
Consumer<? super T> action) |
CompletableFuture<Void> |
acceptEitherAsync(CompletionStage<? extends T> other,
Consumer<? super T> action) |
CompletableFuture<Void> |
acceptEitherAsync(CompletionStage<? extends T> other,
Consumer<? super T> action,
Executor executor) |
<U> CompletableFuture<U> |
applyToEither(CompletionStage<? extends T> other,
Function<? super T,U> fn) |
<U> CompletableFuture<U> |
applyToEitherAsync(CompletionStage<? extends T> other,
Function<? super T,U> fn) |
<U> CompletableFuture<U> |
applyToEitherAsync(CompletionStage<? extends T> other,
Function<? super T,U> fn,
Executor executor) |
CompletableFuture<T> |
exceptionally(Function<Throwable,? extends T> fn) |
<U> CompletableFuture<U> |
handle(BiFunction<? super T,Throwable,? extends U> fn) |
<U> CompletableFuture<U> |
handleAsync(BiFunction<? super T,Throwable,? extends U> fn) |
<U> CompletableFuture<U> |
handleAsync(BiFunction<? super T,Throwable,? extends U> fn,
Executor executor) |
CompletableFuture<Void> |
runAfterBoth(CompletionStage<?> other,
Runnable action) |
CompletableFuture<Void> |
runAfterBothAsync(CompletionStage<?> other,
Runnable action) |
CompletableFuture<Void> |
runAfterBothAsync(CompletionStage<?> other,
Runnable action,
Executor executor) |
CompletableFuture<Void> |
runAfterEither(CompletionStage<?> other,
Runnable action) |
CompletableFuture<Void> |
runAfterEitherAsync(CompletionStage<?> other,
Runnable action) |
CompletableFuture<Void> |
runAfterEitherAsync(CompletionStage<?> other,
Runnable action,
Executor executor) |
static ContextAwareCompletableFuture<Void> |
runAsync(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<Void> |
runAsync(Runnable runnable,
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<Void> |
runAsync(Runnable runnable,
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(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(Supplier<U> supplier,
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(Supplier<U> supplier,
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. |
CompletableFuture<Void> |
thenAccept(Consumer<? super T> action) |
CompletableFuture<Void> |
thenAcceptAsync(Consumer<? super T> action) |
CompletableFuture<Void> |
thenAcceptAsync(Consumer<? super T> action,
Executor executor) |
<U> CompletableFuture<Void> |
thenAcceptBoth(CompletionStage<? extends U> other,
BiConsumer<? super T,? super U> action) |
<U> CompletableFuture<Void> |
thenAcceptBothAsync(CompletionStage<? extends U> other,
BiConsumer<? super T,? super U> action) |
<U> CompletableFuture<Void> |
thenAcceptBothAsync(CompletionStage<? extends U> other,
BiConsumer<? super T,? super U> action,
Executor executor) |
<U> CompletableFuture<U> |
thenApply(Function<? super T,? extends U> fn) |
<U> CompletableFuture<U> |
thenApplyAsync(Function<? super T,? extends U> fn) |
<U> CompletableFuture<U> |
thenApplyAsync(Function<? super T,? extends U> fn,
Executor executor) |
<U,V> CompletableFuture<V> |
thenCombine(CompletionStage<? extends U> other,
BiFunction<? super T,? super U,? extends V> fn) |
<U,V> CompletableFuture<V> |
thenCombineAsync(CompletionStage<? extends U> other,
BiFunction<? super T,? super U,? extends V> fn) |
<U,V> CompletableFuture<V> |
thenCombineAsync(CompletionStage<? extends U> other,
BiFunction<? super T,? super U,? extends V> fn,
Executor executor) |
<U> CompletableFuture<U> |
thenCompose(Function<? super T,? extends CompletionStage<U>> fn) |
<U> CompletableFuture<U> |
thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn) |
<U> CompletableFuture<U> |
thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn,
Executor executor) |
CompletableFuture<Void> |
thenRun(Runnable action) |
CompletableFuture<Void> |
thenRunAsync(Runnable action) |
CompletableFuture<Void> |
thenRunAsync(Runnable action,
Executor executor) |
CompletableFuture<T> |
whenComplete(BiConsumer<? super T,? super Throwable> action) |
CompletableFuture<T> |
whenCompleteAsync(BiConsumer<? super T,? super Throwable> action) |
CompletableFuture<T> |
whenCompleteAsync(BiConsumer<? super T,? super Throwable> action,
Executor executor) |
protected <RESULT> CompletableFuture<RESULT> |
wrapResult(CompletableFuture<RESULT> result)
Wraps the resulting completable future from any folowup calls in this class.
|
allOf, anyOf, cancel, complete, completedFuture, completeExceptionally, get, get, getNow, getNumberOfDependents, isCancelled, isCompletedExceptionally, isDone, join, obtrudeException, obtrudeValue, 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 (or specify null to take a
new snapshot upon creation of this completable future).ContextManagers.createContextSnapshot()public static <U> ContextAwareCompletableFuture<U> supplyAsync(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 returning the value to be used to complete the returned CompletableFutureCompletableFuture.supplyAsync(Supplier),
supplyAsync(Supplier, Executor, ContextSnapshot)public static <U> ContextAwareCompletableFuture<U> supplyAsync(Supplier<U> supplier, 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(Supplier<U> supplier, 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<Void> runAsync(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<Void> runAsync(Runnable runnable, 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<Void> runAsync(Runnable runnable, 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 executionCompletableFuture.runAsync(Runnable, Executor)protected <RESULT> CompletableFuture<RESULT> wrapResult(CompletableFuture<RESULT> result)
RESULT - The result type of the completable future.result - The original result after the contextualized followup call.public <U> CompletableFuture<U> thenApply(Function<? super T,? extends U> fn)
thenApply in interface CompletionStage<T>thenApply in class CompletableFuture<T>public <U> CompletableFuture<U> thenApplyAsync(Function<? super T,? extends U> fn)
thenApplyAsync in interface CompletionStage<T>thenApplyAsync in class CompletableFuture<T>public <U> CompletableFuture<U> thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)
thenApplyAsync in interface CompletionStage<T>thenApplyAsync in class CompletableFuture<T>public CompletableFuture<Void> thenAccept(Consumer<? super T> action)
thenAccept in interface CompletionStage<T>thenAccept in class CompletableFuture<T>public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> action)
thenAcceptAsync in interface CompletionStage<T>thenAcceptAsync in class CompletableFuture<T>public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> action, Executor executor)
thenAcceptAsync in interface CompletionStage<T>thenAcceptAsync in class CompletableFuture<T>public CompletableFuture<Void> thenRun(Runnable action)
thenRun in interface CompletionStage<T>thenRun in class CompletableFuture<T>public CompletableFuture<Void> thenRunAsync(Runnable action)
thenRunAsync in interface CompletionStage<T>thenRunAsync in class CompletableFuture<T>public CompletableFuture<Void> thenRunAsync(Runnable action, Executor executor)
thenRunAsync in interface CompletionStage<T>thenRunAsync in class CompletableFuture<T>public <U,V> CompletableFuture<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
thenCombine in interface CompletionStage<T>thenCombine in class CompletableFuture<T>public <U,V> CompletableFuture<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
thenCombineAsync in interface CompletionStage<T>thenCombineAsync in class CompletableFuture<T>public <U,V> CompletableFuture<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn, Executor executor)
thenCombineAsync in interface CompletionStage<T>thenCombineAsync in class CompletableFuture<T>public <U> CompletableFuture<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
thenAcceptBoth in interface CompletionStage<T>thenAcceptBoth in class CompletableFuture<T>public <U> CompletableFuture<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
thenAcceptBothAsync in interface CompletionStage<T>thenAcceptBothAsync in class CompletableFuture<T>public <U> CompletableFuture<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action, Executor executor)
thenAcceptBothAsync in interface CompletionStage<T>thenAcceptBothAsync in class CompletableFuture<T>public CompletableFuture<Void> runAfterBoth(CompletionStage<?> other, Runnable action)
runAfterBoth in interface CompletionStage<T>runAfterBoth in class CompletableFuture<T>public CompletableFuture<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action)
runAfterBothAsync in interface CompletionStage<T>runAfterBothAsync in class CompletableFuture<T>public CompletableFuture<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)
runAfterBothAsync in interface CompletionStage<T>runAfterBothAsync in class CompletableFuture<T>public <U> CompletableFuture<U> applyToEither(CompletionStage<? extends T> other, Function<? super T,U> fn)
applyToEither in interface CompletionStage<T>applyToEither in class CompletableFuture<T>public <U> CompletableFuture<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn)
applyToEitherAsync in interface CompletionStage<T>applyToEitherAsync in class CompletableFuture<T>public <U> CompletableFuture<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn, Executor executor)
applyToEitherAsync in interface CompletionStage<T>applyToEitherAsync in class CompletableFuture<T>public CompletableFuture<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
acceptEither in interface CompletionStage<T>acceptEither in class CompletableFuture<T>public CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
acceptEitherAsync in interface CompletionStage<T>acceptEitherAsync in class CompletableFuture<T>public CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)
acceptEitherAsync in interface CompletionStage<T>acceptEitherAsync in class CompletableFuture<T>public CompletableFuture<Void> runAfterEither(CompletionStage<?> other, Runnable action)
runAfterEither in interface CompletionStage<T>runAfterEither in class CompletableFuture<T>public CompletableFuture<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action)
runAfterEitherAsync in interface CompletionStage<T>runAfterEitherAsync in class CompletableFuture<T>public CompletableFuture<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)
runAfterEitherAsync in interface CompletionStage<T>runAfterEitherAsync in class CompletableFuture<T>public <U> CompletableFuture<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
thenCompose in interface CompletionStage<T>thenCompose in class CompletableFuture<T>public <U> CompletableFuture<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
thenComposeAsync in interface CompletionStage<T>thenComposeAsync in class CompletableFuture<T>public <U> CompletableFuture<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn, Executor executor)
thenComposeAsync in interface CompletionStage<T>thenComposeAsync in class CompletableFuture<T>public CompletableFuture<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
whenComplete in interface CompletionStage<T>whenComplete in class CompletableFuture<T>public CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
whenCompleteAsync in interface CompletionStage<T>whenCompleteAsync in class CompletableFuture<T>public CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor)
whenCompleteAsync in interface CompletionStage<T>whenCompleteAsync in class CompletableFuture<T>public <U> CompletableFuture<U> handle(BiFunction<? super T,Throwable,? extends U> fn)
handle in interface CompletionStage<T>handle in class CompletableFuture<T>public <U> CompletableFuture<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn)
handleAsync in interface CompletionStage<T>handleAsync in class CompletableFuture<T>public <U> CompletableFuture<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn, Executor executor)
handleAsync in interface CompletionStage<T>handleAsync in class CompletableFuture<T>public CompletableFuture<T> exceptionally(Function<Throwable,? extends T> fn)
exceptionally in interface CompletionStage<T>exceptionally in class CompletableFuture<T>Copyright © 2016–2017 Talsma ICT. All rights reserved.