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. -
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 <T extends NamedService>
Optional<T> discoverService(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<? extends ConfiguredProvider<T>> providerType, Class<T> configType, boolean discoverServices, Optional<T> 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>>
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, 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 StringresolveExpression(Config config, String expression) Resolves an expression that may contain references to configuration values with possible default values.
-
Method Details
-
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
-
discoverService
public static <T extends NamedService> Optional<T> discoverService(Config config, String configKey, Optional<ServiceRegistry> serviceRegistry, Class<? extends ConfiguredProvider<T>> providerType, Class<T> configType, boolean discoverServices, Optional<T> existingValue) Used to discover service fromServiceRegistryfor builder options annotated withOption.Provider, if the blueprint is annotated withPrototype.RegistrySupport.- Type Parameters:
T- type of the service- 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)
-
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 configured service provider that creates instances of S- 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)
-
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 configured service provider that creates instances of S- 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
-
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
-