public class HystrixDelegatingRequestContext extends Object implements RequestContext
RequestContex
method calls to the contained delegate, while also initializing and shutting down
a HystrixRequestContext
as needed.Constructor and Description |
---|
HystrixDelegatingRequestContext(RequestContext delegate)
Initializes a
HystrixRequestContext if there is currently none. |
Modifier and Type | Method and Description |
---|---|
Optional<Property<?>> |
getProperty(String name)
Retrieves the property for the given name.
|
Optional<javax.servlet.http.HttpServletRequest> |
getRequest() |
long |
getRequestThreadId() |
Optional<Property<?>> |
removeProperty(String name)
Removes the property with the given name.
|
void |
setPropertyIfAbsent(String name,
Property<?> value)
Sets a value for the property for the given name, if it has not been set before.
|
void |
shutdownHystrixRequestContext()
Shuts down the
HystrixRequestContext if it was initialized by here. |
public HystrixDelegatingRequestContext(@Nonnull RequestContext delegate)
HystrixRequestContext
if there is currently none.delegate
- The actual RequestContext
to delegate all method calls to.public void shutdownHystrixRequestContext()
HystrixRequestContext
if it was initialized by here.@Nonnull public Optional<javax.servlet.http.HttpServletRequest> getRequest()
getRequest
in interface RequestContext
HttpServletRequest
of this instance, if present. Can be absent if the RequestContext
has been created by a RequestContextExecutor
when running outside the normal servlet lifecycle
(e.g. within background tasks).public long getRequestThreadId()
getRequestThreadId
in interface RequestContext
@Nonnull public Optional<Property<?>> getProperty(@Nonnull String name) throws RequestContextPropertyException
getProperty
in interface RequestContext
RequestContextPropertyException
- If there is an issue while accessing the property or if the property has a different type than the
one that is provided.public void setPropertyIfAbsent(@Nonnull String name, @Nonnull Property<?> value) throws RequestContextPropertyException
setPropertyIfAbsent
in interface RequestContext
RequestContextPropertyException
- If there is an issue while setting the property.@Nonnull public Optional<Property<?>> removeProperty(@Nonnull String name) throws RequestContextPropertyException
Caution: Implementations may not be thread-safe!
removeProperty
in interface RequestContext
RequestContextPropertyException
- If there is an issue while removing the property.Copyright © 2019 SAP SE. All rights reserved.