Keys in MarshalledContext must provide a marshaller and unmarshaller.
Keys in MarshalledContext must provide a marshaller
and unmarshaller. The key id
is used for marshalling and
unmarshalling and thus must be unique. The behavior of the
MarshalledContext when using two keys with the same key id
is undefined.
Represents an opaque type that consists of a key-value pair which can be used to set multiple keys in the context.
Represents an opaque type that consists of a key-value pair which can be used to set multiple keys in the context.
Retrieve the current definition of a key.
Retrieve the current definition of a key.
NoSuchElementException
when the key is undefined
in the current request-local context.
Tells whether key
is defined in the current request-local
context.
Tells whether key
is defined in the current request-local
context.
Retrieve the current definition of a key, but only if it is defined in the current request-local context.
Retrieve the current definition of a key, but only if it is defined in the current request-local context.
Retrieve the current definition of a key if it is defined.
Retrieve the current definition of a key if it is defined.
If it is not defined, orElse
is evaluated and returned.
Bind multiple key-value pairs.
Bind multiple key-value pairs. Keys later in the collection take precedent over keys earlier in the collection.
Bind two keys and values in the scope of fn
.
Bind two keys and values in the scope of fn
.
Bind value
to key
in the scope of fn
.
Bind value
to key
in the scope of fn
.
Unbind the passed-in keys, in the scope of fn
.
Unbind the passed-in keys, in the scope of fn
.
Unbind the passed-in key, in the scope of fn
.
Unbind the passed-in key, in the scope of fn
.
Clears all bindings in the scope of fn
.
Clears all bindings in the scope of fn
.
For example:
context.let(Key1, "value1") { context.let(Key2, "something else") { context.letClearAll { // context.contains(Key1) == false // context.contains(Key2) == false } // context(Key1) == "value1" // context(Key2) == "something else" } }
Store into the current environment a set of marshalled
bindings and run fn
.
Store into the current environment a set of marshalled
bindings and run fn
. Bindings are unmarshalled on demand.
Marshal the current environment into a set of (id, value) pairs.
A marshalled context contains bindings that may be marshalled and sent across process boundaries. A set of marshalled bindings may be restored in the local environment. Thus we can use marshalled contexts to propagate a set of bindings across a whole request tree.