public class DefaultRequestContext extends Object implements RequestContext
RequestContext
. It represents the context of a request
that can be accessed from within other threads outside the thread that is spawned for the incoming servlet request.Constructor and Description |
---|
DefaultRequestContext(javax.servlet.http.HttpServletRequest request)
Default constructor initializing this
RequestContext with the given HttpServletRequest . |
Modifier and Type | Method and Description |
---|---|
protected boolean |
canEqual(Object other) |
boolean |
equals(Object o) |
ConcurrentMap<String,Property<?>> |
getProperties() |
Optional<Property<?>> |
getProperty(String name)
Retrieves the property for the given name.
|
Optional<javax.servlet.http.HttpServletRequest> |
getRequest() |
long |
getRequestThreadId() |
int |
hashCode() |
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.
|
String |
toString() |
public DefaultRequestContext(@Nullable javax.servlet.http.HttpServletRequest request)
RequestContext
with the given HttpServletRequest
.request
- The HttpServletRequest
for this RequestContext
. May be null
to initialize a
RequestContext
that may be needed by background tasks that are not triggered by a request.@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).@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.public ConcurrentMap<String,Property<?>> getProperties()
protected boolean canEqual(Object other)
public long getRequestThreadId()
getRequestThreadId
in interface RequestContext
Copyright © 2018 SAP SE. All rights reserved.