Package org.eclipse.hono.util
Class MapBasedExecutionContext
- java.lang.Object
-
- org.eclipse.hono.util.MapBasedExecutionContext
-
- All Implemented Interfaces:
ExecutionContext
public class MapBasedExecutionContext extends Object implements ExecutionContext
An execution context that stores properties in aMap
.
-
-
Constructor Summary
Constructors Constructor Description MapBasedExecutionContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
asMap()
Gets the properties stored in this context.static ExecutionContext
empty()
Creates an empty execution context.<T> T
get(String key)
Gets the value for a key.<T> T
get(String key, T defaultValue)
Gets the value for a key.io.opentracing.SpanContext
getTracingContext()
Gets the OpenTracing context that is used to track the processing of this context.static ExecutionContext
of(Map<String,Object> props)
Creates an execution context for given set of properties.void
put(String key, Object value)
Sets a value for a key.void
setTracingContext(io.opentracing.SpanContext spanContext)
Sets the OpenTracing context to use for tracking the processing of this context.
-
-
-
Method Detail
-
empty
public static ExecutionContext empty()
Creates an empty execution context.- Returns:
- The new context.
-
of
public static ExecutionContext of(Map<String,Object> props)
Creates an execution context for given set of properties.- Parameters:
props
- The properties to add to the new context.- Returns:
- The new context.
-
get
public final <T> T get(String key)
Description copied from interface:ExecutionContext
Gets the value for a key.- Specified by:
get
in interfaceExecutionContext
- Type Parameters:
T
- The type of the value.- Parameters:
key
- The key to get the value for.- Returns:
- The value or
null
if the key is unknown.
-
get
public final <T> T get(String key, T defaultValue)
Description copied from interface:ExecutionContext
Gets the value for a key.- Specified by:
get
in interfaceExecutionContext
- Type Parameters:
T
- The type of the value.- Parameters:
key
- The key to get the value for.defaultValue
- The value to return if the key is unknown.- Returns:
- The value.
-
put
public final void put(String key, Object value)
Description copied from interface:ExecutionContext
Sets a value for a key.- Specified by:
put
in interfaceExecutionContext
- Parameters:
key
- The key.value
- The value.
-
getTracingContext
public io.opentracing.SpanContext getTracingContext()
Description copied from interface:ExecutionContext
Gets the OpenTracing context that is used to track the processing of this context.- Specified by:
getTracingContext
in interfaceExecutionContext
- Returns:
- The context or
null
if no tracing context is set.
-
setTracingContext
public void setTracingContext(io.opentracing.SpanContext spanContext)
Description copied from interface:ExecutionContext
Sets the OpenTracing context to use for tracking the processing of this context.- Specified by:
setTracingContext
in interfaceExecutionContext
- Parameters:
spanContext
- The context.
-
-