T
- the type of the object being stored in the CorrelationMap (e.g. a request).public abstract class AbstractCorrelationMap<T> extends Object implements CorrelationMap<T>
CorrelationMap
interface based on a ConcurrentMap.
Subclass can provide a distributable ConcurrentMap variant (such as HazelCast or Apache Ignite) or an in-memory one
using ConcurrentHashMap
.
Modifier and Type | Field and Description |
---|---|
protected ConcurrentMap<String,T> |
map |
Modifier | Constructor and Description |
---|---|
protected |
AbstractCorrelationMap(ConcurrentMapService concurrentMapService) |
Modifier and Type | Method and Description |
---|---|
T |
get(String id)
Retrieves the object stored under the given id.
|
T |
put(String id,
T value)
Stores the given value under the given id in the CorrelationMap.
|
T |
remove(String id)
Deletes the mapping for the given id if one existed.
|
protected void |
setMap(ConcurrentMap<String,T> cacheMap) |
@Nonnull protected volatile ConcurrentMap<String,T> map
protected AbstractCorrelationMap(@Nonnull ConcurrentMapService concurrentMapService)
@Nullable public final T get(@Nonnull String id)
CorrelationMap
get
in interface CorrelationMap<T>
id
- the idnull
if the id was not present or
expired.@Nullable public final T put(@Nonnull String id, @Nonnull T value)
CorrelationMap
put
in interface CorrelationMap<T>
id
- the idvalue
- the object to store in the CorrelationMap for the given id, cannot be null
.null
otherwise.@Nullable public final T remove(@Nonnull String id)
CorrelationMap
remove
in interface CorrelationMap<T>
id
- the idnull
otherwise.protected void setMap(ConcurrentMap<String,T> cacheMap)
Copyright © 2020. All Rights Reserved.