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.

  • Method Details

    • register

      <T> void register(ValueRegistry.RuntimeKey<T> key, T value)
      Registers a value with a specified key.
      Parameters:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      Throws:
      IllegalArgumentException - if the specified key already has an associated value
    • registerInfo

      <T> void registerInfo(ValueRegistry.RuntimeKey<T> key, ValueRegistry.RuntimeInfo<T> runtimeInfo)
      Registers a ValueRegistry.RuntimeInfo with a specified key.
      Parameters:
      key - key with which the specified value is to be associated
      runtimeInfo - value to be associated with the specified key
      Throws:
      IllegalArgumentException - if the specified key already has an associated value
      See Also:
    • get

      <T> T get(ValueRegistry.RuntimeKey<T> key)
      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

      <T> T getOrDefault(ValueRegistry.RuntimeKey<T> key, T defaultValue)
      Returns the value to which the specified key is mapped.
      Parameters:
      key - the key whose associated value is to be returned
      defaultValue - the default mapping of the key
      Returns:
      the value to which the specified key is mapped, or defaultValue if the key has no value
    • containsKey

      <T> boolean containsKey(ValueRegistry.RuntimeKey<T> key)
      Returns true if ValueRegistry contains a mapping for the specified key.
      Parameters:
      key - key whose presence in ValueRegistry is to be tested
      Returns:
      true if ValueRegistry contains 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.RuntimeKey for 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:
      • "io.quarkus.runtime.ValueRegistryConfigSource"