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 newRequestLocalto get/set values in the currentRequestContext.<T> RequestLocal<T>newRequestLocal(Consumer<T> cleanupListener) Creates a newRequestLocalto 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 theRequestStartedEventhas 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
nullif 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
nullif 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
nullif there is no current request.
-
newRequestLocal
Creates a newRequestLocalto get/set values in the currentRequestContext. Conceptually similar to aThreadLocal, but tied to the currentRequestContextinstead of the current thread.- Type Parameters:
T- the value type- Returns:
- the
RequestLocal - Since:
- 7.9
-
newRequestLocal
Creates a newRequestLocalto get/set values in the currentRequestContext. Conceptually similar to aThreadLocal, but tied to the currentRequestContextinstead of the current thread.- Type Parameters:
T- the value type- Parameters:
cleanupListener- optional listener that is invoked when anRequestContexthas completed and all values in the context are removed. ThecleanupListeneris NOT called if theRequestLocaldoes not contain a value for theRequestContextthat is being wrapped up.- Returns:
- the
RequestLocal - Since:
- 7.9
-