Class ConfigBuilderSupport
java.lang.Object
io.helidon.config.ConfigBuilderSupport
Methods used from generated code in builders when
Prototype.Configured is used.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceExtension ofPrototype.Builderthat supports configuration.static final classProvider discovery settings used by generated configured builders. -
Method Summary
Modifier and TypeMethodDescriptionstatic <S extends NamedService, T extends ConfiguredProvider<S>>
Optional<S> discoverService(Config config, String configKey, Class<T> providerType, Class<S> configType, boolean allFromServiceLoader, Optional<S> existingValue) Discover service from configuration.static <S extends NamedService, T extends ConfiguredProvider<S>>
Optional<S> discoverService(Config config, String configKey, Class<T> providerType, Class<S> configType, ConfigBuilderSupport.ProviderSettings settings, Optional<S> existingValue) Used by generated configured builders to discover one service usingServiceLoader, validating the configured provider identity and outer container form when configuration is consulted.static <S extends NamedService, T extends ConfiguredProvider<S>>
Optional<S> discoverService(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<T> providerType, Class<S> configType, boolean discoverServices, Optional<S> existingValue) Used to discover service fromServiceRegistryfor builder options annotated withOption.Provider, if the blueprint is annotated withPrototype.RegistrySupport.static <S extends NamedService, T extends ConfiguredProvider<S>>
Optional<S> discoverService(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<T> providerType, Class<S> configType, ConfigBuilderSupport.ProviderSettings settings, Optional<S> existingValue) Used by generated configured builders to discover one service fromServiceRegistry, validating the configured provider identity and outer container form when configuration is consulted.static <S extends NamedService, T extends ConfiguredProvider<S>>
List<S> discoverServices(Config config, String configKey, Class<T> providerType, Class<S> configType, boolean allFromServiceLoader, List<S> existingInstances) Discover services from configuration.static <S extends NamedService, T extends ConfiguredProvider<S>>
List<S> discoverServices(Config config, String configKey, Class<T> providerType, Class<S> configType, ConfigBuilderSupport.ProviderSettings settings, List<S> existingInstances) Used by generated configured builders to discover services usingServiceLoaderafter the configured provider identity and outer container form have been validated.static <S extends NamedService, T extends ConfiguredProvider<S>>
List<S> discoverServices(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<T> providerType, Class<S> configType, boolean allFromRegistry, List<S> existingValues) Used to discover services fromServiceRegistryfor builder options annotated withOption.Provider, if the blueprint is annotated withPrototype.RegistrySupport.static <S extends NamedService, T extends ConfiguredProvider<S>>
List<S> discoverServices(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<T> providerType, Class<S> configType, ConfigBuilderSupport.ProviderSettings settings, List<S> existingValues) Used by generated configured builders to discover services fromServiceRegistryafter the configured provider identity and outer container form have been validated.static StringresolveExpression(Config config, String expression) Resolves an expression that may contain references to configuration values with possible default values.resolveSetExpressions(Config config, Collection<String> expressions) Resolve expressions from a set of values.static voidvalidateProviderConfig(Config config, String configKey, Option.Provider.Identity identity, Option.Provider.ConfigForm configForm) Validate the configured provider container before generated builder code maps or discovers provider values.
-
Method Details
-
validateProviderConfig
public static void validateProviderConfig(Config config, String configKey, Option.Provider.Identity identity, Option.Provider.ConfigForm configForm) Validate the configured provider container before generated builder code maps or discovers provider values.- Parameters:
config- configuration located at the parent of the provider optionconfigKey- configuration key of the provider optionidentity- configured provider identityconfigForm- configured provider outer container form
-
discoverServices
public static <S extends NamedService, T extends ConfiguredProvider<S>> List<S> discoverServices(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<T> providerType, Class<S> configType, boolean allFromRegistry, List<S> existingValues) Used to discover services fromServiceRegistryfor builder options annotated withOption.Provider, if the blueprint is annotated withPrototype.RegistrySupport.- Type Parameters:
S- type of the serviceT- type of the service provider (contract)- Parameters:
config- configuration of the optionconfigKey- configuration key associated with this optionserviceRegistry- service registry instanceproviderType- type of the service provider (contract)configType- type of the configurationallFromRegistry- whether to use all services from the registryexistingValues- existing values that was explicitly configured by the user- Returns:
- instances from the user augmented with instances from the registry
-
discoverServices
public static <S extends NamedService, T extends ConfiguredProvider<S>> List<S> discoverServices(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<T> providerType, Class<S> configType, ConfigBuilderSupport.ProviderSettings settings, List<S> existingValues) Used by generated configured builders to discover services fromServiceRegistryafter the configured provider identity and outer container form have been validated.- Type Parameters:
S- type of the serviceT- type of the service provider (contract)- Parameters:
config- configuration of the optionconfigKey- configuration key associated with this optionserviceRegistry- service registry instanceproviderType- type of the service provider (contract)configType- type of the configurationsettings- provider identity, outer container form, and discovery settingsexistingValues- values explicitly configured by the user- Returns:
- user instances augmented with instances from the registry
-
discoverService
public static <S extends NamedService, T extends ConfiguredProvider<S>> Optional<S> discoverService(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<T> providerType, Class<S> configType, boolean discoverServices, Optional<S> existingValue) Used to discover service fromServiceRegistryfor builder options annotated withOption.Provider, if the blueprint is annotated withPrototype.RegistrySupport.- Type Parameters:
S- type of the serviceT- type of the service provider (contract)- Parameters:
config- configuration of the optionconfigKey- configuration key associated with this optionserviceRegistry- service registry instanceproviderType- type of the service provider (contract)configType- type of the configurationdiscoverServices- whether to discover services from registryexistingValue- existing value that was explicitly configured by the user- Returns:
- an instance, if available in the registry, or if provided by the user (user's value wins)
-
discoverService
public static <S extends NamedService, T extends ConfiguredProvider<S>> Optional<S> discoverService(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<T> providerType, Class<S> configType, ConfigBuilderSupport.ProviderSettings settings, Optional<S> existingValue) Used by generated configured builders to discover one service fromServiceRegistry, validating the configured provider identity and outer container form when configuration is consulted.- Type Parameters:
S- type of the serviceT- type of the service provider (contract)- Parameters:
config- configuration of the optionconfigKey- configuration key associated with this optionserviceRegistry- service registry instanceproviderType- type of the service provider (contract)configType- type of the configurationsettings- provider identity, outer container form, and discovery settingsexistingValue- value explicitly configured by the user- Returns:
- the configured or discovered service, if available
-
discoverServices
public static <S extends NamedService, T extends ConfiguredProvider<S>> List<S> discoverServices(Config config, String configKey, Class<T> providerType, Class<S> configType, boolean allFromServiceLoader, List<S> existingInstances) Discover services from configuration. If already configured instances contain a service of the same type and name that would be added from configuration, the configuration would be ignored (e.g. the user must make a choice whether to configure, or set using an API).- Type Parameters:
S- type of the expected serviceT- type of the service provider (contract)- Parameters:
config- configuration located at the parent node of the service providersconfigKey- configuration key of the provider list (either a list node, or object, where each child is one service)providerType- type of the service provider interface, used to lookup fromServiceLoaderconfigType- type of the configured serviceallFromServiceLoader- whether all services from service loader should be used, or only the ones with configured nodeexistingInstances- already configured instances- Returns:
- list of discovered services, ordered by
Weight(highest weight is first in the list)
-
discoverServices
public static <S extends NamedService, T extends ConfiguredProvider<S>> List<S> discoverServices(Config config, String configKey, Class<T> providerType, Class<S> configType, ConfigBuilderSupport.ProviderSettings settings, List<S> existingInstances) Used by generated configured builders to discover services usingServiceLoaderafter the configured provider identity and outer container form have been validated.- Type Parameters:
S- type of the expected serviceT- type of the service provider- Parameters:
config- configuration located at the parent node of the service providersconfigKey- configuration key of the provider collectionproviderType- service provider interface used for discoveryconfigType- configured service typesettings- provider identity, outer container form, and discovery settingsexistingInstances- explicitly configured instances- Returns:
- discovered services ordered by weight
-
discoverService
public static <S extends NamedService, T extends ConfiguredProvider<S>> Optional<S> discoverService(Config config, String configKey, Class<T> providerType, Class<S> configType, boolean allFromServiceLoader, Optional<S> existingValue) Discover service from configuration. If an instance is already configured using a builder, it will not be discovered from configuration (e.g. the user must make a choice whether to configure, or set using API).- Type Parameters:
S- type of the expected serviceT- type of the service provider (contract)- Parameters:
config- configuration located at the parent node of the service providersconfigKey- configuration key of the provider list (either a list node, or object, where each child is one service - this method requires * zero to one configured services)providerType- type of the service provider interface, used to lookup fromServiceLoaderconfigType- type of the configured serviceallFromServiceLoader- whether all services from service loader should be used, or only the ones with configured nodeexistingValue- value already configured, if the name is same as discovered from configuration- Returns:
- the first service (ordered by
Weightthat is discovered, or empty optional if none is found
-
discoverService
public static <S extends NamedService, T extends ConfiguredProvider<S>> Optional<S> discoverService(Config config, String configKey, Class<T> providerType, Class<S> configType, ConfigBuilderSupport.ProviderSettings settings, Optional<S> existingValue) Used by generated configured builders to discover one service usingServiceLoader, validating the configured provider identity and outer container form when configuration is consulted.- Type Parameters:
S- type of the expected serviceT- type of the service provider- Parameters:
config- configuration located at the parent node of the service providerconfigKey- configuration key of the provider collectionproviderType- service provider interface used for discoveryconfigType- configured service typesettings- provider identity, outer container form, and discovery settingsexistingValue- explicitly configured value- Returns:
- the configured or discovered service, if available
-
resolveExpression
Resolves an expression that may contain references to configuration values with possible default values. Nested expression are not allowed.- Parameters:
config- configuration instanceexpression- expression to resolve, such as${service.scheme:http}://${service.host:localhost}:${service.port}, whereservice.schemehas a default value ofhttp,service.hosthas a default value oflocalhost, andservice.portdoes not have a default value, and will fail if not configured- Returns:
- expression value with values retrieved from the
configinstance
-
resolveSetExpressions
Resolve expressions from a set of values. This is mostly used from annotations (generated code), where theexpressionsis either a single string, that resolved to a configured value (with comma separated defaults), or multiple strings, each representing a value.- Parameters:
config- configuration to obtain values for expressionexpressions- expressions to use to get actual values- Returns:
- a set of values to be used by an application
-