Interface ContextStore<K,C>
-
- Type Parameters:
K- key type to do context lookupsC- context type
public interface ContextStore<K,C>Interface to represent context storage for instrumentations.Context instances are weakly referenced and will be garbage collected when their corresponding key instance is collected.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceContextStore.Factory<C>Factory interface to create context instances.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Cget(K key)Get context given the key.voidput(K key, C context)Put new context instance for given key.CputIfAbsent(K key, C context)Put new context instance if key is absent.CputIfAbsent(K key, ContextStore.Factory<C> contextFactory)Put new context instance if key is absent.
-
-
-
Method Detail
-
get
C get(K key)
Get context given the key.- Parameters:
key- the key to looup- Returns:
- context object
-
put
void put(K key, C context)
Put new context instance for given key.- Parameters:
key- key to usecontext- context instance to save
-
putIfAbsent
C putIfAbsent(K key, C context)
Put new context instance if key is absent.- Parameters:
key- key to usecontext- new context instance to put- Returns:
- old instance if it was present, or new instance
-
putIfAbsent
C putIfAbsent(K key, ContextStore.Factory<C> contextFactory)
Put new context instance if key is absent. Uses context factory to avoid creating objects if not needed.- Parameters:
key- key to usecontextFactory- factory instance to produce new context object- Returns:
- old instance if it was present, or new instance
-
-