Top Description Inners Fields Constructors Methods
io.micrometer.context

pack-priv final Class DefaultContextSnapshot

extends HashMap<Object, Object>
implements ContextSnapshot
Class Inheritance
All Implemented Interfaces
io.micrometer.context.ContextSnapshot
Imports
java.util.HashMap, .List, .Map, java.util.function.Predicate

Default implementation of ContextSnapshot.
Authors
Rossen Stoyanchev, Brian Clozel, Dariusz Jędrzejczyk
Since
1.0.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
DefaultContextSnapshot.DefaultScope

Default implementation of Scope.

Field Summary

Modifier and TypeField and Description
private final boolean
private final ContextRegistry

Constructor Summary

AccessConstructor and Description
pack-priv
DefaultContextSnapshot(ContextRegistry contextRegistry, boolean clearMissing)

Method Summary

Modifier and TypeMethod and Description
pack-priv static Map<Object, Object>
clearThreadLocal(Object key, ThreadLocalAccessor<?> accessor, Map<Object, Object> previousValues)

pack-priv static <V> Map<Object, Object>
setThreadLocal(Object key, V value, ThreadLocalAccessor<?> accessor, Map<Object, Object> previousValues)

public ContextSnapshot.Scope
public ContextSnapshot.Scope
setThreadLocals(Predicate<Object>
selects keys for use when setting ThreadLocal values
keyPredicate
)

Implements io.micrometer.context.ContextSnapshot.setThreadLocals.

Variant of setThreadLocals() with a predicate to select context values by key.
public String
toString()

Overrides java.util.AbstractMap.toString.

Returns a string representation of this map.
public <C> C
updateContext(C
the context to write to
context
)

Implements io.micrometer.context.ContextSnapshot.updateContext.

Update the given context with all snapshot values.
public <C> C
updateContext(C
the context to write to
context
,
Predicate<Object>
predicate for context value keys
keyPredicate
)

Implements io.micrometer.context.ContextSnapshot.updateContext.

Variant of updateContext(Object) to update the given context with a subset of snapshot values.
private <C> C
updateContextInternal(C context, Map<Object, Object> valueContainer)

Inherited from java.util.HashMap:
clearclonecomputecomputeIfAbsentcomputeIfPresentcontainsKeycontainsValueentrySetforEachgetgetOrDefaultisEmptykeySetmergenewHashMapputputAllputIfAbsentremoveremovereplacereplacereplaceAllsizevalues

Field Detail

clearMissingback to summary
private final boolean clearMissing
contextRegistryback to summary
private final ContextRegistry contextRegistry

Constructor Detail

DefaultContextSnapshotback to summary
pack-priv DefaultContextSnapshot(ContextRegistry contextRegistry, boolean clearMissing)

Method Detail

clearThreadLocalback to summary
pack-priv static Map<Object, Object> clearThreadLocal(Object key, ThreadLocalAccessor<?> accessor, Map<Object, Object> previousValues)
Annotations
@SuppressWarnings:unchecked
setThreadLocalback to summary
pack-priv static <V> Map<Object, Object> setThreadLocal(Object key, V value, ThreadLocalAccessor<?> accessor, Map<Object, Object> previousValues)
Annotations
@SuppressWarnings:unchecked
setThreadLocalsback to summary
public ContextSnapshot.Scope setThreadLocals()

Implements io.micrometer.context.ContextSnapshot.setThreadLocals.

Doc from io.micrometer.context.ContextSnapshot.setThreadLocals.

Set ThreadLocal values from the snapshot.

Returns:ContextSnapshot.Scope

an object that can be used to reset ThreadLocal values at the end of the context scope, either removing them or restoring their previous values, if any.

Annotations
@Override
setThreadLocalsback to summary
public ContextSnapshot.Scope setThreadLocals(Predicate<Object> keyPredicate)

Implements io.micrometer.context.ContextSnapshot.setThreadLocals.

Doc from io.micrometer.context.ContextSnapshot.setThreadLocals.

Variant of setThreadLocals() with a predicate to select context values by key.

Parameters
keyPredicate:Predicate<Object>

selects keys for use when setting ThreadLocal values

Returns:ContextSnapshot.Scope

an object that can be used to reset ThreadLocal values at the end of the context scope, either removing them or restoring their previous values, if any.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.util.AbstractMap.toString.

Doc from java.util.AbstractMap.toString.

Returns a string representation of this map. The string representation consists of a list of key-value mappings in the order returned by the map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space). Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. Keys and values are converted to strings as by String#valueOf(Object).

Returns:String

a string representation of this map

Annotations
@Override
updateContextback to summary
public <C> C updateContext(C context)

Implements io.micrometer.context.ContextSnapshot.updateContext.

Doc from io.micrometer.context.ContextSnapshot.updateContext.

Update the given context with all snapshot values.

Parameters
<C>
the type of the target context
context:C

the context to write to

Returns:C

a context, possibly a new instance, with the written values

Annotations
@Override
updateContextback to summary
public <C> C updateContext(C context, Predicate<Object> keyPredicate)

Implements io.micrometer.context.ContextSnapshot.updateContext.

Doc from io.micrometer.context.ContextSnapshot.updateContext.

Variant of updateContext(Object) to update the given context with a subset of snapshot values.

Parameters
<C>
the type of the target context
context:C

the context to write to

keyPredicate:Predicate<Object>

predicate for context value keys

Returns:C

a context, possibly a new instance, with the written values

Annotations
@Override
updateContextInternalback to summary
private <C> C updateContextInternal(C context, Map<Object, Object> valueContainer)
Annotations
@SuppressWarnings:unchecked
io.micrometer.context back to summary

pack-priv Class DefaultContextSnapshot.DefaultScope

extends Object
implements Scope
Class Inheritance
All Implemented Interfaces
io.micrometer.context.ContextSnapshot.Scope, java.lang.AutoCloseable

Default implementation of Scope.

Field Summary

Modifier and TypeField and Description
private final ContextRegistry
private final Map<Object, Object>

Constructor Summary

AccessConstructor and Description
private
DefaultScope(Map<Object, Object> previousValues, ContextRegistry contextRegistry)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements io.micrometer.context.ContextSnapshot.Scope.close.

Reset ThreadLocal values, either removing them or restoring their previous values, if any.
public static ContextSnapshot.Scope
from(Map<Object, Object> previousValues, ContextRegistry registry)

private <V> void
resetThreadLocalValue(ThreadLocalAccessor<?> accessor, V previousValue)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextRegistryback to summary
private final ContextRegistry contextRegistry
previousValuesback to summary
private final Map<Object, Object> previousValues

Constructor Detail

DefaultScopeback to summary
private DefaultScope(Map<Object, Object> previousValues, ContextRegistry contextRegistry)

Method Detail

closeback to summary
public void close()

Implements io.micrometer.context.ContextSnapshot.Scope.close.

Doc from io.micrometer.context.ContextSnapshot.Scope.close.

Reset ThreadLocal values, either removing them or restoring their previous values, if any.

Annotations
@Override
fromback to summary
public static ContextSnapshot.Scope from(Map<Object, Object> previousValues, ContextRegistry registry)
resetThreadLocalValueback to summary
private <V> void resetThreadLocalValue(ThreadLocalAccessor<?> accessor, V previousValue)
Annotations
@SuppressWarnings:unchecked