Package io.quarkus.registry
Interface ValueRegistry
public interface ValueRegistry
Provides a low-level API for registering and accessing runtime values generated by Quarkus or Quarkus
extensions. Typically, such values describe a fully configured application, known only at application startup,
such as the HTTP port. Once a value is added to the
ValueRegistry, it can't be changed.
These values should not be exposed by the Config mechanism directly, as that would require mutating the Config
system, which should be immutable, and cause hard-to-debug issues. Instead, ValueRegistry should be
preferred for exposing such values.
The ValueRegistry should also be the preferred solution when a service requires information from another
service, to avoid dependencies cycles and exposure of internal APIs.
While primarily targeting Quarkus and Quarkus Extensions' internal uses, general Quarkus Applications can also use
The ValueRegistry.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAllows to defer and retrieve instances of an object that represent information only available at runtime withValueRegistry.static final classA typed key. -
Method Summary
Modifier and TypeMethodDescription<T> booleancontainsKey(ValueRegistry.RuntimeKey<T> key) ReturnstrueifValueRegistrycontains a mapping for the specified key.<T> Tget(ValueRegistry.RuntimeKey<T> key) Returns the value to which the specified key is mapped.Deprecated, for removal: This API element is subject to removal in a future version.<T> TgetOrDefault(ValueRegistry.RuntimeKey<T> key, T defaultValue) Returns the value to which the specified key is mapped.<T> voidregister(ValueRegistry.RuntimeKey<T> key, T value) Registers a value with a specified key.<T> voidregisterInfo(ValueRegistry.RuntimeKey<T> key, ValueRegistry.RuntimeInfo<T> runtimeInfo) Registers aValueRegistry.RuntimeInfowith a specified key.
-
Method Details
-
register
Registers a value with a specified key.- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key- Throws:
IllegalArgumentException- if the specified key already has an associated value
-
registerInfo
Registers aValueRegistry.RuntimeInfowith a specified key.- Parameters:
key- key with which the specified value is to be associatedruntimeInfo- value to be associated with the specified key- Throws:
IllegalArgumentException- if the specified key already has an associated value- See Also:
-
get
Returns the value to which the specified key is mapped.- Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped
- Throws:
IllegalArgumentException- if the specified key has no associated value
-
getOrDefault
Returns the value to which the specified key is mapped.- Parameters:
key- the key whose associated value is to be returneddefaultValue- the default mapping of the key- Returns:
- the value to which the specified key is mapped, or
defaultValueif the key has no value
-
containsKey
ReturnstrueifValueRegistrycontains a mapping for the specified key.- Parameters:
key- key whose presence inValueRegistryis to be tested- Returns:
trueifValueRegistrycontains a mapping for the specified key
-
get
Deprecated, for removal: This API element is subject to removal in a future version.Returns the value to which the specified key is mapped.To avoid allocating a
ValueRegistry.RuntimeKeyfor the Config bridge look up.- Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped
- See Also:
-