public final class ServerRequestContext extends Object
HttpRequest that is bound to instrumented threads.
Allowing lookup of the current request if it is present.| Modifier and Type | Method and Description |
|---|---|
static <T> Optional<HttpRequest<T>> |
currentRequest()
Retrieve the current server request context.
|
static Runnable |
instrument(HttpRequest request,
Runnable runnable)
Return a new runnable by instrumenting the given runnable with request context handling.
|
static <T> T |
with(HttpRequest request,
Callable<T> callable)
Wrap the execution of the given callable in request context processing.
|
static void |
with(HttpRequest request,
Runnable runnable)
Wrap the execution of the given runnable in request context processing.
|
static <T> T |
with(HttpRequest request,
Supplier<T> callable)
Wrap the execution of the given callable in request context processing.
|
public static void with(HttpRequest request, Runnable runnable)
request - The requestrunnable - The runnablepublic static Runnable instrument(HttpRequest request, Runnable runnable)
request - The requestrunnable - The runnablepublic static <T> T with(HttpRequest request, Supplier<T> callable)
T - The return type of the callablerequest - The requestcallable - The callablepublic static <T> T with(HttpRequest request, Callable<T> callable) throws Exception
T - The return type of the callablerequest - The requestcallable - The callableException - If the callable throws an exceptionpublic static <T> Optional<HttpRequest<T>> currentRequest()
T - The body type