Class ThreadLocalCapturingInterceptor
java.lang.Object
ca.uhn.fhir.rest.client.interceptor.ThreadLocalCapturingInterceptor
- All Implemented Interfaces:
ca.uhn.fhir.rest.client.api.IClientInterceptor
public class ThreadLocalCapturingInterceptor
extends Object
implements ca.uhn.fhir.rest.client.api.IClientInterceptor
This is a client interceptor that captures the current request and response
in a ThreadLocal variable, meaning that it can work in multithreaded
environments without mixing up requests.
Use this with caution, since this interceptor does not automatically clean up
the ThreadLocal after setting it. You must make sure to call
clearThreadLocals()
after a given request has been completed,
or you will end up leaving stale request/response objects associated
with threads that no longer need them.
- Since:
- 3.5.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method should be called at the end of any request process, in order to clear the last request and response from the current thread.ca.uhn.fhir.rest.client.api.IHttpRequest
ca.uhn.fhir.rest.client.api.IHttpResponse
void
interceptRequest
(ca.uhn.fhir.rest.client.api.IHttpRequest theRequest) void
interceptResponse
(ca.uhn.fhir.rest.client.api.IHttpResponse theResponse) boolean
Should we buffer (capture) the response body? This defaults tofalse
.setBufferResponse
(boolean theBufferResponse) Should we buffer (capture) the response body? This defaults tofalse
.
-
Constructor Details
-
ThreadLocalCapturingInterceptor
public ThreadLocalCapturingInterceptor()
-
-
Method Details
-
clearThreadLocals
This method should be called at the end of any request process, in order to clear the last request and response from the current thread. -
getRequestForCurrentThread
-
getResponseForCurrentThread
-
interceptRequest
- Specified by:
interceptRequest
in interfaceca.uhn.fhir.rest.client.api.IClientInterceptor
-
interceptResponse
- Specified by:
interceptResponse
in interfaceca.uhn.fhir.rest.client.api.IClientInterceptor
-
isBufferResponse
Should we buffer (capture) the response body? This defaults tofalse
. Set totrue
if you are planning on examining response bodies after the response processing is complete. -
setBufferResponse
Should we buffer (capture) the response body? This defaults tofalse
. Set totrue
if you are planning on examining response bodies after the response processing is complete.
-