public interface RequestManager
RequestStartedEvent
and
RequestEndedEvent
.Modifier and Type | Method and Description |
---|---|
<T,E extends Exception> |
doAsRequest(RequestCallback<T,E> callback,
RequestInfoProvider requestInfoProvider)
Sets up and tears down all logic for processing requests.
|
RequestContext |
getRequestContext() |
String |
getRequestId() |
RequestMetadata |
getRequestMetadata() |
<T> RequestLocal<T> |
newRequestLocal()
Creates a new
RequestLocal to get/set values in the current RequestContext . |
<T> RequestLocal<T> |
newRequestLocal(Consumer<T> cleanupListener)
Creates a new
RequestLocal to get/set values in the current RequestContext . |
@Nullable <T,E extends Exception> T doAsRequest(@Nonnull RequestCallback<T,E> callback, @Nonnull RequestInfoProvider requestInfoProvider) throws E extends Exception
T
- type of the requestE
- type of exceptioncallback
- called after the RequestStartedEvent
has been published.requestInfoProvider
- provides request details such as sessionId, remoteAddress that are used to
set up logging.E
- when RequestCallback.withRequest(RequestContext)
throws an exception.E extends Exception
@Nullable RequestContext getRequestContext()
null
if there is no current request, for instance
when running a task in a background thread.@Nullable String getRequestId()
null
if there is no
current request, for instance when running a task in a background thread.RequestContext.getId()
@Nullable RequestMetadata getRequestMetadata()
null
if there is no current request.@Nonnull <T> RequestLocal<T> newRequestLocal()
RequestLocal
to get/set values in the current RequestContext
.
Conceptually similar to a ThreadLocal
, but tied to the current RequestContext
instead of
the current thread.T
- the value typeRequestLocal
@Nonnull <T> RequestLocal<T> newRequestLocal(@Nullable Consumer<T> cleanupListener)
RequestLocal
to get/set values in the current RequestContext
.
Conceptually similar to a ThreadLocal
, but tied to the current RequestContext
instead of
the current thread.T
- the value typecleanupListener
- optional listener that is invoked when an RequestContext
has completed and all
values in the context are removed. The cleanupListener
is NOT called if the
RequestLocal
does not contain a value for the RequestContext
that is
being wrapped up.RequestLocal
Copyright © 2022 Atlassian. All rights reserved.