public interface ContextLocal<T>
Context
.
Local storage should be registered before creating a Vertx
instance, once registered a
local storage cannot be unregistered.
It is recommended to initialize local storage as static fields of a VertxServiceProvider
,
since providers are discovered before the capture of known local storages.
Modifier and Type | Method and Description |
---|---|
default T |
get(Context context)
Get the local data from the
context . |
default T |
get(Context context,
AccessMode accessMode)
Like
get(Context) but with an accessMode . |
default T |
get(Context context,
AccessMode accessMode,
java.util.function.Supplier<? extends T> initialValueSupplier)
Like
get(Context, Supplier) but with an accessMode . |
default T |
get(Context context,
java.util.function.Supplier<? extends T> initialValueSupplier)
Get the local data from the
context , when it does not exist then call initialValueSupplier to obtain
the initial value. |
default void |
put(Context context,
AccessMode accessMode,
T value)
Like
#put(Context, T) but with an accessMode . |
default void |
put(Context context,
T data)
Put local data in the
context . |
static <T> ContextLocal<T> |
registerLocal(Class<T> type)
Registers a context local storage.
|
default void |
remove(Context context)
Remove the local data from the context.
|
default void |
remove(Context context,
AccessMode accessMode)
Like
remove(Context) but with an accessMode . |
static <T> ContextLocal<T> registerLocal(Class<T> type)
default T get(Context context, java.util.function.Supplier<? extends T> initialValueSupplier)
context
, when it does not exist then call initialValueSupplier
to obtain
the initial value. The supplier can be called multiple times when several threads call this method concurrently.initialValueSupplier
- the supplier of the initial valuedefault void put(Context context, T data)
context
.data
- the datadefault void remove(Context context)
default T get(Context context, AccessMode accessMode)
get(Context)
but with an accessMode
.default T get(Context context, AccessMode accessMode, java.util.function.Supplier<? extends T> initialValueSupplier)
get(Context, Supplier)
but with an accessMode
.default void put(Context context, AccessMode accessMode, T value)
#put(Context, T)
but with an accessMode
.default void remove(Context context, AccessMode accessMode)
remove(Context)
but with an accessMode
.Copyright © 2024 Eclipse. All rights reserved.