- All Known Implementing Classes:
ThreadLocalRequestContextResolver
public interface RequestContextResolver
The holder for the current request context that is bound to instrumented threads. Allowing lookup
of the current request if it is present. The Default implementation uses ThreadLocal. If you are
able, you should provide an implementation using ScopedValues.
-
Method Summary
Modifier and TypeMethodDescription<T> T
callWith
(ServerContext ctx, Callable<T> callable) Wraps the execution of the given callable in request context processing.Retrieve the current server context.void
runWith
(ServerContext ctx, Runnable runnable) Wraps the execution of the given runnable in request context processing.<T> T
supplyWith
(ServerContext ctx, Supplier<T> supplier) Wraps the execution of the given supplier in request context processing.
-
Method Details
-
callWith
Wraps the execution of the given callable in request context processing.- Type Parameters:
T
- The return type of the callable- Parameters:
ctx
- The request contextcallable
- The callable- Returns:
- The return value of the callable
- Throws:
Exception
- if the callable throws an exception
-
supplyWith
Wraps the execution of the given supplier in request context processing.- Type Parameters:
T
- The return type of the supplier- Parameters:
ctx
- The request contextsupplier
- The supplier- Returns:
- The return value of the supplier
-
runWith
Wraps the execution of the given runnable in request context processing.- Parameters:
ctx
- The request contextrunnable
- The runnable
-
currentRequest
Optional<ServerContext> currentRequest()Retrieve the current server context.- Returns:
- The request context if it is present
-