diff --git a/context-propagation-api/README.md b/context-propagation-api/README.md index 00dbcf0b..fd61ef78 100644 --- a/context-propagation-api/README.md +++ b/context-propagation-api/README.md @@ -35,15 +35,15 @@ although technically these use cases are not appropriate. Manages contexts by initializing and maintaining an active context value. Normally it is not necessary to interact directly with individual context managers. -The `ContextManagers` utility class detects available context managers and lets -you take a [_snapshot_](#context-snapshot) of **all** active contexts at once. +The api detects available context managers and lets +you capture a [_snapshot_](#context-snapshot) of **all** active contexts at once. - [ContextManager javadoc][contextmanager] -- [ContextManagers javadoc][contextmanagers] +- [ContextSnapshot javadoc][contextsnapshot] ### Context Snapshot -A context snapshot is created by the [ContextManagers]' `createContextSnapshot()` method. +A context snapshot is captured by the [ContextSnapshot]' `capture()` method. The snapshot contains active context values from all known [ContextManager] implementations. Once created, the captured _values_ in such context snapshot will not change anymore, even when the active context is later modified. @@ -52,7 +52,6 @@ They stay active until the reactivation is closed again (or are overwritten by n Closing the reactivated object is mandatory (from the thread where the reactivation was called). - [ContextSnapshot javadoc](https://javadoc.io/page/nl.talsmasoftware.context/context-propagation/latest/nl/talsmasoftware/context/ContextSnapshot.html) -- [ContextManagers javadoc](https://javadoc.io/page/nl.talsmasoftware.context/context-propagation/latest/nl/talsmasoftware/context/ContextManagers.html) ## Creating your own context manager @@ -68,23 +67,24 @@ It should contain the fully qualified classname of your implementation. ```java public class DummyContextManager implements ContextManager { - public Context initializeNewContext(String value) { - return new DummyContext(value); + public Context initializeNewContext(String value) { + return new DummyContext(value); + } + + public Context getActiveContextValue() { + DummyContext current = DummyContext.current(); + return current != null ? current.getValue() : null; + } + + private static final class DummyContext extends AbstractThreadLocalContext { + private DummyContext(String newValue) { + super(newValue); } - public Context getActiveContext() { - return DummyContext.current(); - } - - private static final class DummyContext extends AbstractThreadLocalContext { - private DummyContext(String newValue) { - super(newValue); - } - - private static Context current() { - return AbstractThreadLocalContext.current(DummyContext.class); - } + private static Context current() { + return AbstractThreadLocalContext.current(DummyContext.class); } + } } ``` @@ -95,7 +95,6 @@ public class DummyContextManager implements ContextManager { [javadoc]: https://www.javadoc.io/doc/nl.talsmasoftware.context/context-propagation [threadlocal]: https://docs.oracle.com/javase/8/docs/api/java/lang/ThreadLocal.html - [context]: https://javadoc.io/page/nl.talsmasoftware.context/context-propagation/latest/nl/talsmasoftware/context/Context.html - [contextsnapshot]: https://javadoc.io/page/nl.talsmasoftware.context/context-propagation/latest/nl/talsmasoftware/context/ContextSnapshot.html - [contextmanager]: https://javadoc.io/page/nl.talsmasoftware.context/context-propagation/latest/nl/talsmasoftware/context/ContextManager.html - [contextmanagers]: https://javadoc.io/page/nl.talsmasoftware.context/context-propagation/latest/nl/talsmasoftware/context/ContextManagers.html + [context]: https://javadoc.io/page/nl.talsmasoftware.context/context-propagation/latest/nl/talsmasoftware/context/api/Context.html + [contextsnapshot]: https://javadoc.io/page/nl.talsmasoftware.context/context-propagation/latest/nl/talsmasoftware/context/api/ContextSnapshot.html + [contextmanager]: https://javadoc.io/page/nl.talsmasoftware.context/context-propagation/latest/nl/talsmasoftware/context/api/ContextManager.html diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/concurrent/ContextAwareCompletableFuture.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/concurrent/ContextAwareCompletableFuture.java index c66d233f..4db10d33 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/concurrent/ContextAwareCompletableFuture.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/concurrent/ContextAwareCompletableFuture.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.concurrent; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import nl.talsmasoftware.context.core.function.BiConsumerWithContext; import nl.talsmasoftware.context.core.function.BiFunctionWithContext; import nl.talsmasoftware.context.core.function.ConsumerWithContext; @@ -61,10 +60,10 @@ public class ContextAwareCompletableFuture extends CompletableFuture { private final boolean takeNewSnapshot; /** - * Creates a new {@link ContextSnapshot} and remembers that in this completable future, + * Captures a new {@link ContextSnapshot} and remembers that in this completable future, * running all completion methods within this snapshot. * - * @see ContextManagers#createContextSnapshot() + * @see ContextSnapshot#capture() */ public ContextAwareCompletableFuture() { this((ContextSnapshot) null); @@ -75,8 +74,8 @@ public ContextAwareCompletableFuture() { * snapshot context. * * @param snapshot the snapshot to run completion methods in. - * Optional, the completable future will take a new snaphot if {@code null} is provided. - * @see ContextManagers#createContextSnapshot() + * Optional, the completable future will capture a new snapshot if {@code null} is provided. + * @see ContextSnapshot#capture() */ public ContextAwareCompletableFuture(ContextSnapshot snapshot) { this(new ContextSnapshotHolder(snapshot), false); @@ -126,8 +125,8 @@ public static ContextAwareCompletableFuture supplyAsync(Supplier suppl * This method is lenient to {@code null} values for {@code executor} and {@code snapshot}:
* If {@code executor == null} the common {@link java.util.concurrent.ForkJoinPool ForkJoinPool} is used as * specified by {@link CompletableFuture#supplyAsync(Supplier)}.
- * If {@code snapshot == null} a {@link ContextManagers#createContextSnapshot() new context snapshot} is - * created for the {@link Supplier} (if not already a {@link SupplierWithContext}). + * If {@code snapshot == null} a {@link ContextSnapshot#capture() new context snapshot} is + * captured for the {@link Supplier} (if not already a {@link SupplierWithContext}). * * @param supplier a function returning the value to be used to complete the returned CompletableFuture * @param executor the executor to use for asynchronous execution @@ -150,8 +149,8 @@ public static ContextAwareCompletableFuture supplyAsync(Supplier suppl * This method is lenient to {@code null} values for {@code executor} and {@code snapshot}:
* If {@code executor == null} the common {@link java.util.concurrent.ForkJoinPool ForkJoinPool} is used as * specified by {@link CompletableFuture#supplyAsync(Supplier)}.
- * If {@code snapshot == null} a {@link ContextManagers#createContextSnapshot() new context snapshot} is - * created for the {@link Supplier} (if not already a {@link SupplierWithContext}). + * If {@code snapshot == null} a {@link ContextSnapshot#capture() new context snapshot} is + * captured for the {@link Supplier} (if not already a {@link SupplierWithContext}). * * @param supplier a function returning the value to be used to complete the returned CompletableFuture * @param executor the executor to use for asynchronous execution @@ -215,8 +214,8 @@ public static ContextAwareCompletableFuture runAsync(Runnable runnable, Ex * This method is lenient to {@code null} values for {@code executor} and {@code snapshot}:
* If {@code executor == null} the common {@link java.util.concurrent.ForkJoinPool ForkJoinPool} is used as * specified by {@link CompletableFuture#supplyAsync(Supplier)}.
- * If {@code snapshot == null} a {@link ContextManagers#createContextSnapshot() new context snapshot} is - * created for the {@link Supplier} (if not already a {@link SupplierWithContext}). + * If {@code snapshot == null} a {@link ContextSnapshot#capture() new context snapshot} is + * captured for the {@link Supplier} (if not already a {@link SupplierWithContext}). * * @param runnable the action to run before completing the returned CompletableFuture * @param executor the executor to use for asynchronous execution @@ -237,8 +236,8 @@ public static ContextAwareCompletableFuture runAsync(Runnable runnable, Ex * This method is lenient to {@code null} values for {@code executor} and {@code snapshot}:
* If {@code executor == null} the common {@link java.util.concurrent.ForkJoinPool ForkJoinPool} is used as * specified by {@link CompletableFuture#supplyAsync(Supplier)}.
- * If {@code snapshot == null} a {@link ContextManagers#createContextSnapshot() new context snapshot} is - * created for the {@link Supplier} (if not already a {@link SupplierWithContext}). + * If {@code snapshot == null} a {@link ContextSnapshot#capture() new context snapshot} is + * captured for the {@link Supplier} (if not already a {@link SupplierWithContext}). * * @param runnable the action to run before completing the returned CompletableFuture * @param executor the executor to use for asynchronous execution diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/delegation/WrapperWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/delegation/WrapperWithContext.java index 682c035f..b31f48d8 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/delegation/WrapperWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/delegation/WrapperWithContext.java @@ -49,7 +49,7 @@ protected WrapperWithContext(final ContextSnapshot snapshot, final T delegate) { *

* Note: Make sure the supplier function does not obtain the context snapshot * from any threadlocal storage! The wrapper is designed to propagate contexts from one thread to another. - * Therefore, the snapshot must be {@link nl.talsmasoftware.context.core.ContextManagers#createContextSnapshot() captured} + * Therefore, the snapshot must be {@link ContextSnapshot#capture() captured} * in the source thread and {@link ContextSnapshot#reactivate() reactivated} in the target thread. * If unsure, please use the * {@link #WrapperWithContext(ContextSnapshot, Object) constructor with snapshot} instead. diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiConsumerWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiConsumerWithContext.java index 12ccda6b..7069294a 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiConsumerWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiConsumerWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -64,7 +63,7 @@ public BiConsumerWithContext(ContextSnapshot snapshot, BiConsumer delegate *

  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • accept the values by passing them to the delegate bi-consumer *
  • if snapshot consumer is non-null, - * pass it a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} + * pass it a {@linkplain ContextSnapshot#capture() new context snapshot} *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} * * @@ -103,7 +102,7 @@ protected BiConsumerWithContext(Supplier snapshotSupplier, BiCo *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • accept the values by passing them to the delegate bi-consumer *
  • if snapshot consumer is non-null, - * pass it a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} + * pass it a {@linkplain ContextSnapshot#capture() new context snapshot} *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} * * @@ -141,7 +140,7 @@ public void accept(T in1, U in2) { *
  • passing them to the {@code after} bi-consumer * *
  • if snapshot consumer is non-null, - * pass it a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} + * pass it a {@linkplain ContextSnapshot#capture() new context snapshot} *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} * * diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiFunctionWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiFunctionWithContext.java index 8efec5cc..0953d729 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiFunctionWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiFunctionWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -73,7 +72,7 @@ public BiFunctionWithContext(ContextSnapshot snapshot, BiFunction *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • apply the delegate function *
  • if snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the result from the delegate function call (or throw runtime exception if the delegate did). * @@ -113,7 +112,7 @@ protected BiFunctionWithContext(Supplier snapshotSupplier, BiFu *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • apply the delegate bi-function and get the result *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the result
  • * @@ -150,7 +149,7 @@ public OUT apply(IN1 in1, IN2 in2) { *
  • apply the delegate bi-function and get the result *
  • apply the {@code after} function to the result to get the end result *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the end result
  • * diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiPredicateWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiPredicateWithContext.java index ebca37a5..49d6376e 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiPredicateWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BiPredicateWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.BiPredicate; import java.util.function.Consumer; @@ -71,7 +70,7 @@ public BiPredicateWithContext(ContextSnapshot snapshot, BiPredicate de *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • test the delegate bi-predicate and get the outcome *
  • if snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return bi-predicate outcome (or throw runtime exception if the delegate did). * @@ -111,7 +110,7 @@ protected BiPredicateWithContext(Supplier snapshotSupplier, BiP *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • test the bi-delegate predicate and get the outcome *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the outcome
  • * @@ -149,7 +148,7 @@ public boolean test(IN1 in1, IN2 in2) { *
  • test the delegate bi-predicate and get the outcome *
  • if the outcome is true, test the {@code other} bi-predicate and return that outcome
  • *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the final outcome
  • * @@ -195,7 +194,7 @@ public BiPredicate and(BiPredicate other) { *
  • test the delegate bi-predicate and get the outcome *
  • if the outcome is false, test the {@code other} vi-predicate and return that outcome
  • *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the final outcome
  • * diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BinaryOperatorWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BinaryOperatorWithContext.java index 36d74579..32b99197 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BinaryOperatorWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BinaryOperatorWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.BinaryOperator; import java.util.function.Consumer; @@ -64,7 +63,7 @@ public BinaryOperatorWithContext(ContextSnapshot snapshot, BinaryOperator del *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • apply the delegate binary operator *
  • if snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the result from the delegate operator call (or throw runtime exception if the delegate did). * diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BooleanSupplierWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BooleanSupplierWithContext.java index e393e87a..bd8dfa04 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BooleanSupplierWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/BooleanSupplierWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.BooleanSupplier; import java.util.function.Consumer; @@ -67,7 +66,7 @@ public BooleanSupplierWithContext(ContextSnapshot snapshot, BooleanSupplier dele *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • getting the outcome from the delegate boolean supplier *
  • if snapshot consumer is non-null, - * pass it a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} + * pass it a {@linkplain ContextSnapshot#capture() new context snapshot} *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the outcome from the delegate boolean supplier call (or throw runtime exception if the delegate did). * @@ -107,7 +106,7 @@ protected BooleanSupplierWithContext(Supplier snapshotSupplier, *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • get the outcome from the delegate boolean supplier *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the outcome
  • * diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/ConsumerWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/ConsumerWithContext.java index 30119457..9b42909a 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/ConsumerWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/ConsumerWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.Consumer; import java.util.function.Supplier; @@ -62,7 +61,7 @@ public ConsumerWithContext(ContextSnapshot snapshot, Consumer delegate) { *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • accept the value by passing it to the delegate consumer *
  • if snapshot consumer is non-null, - * pass it a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} + * pass it a {@linkplain ContextSnapshot#capture() new context snapshot} *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} * * @@ -101,7 +100,7 @@ protected ConsumerWithContext(Supplier snapshotSupplier, Consum *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • accept the value by passing it to the delegate consumer *
  • if snapshot consumer is non-null, - * pass it a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} + * pass it a {@linkplain ContextSnapshot#capture() new context snapshot} *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} * * @@ -138,7 +137,7 @@ public void accept(T value) { *
  • passing it to the {@code after} consumer * *
  • if snapshot consumer is non-null, - * pass it a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} + * pass it a {@linkplain ContextSnapshot#capture() new context snapshot} *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} * * diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/FunctionWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/FunctionWithContext.java index 437e4736..65999143 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/FunctionWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/FunctionWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.Consumer; import java.util.function.Function; @@ -71,7 +70,7 @@ public FunctionWithContext(ContextSnapshot snapshot, Function delegate) *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • apply the delegate function *
  • if snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the result from the delegate function call (or throw runtime exception if the delegate did). * @@ -111,7 +110,7 @@ protected FunctionWithContext(Supplier snapshotSupplier, Functi *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • apply the delegate function and get the result *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the result
  • * @@ -146,7 +145,7 @@ public OUT apply(IN in) { *
  • apply the {@code before} function *
  • apply the delegate function to the result of the {@code before} function and get the end result *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the end result
  • * @@ -184,7 +183,7 @@ public Function compose(Function before) { *
  • apply the delegate function and get the result *
  • apply the {@code after} function to the result to get the end result *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the end result
  • * diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/PredicateWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/PredicateWithContext.java index 05b91397..021a1956 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/PredicateWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/PredicateWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.Consumer; import java.util.function.Predicate; @@ -70,7 +69,7 @@ public PredicateWithContext(ContextSnapshot snapshot, Predicate delegate) { *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • test the delegate predicate and get the outcome *
  • if snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return predicate outcome (or throw runtime exception if the delegate did). * @@ -110,7 +109,7 @@ protected PredicateWithContext(Supplier snapshotSupplier, Predi *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • test the delegate predicate and get the outcome *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the outcome
  • * @@ -147,7 +146,7 @@ public boolean test(T value) { *
  • test the delegate predicate and get the outcome *
  • if the outcome is true, test the {@code other} predicate and return that outcome
  • *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the final outcome
  • * @@ -193,7 +192,7 @@ public Predicate and(Predicate other) { *
  • test the delegate predicate and get the outcome *
  • if the outcome is false, test the {@code other} predicate and return that outcome
  • *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the final outcome
  • * diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/RunnableWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/RunnableWithContext.java index 0f505bb7..81d1c655 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/RunnableWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/RunnableWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.Consumer; import java.util.function.Supplier; @@ -58,7 +57,7 @@ public RunnableWithContext(ContextSnapshot snapshot, Runnable delegate) { *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • run the delegate task *
  • if snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} * * @@ -97,7 +96,7 @@ protected RunnableWithContext(Supplier snapshotSupplier, Runnab *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • run the delegate task *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} * */ diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/SupplierWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/SupplierWithContext.java index 74dbea48..bf8d9425 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/SupplierWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/SupplierWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.Consumer; import java.util.function.Supplier; @@ -60,7 +59,7 @@ public SupplierWithContext(ContextSnapshot snapshot, Supplier delegate) { *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • supply the value by calling the delegate *
  • if snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} * * @@ -99,7 +98,7 @@ protected SupplierWithContext(Supplier snapshotSupplier, Suppli *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • get the result from the delegate supplier *
  • if context snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the result
  • * diff --git a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/UnaryOperatorWithContext.java b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/UnaryOperatorWithContext.java index caca8c8e..e5c5ee57 100644 --- a/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/UnaryOperatorWithContext.java +++ b/context-propagation-core/src/main/java/nl/talsmasoftware/context/core/function/UnaryOperatorWithContext.java @@ -16,7 +16,6 @@ package nl.talsmasoftware.context.core.function; import nl.talsmasoftware.context.api.ContextSnapshot; -import nl.talsmasoftware.context.core.ContextManagers; import java.util.function.Consumer; import java.util.function.Supplier; @@ -64,7 +63,7 @@ public UnaryOperatorWithContext(ContextSnapshot snapshot, UnaryOperator deleg *
  • {@linkplain ContextSnapshot#reactivate() reactivate} the given snapshot *
  • apply the delegate operator *
  • if snapshot consumer is non-null, - * pass a {@linkplain ContextManagers#createContextSnapshot() new context snapshot} to the consumer + * pass a {@linkplain ContextSnapshot#capture() new context snapshot} to the consumer *
  • close the {@linkplain ContextSnapshot.Reactivation reactivation} *
  • return the result from the delegate operator call (or throw runtime exception if the delegate did). * diff --git a/timers/context-timer-opentelemetry/src/test/java/nl/talsmasoftware/context/timers/opentelemetry/OpenTelemetryContextTimerTest.java b/timers/context-timer-opentelemetry/src/test/java/nl/talsmasoftware/context/timers/opentelemetry/OpenTelemetryContextTimerTest.java index 34cf9d27..118aec9f 100644 --- a/timers/context-timer-opentelemetry/src/test/java/nl/talsmasoftware/context/timers/opentelemetry/OpenTelemetryContextTimerTest.java +++ b/timers/context-timer-opentelemetry/src/test/java/nl/talsmasoftware/context/timers/opentelemetry/OpenTelemetryContextTimerTest.java @@ -32,7 +32,7 @@ class OpenTelemetryContextTimerTest { OpenTelemetryContextTimer subject = new OpenTelemetryContextTimer(); @Test - void update_ContextManagers_createContextSnapshot() { + void update_ContextSnapshot_capture() { // prepare // execute diff --git a/timers/context-timer-opentracing/src/main/java/nl/talsmasoftware/context/timers/opentracing/OpentracingContextTimer.java b/timers/context-timer-opentracing/src/main/java/nl/talsmasoftware/context/timers/opentracing/OpentracingContextTimer.java index fdf17ace..3f30a245 100644 --- a/timers/context-timer-opentracing/src/main/java/nl/talsmasoftware/context/timers/opentracing/OpentracingContextTimer.java +++ b/timers/context-timer-opentracing/src/main/java/nl/talsmasoftware/context/timers/opentracing/OpentracingContextTimer.java @@ -51,8 +51,8 @@ public void update(Class type, String method, long duration, TimeUnit unit, T Span span = GlobalTracer.get().buildSpan(operationName).withStartTimestamp(startTimestampMicros).start(); try { Map log = new LinkedHashMap<>(); - if ("createContextSnapshot".equals(method)) { - log.put(Fields.EVENT, "New context snapshot created"); + if ("capture".equals(method)) { + log.put(Fields.EVENT, "New context snapshot captured"); } else if ("reactivate".equals(method)) { log.put(Fields.EVENT, "Context snapshot reactivated"); } diff --git a/timers/context-timer-opentracing/src/test/java/nl/talsmasoftware/context/timers/opentracing/OpentracingContextTimerTest.java b/timers/context-timer-opentracing/src/test/java/nl/talsmasoftware/context/timers/opentracing/OpentracingContextTimerTest.java index ad0aeabb..6acfe8ef 100644 --- a/timers/context-timer-opentracing/src/test/java/nl/talsmasoftware/context/timers/opentracing/OpentracingContextTimerTest.java +++ b/timers/context-timer-opentracing/src/test/java/nl/talsmasoftware/context/timers/opentracing/OpentracingContextTimerTest.java @@ -74,7 +74,7 @@ public void testDisabledByDefault() { } @Test - public void testTraceCreateContextSnapshot() { + public void testTraceCaptureContextSnapshot() { System.setProperty(PROPERTY_NAME, "true"); ContextSnapshot.capture(); assertThat(tracer.finishedSpans(), hasItem(withOperationName("ContextSnapshot.capture")));