Package com.atlassian.bitbucket.request
Interface RequestManager
public interface RequestManager
Sets up and tears down all logic for processing requests, such as logging, access logging, profiling and publishing
RequestStartedEvent
and
RequestEndedEvent
.-
Method Summary
Modifier and TypeMethodDescription<T,
E extends Exception>
TdoAsRequest
(RequestCallback<T, E> callback, RequestInfoProvider requestInfoProvider) Sets up and tears down all logic for processing requests.<T> RequestLocal<T>
Creates a newRequestLocal
to get/set values in the currentRequestContext
.<T> RequestLocal<T>
newRequestLocal
(Consumer<T> cleanupListener) Creates a newRequestLocal
to get/set values in the currentRequestContext
.
-
Method Details
-
doAsRequest
@Nullable <T,E extends Exception> T doAsRequest(@Nonnull RequestCallback<T, E> callback, @Nonnull RequestInfoProvider requestInfoProvider) throws ESets up and tears down all logic for processing requests.- Type Parameters:
T
- type of the requestE
- type of exception- Parameters:
callback
- called after theRequestStartedEvent
has been published.requestInfoProvider
- provides request details such as sessionId, remoteAddress that are used to set up logging.- Returns:
- the return value of the callback
- Throws:
E
- whenRequestCallback.withRequest(RequestContext)
throws an exception.
-
getRequestContext
- Returns:
- the context of the current request. Returns
null
if there is no current request, for instance when running a task in a background thread.
-
getRequestId
- Returns:
- a highly unique (though not guaranteeably unique) request ID. Returns
null
if there is no current request, for instance when running a task in a background thread. - Since:
- 5.0
- See Also:
-
getRequestMetadata
- Returns:
- the metadata of the current request. Returns
null
if there is no current request.
-
newRequestLocal
Creates a newRequestLocal
to get/set values in the currentRequestContext
. Conceptually similar to aThreadLocal
, but tied to the currentRequestContext
instead of the current thread.- Type Parameters:
T
- the value type- Returns:
- the
RequestLocal
- Since:
- 7.9
-
newRequestLocal
Creates a newRequestLocal
to get/set values in the currentRequestContext
. Conceptually similar to aThreadLocal
, but tied to the currentRequestContext
instead of the current thread.- Type Parameters:
T
- the value type- Parameters:
cleanupListener
- optional listener that is invoked when anRequestContext
has completed and all values in the context are removed. ThecleanupListener
is NOT called if theRequestLocal
does not contain a value for theRequestContext
that is being wrapped up.- Returns:
- the
RequestLocal
- Since:
- 7.9
-