- All Superinterfaces:
org.eclipse.microprofile.config.Config
- All Known Implementing Classes:
SmallRyeConfig
Config provides a way to retrieve configuration values from a configuration name.
A Config instance is obtained via the SmallRyeConfigBuilder.build(), or by calling the static
methods getOrCreate(), getOrCreate(ClassLoader),
get() or get(ClassLoader), which
details how Config will behave. Generally, a Config instance is composed of:
- Configuration Sources to lookup the configuration values
- Converters to convert values to specific types
- Interceptors to enhance the configuration lookup process
- ConfigMapping Config Mappings classes to group multiple configuration values in a common prefix
-
Field Summary
Fields inherited from interface org.eclipse.microprofile.config.Config
PROFILE, PROPERTY_EXPRESSIONS_ENABLED -
Method Summary
Modifier and TypeMethodDescription<T> TconvertValue(ConfigValue configValue, org.eclipse.microprofile.config.spi.Converter<T> converter) Returns the value for the specifiedConfigValue, converting the value using the specifiedConverter.static Configget()Get aSmallRyeConfiginstance for the currentThread.getContextClassLoader().static Configget(ClassLoader classLoader) Get aSmallRyeConfiginstance for the specifiedClassLoader.<T> TgetConfigMapping(Class<T> type) Returns an instance of aConfigMappingannotated type, mapping all the configuration names matching theConfigMapping.prefix()and theConfigMappingmembers to values from the underlying configuration sources.<T> TgetConfigMapping(Class<T> type, String prefix) Returns an instance of aConfigMappingannotated type, mapping all the configuration names matching the prefix and theConfigMappingmembers to values from the underlying configuration sources.Optional<org.eclipse.microprofile.config.spi.ConfigSource> getConfigSource(String name) Return the first registered configuration sources inSmallRyeConfigthat match the specified name, sorted by descending ordinal value and name.Iterable<org.eclipse.microprofile.config.spi.ConfigSource> Iterable<org.eclipse.microprofile.config.spi.ConfigSource> getConfigSources(Class<?> type) Return the currently registered configuration sources inSmallRyeConfigthat match the specified type.getConfigValue(String name) Returns theConfigValuefor the specified configuration name from the underlying configuration sources.Provides a way to retrieve an updated list of all property names.<T> Optional<T> getOptionalValue(String name, Class<T> propertyType) Returns the value for the specified configuration name from the underlying configuration sources.<T> Optional<T> getOptionalValue(String name, org.eclipse.microprofile.config.spi.Converter<T> converter) Returns the value for the specified configuration name from the underlying configuration sources.getOptionalValues(String name, Class<K> keyClass, Class<V> valueClass) Returns the values for the specified configuration name from the underlying configuration sources.<K,V, C extends Collection<V>>
Optional<Map<K, C>> getOptionalValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.getOptionalValues(String name, Class<T> propertyType) Returns the values for the specified configuration name from the underlying configuration sources.<T,C extends Collection<T>>
Optional<C> getOptionalValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter) Returns the values for the specified configuration name from the underlying configuration sources.<K,V, C extends Collection<V>>
Optional<Map<K, C>> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K, C>> mapFactory, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K, V>> mapFactory) Returns the values for the specified configuration name from the underlying configuration sources.<T,C extends Collection<T>>
Optional<C> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.static ConfigGet or Create aSmallRyeConfiginstance for the currentThread.getContextClassLoader().static ConfiggetOrCreate(ClassLoader classLoader) Get or Create aSmallRyeConfiginstance for the specifiedClassLoader.Returns aListof the active profiles inSmallRyeConfig.This implementation caches the list of property names collected whenSmallRyeConfigis built viaSmallRyeConfigBuilder.build().<T> TReturns the value for the specified configuration name from the underlying configuration sources.<T> TReturns the value for the specified configuration name from the underlying configuration sources.<K,V> Map <K, V> Returns the values for the specified configuration name from the underlying configuration sources.<K,V, C extends Collection<V>>
Map<K, C> getValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.<T> List<T> Returns the values for the specified configuration name from the underlying configuration sources.<T,C extends Collection<T>>
CgetValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.<K,V> Map <K, V> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter) Returns the values for the specified configuration name from the underlying configuration sources.<K,V, C extends Collection<V>>
Map<K, C> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K, C>> mapFactory, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.<K,V> Map <K, V> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K, V>> mapFactory) Returns the values for the specified configuration name from the underlying configuration sources.<T,C extends Collection<T>>
CgetValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.booleanisPropertyPresent(String name) Checks if a property is present in theConfiginstance.<T> org.eclipse.microprofile.config.spi.Converter<T> requireConverter(Class<T> asType) Return theConverterused by this instance to produce instances of the specified type fromStringvalues.Methods inherited from interface org.eclipse.microprofile.config.Config
getConverter, unwrap
-
Method Details
-
getValues
Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returningListconverted to their specified property type. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in a
Listwith the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in aListwith the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Specified by:
getValuesin interfaceorg.eclipse.microprofile.config.Config- Type Parameters:
T- the item type- Parameters:
name- The configuration property name to look for in the configurationpropertyType- The type into which the resolved property values are converted- Returns:
- the resolved property values as a
Listof instances of the property type - Throws:
IllegalArgumentException- if the property values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getValues
<T,C extends Collection<T>> C getValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returningCollectionconverted to their specified property type. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in a
Collectionwith the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in aCollectionwith the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
T- the item typeC- the collection type- Parameters:
name- The configuration property name to look for in the configurationitemClass- The type into which the resolved property values are convertedcollectionFactory- the resulting instance of aCollectionto return the property values- Returns:
- the resolved property values as a
Collectionof instances of the property type - Throws:
IllegalArgumentException- if the property values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getValues
<T,C extends Collection<T>> C getValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returningCollectionconverted by the specifiedConverter. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in a
Collectionwith the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in aCollectionwith the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand theConverterto convert the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
T- the item typeC- the collection type- Parameters:
name- The configuration property name to look for in the configurationconverter- TheConverterto use to convert the resolved property valuescollectionFactory- the resulting instance of aCollectionto return the property values- Returns:
- the resolved property values as a
Collectionof instances of the property type - Throws:
IllegalArgumentException- if the property values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getValues
Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent aMapkey, asmy.property.key, wheremy.propertyis the property name andkeyis theMapkey. All keyed properties are queried for their values, which represent a single entry in the returningMapconverting both the key and value to their specified types. The following configuration:- server.reasons.200=OK
- server.reasons.201=CREATED
- server.reasons.404=NOT_FOUND
Results in a
Mapwith the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasons, the key type asIntegerand the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;with the backslash (\) as the escape character. A configuration ofserver.reasons=200=OK;201=CREATED;404=NOT_FOUNDresults in aMapwith the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasons, the key type asIntegerand the property type as aString.The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value type- Parameters:
name- The configuration property name to look for in the configurationkeyClass- The type into which the resolved property keys are convertedvalueClass- The type into which the resolved property values are converted- Returns:
- the resolved property values as a
Mapof keys of the property name and values of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getValues
<K,V> Map<K,V> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent aMapkey, asmy.property.key, wheremy.propertyis the property name andkeyis theMapkey. All keyed properties are queried for their values, which represent a single entry in the returningMapconverting both the key and value using the specified Converters. The following configuration:- server.reasons.200=OK
- server.reasons.201=CREATED
- server.reasons.404=NOT_FOUND
Results in a
Mapwith the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasonsand Converters to convert the key type as anIntegerand the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;with the backslash (\) as the escape character. A configuration ofserver.reasons=200=OK;201=CREATED;404=NOT_FOUNDresults in aMapwith the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasonsand Converters to convert the key type as anIntegerand the property type as aString.The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value type- Parameters:
name- The configuration property name to look for in the configurationkeyConverter- TheConverterto use to convert the resolved property keysvalueConverter- TheConverterto use to convert the resolved property values- Returns:
- the resolved property values as a
Mapof keys of the property name and values of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getValues
<K,V> Map<K,V> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K, V>> mapFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent aMapkey, asmy.property.key, wheremy.propertyis the property name andkeyis theMapkey. All keyed properties are queried for their values, which represent a single entry in the returningMapconverting both the key and value using the specified Converters. The following configuration:- server.reasons.200=OK
- server.reasons.201=CREATED
- server.reasons.404=NOT_FOUND
Results in a
Mapwith the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasonsand Converters to convert the key type as anIntegerand the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;with the backslash (\) as the escape character. A configuration ofserver.reasons=200=OK;201=CREATED;404=NOT_FOUNDresults in aMapwith the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasonsand Converters to convert the key type as anIntegerand the property type as aString.The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value type- Parameters:
name- The configuration property name to look for in the configurationkeyConverter- TheConverterto use to convert the resolved property keysvalueConverter- TheConverterto use to convert the resolved property valuesmapFactory- the resulting instance of aMapto return the property keys and values- Returns:
- the resolved property values as a
Mapof keys of the property name and values of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getValues
<K,V, Map<K,C extends Collection<V>> C> getValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed indexed properties. A keyed indexed property uses the original property name plus an additional dotted segment to represent aMapkey followed by square brackets and an index in between, asmy.property.key[0], wheremy.propertyis the property name,keyis theMapkey and {code [0]} the index of theCollectionelement. All keyed indexed properties are queried for their value, which represent a single entry in the returningMap, and single element in theCollectionvalue, converting both the key and value to their specified types. The following configuration:- server.env.prod[0]=alpha
- server.env.prod[1]=beta
- server.env.dev[0]=local
Results in a
Mapwith the entry keyprodand entry valueCollectionwith the valuesalphaandbeta, and the entry keydevand entry valueCollectionwith the valuelocal, considering the configuration name asserver.env, the key type as aString, and the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;and value as a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofserver.env=prod=alpha,beta;dev=localresults in aMapwith the entry keyprodand entry valueCollectionwith the valuesalphaandbeta, and the entry keydevand entry valueCollectionwith the valuelocal, considering the configuration name asserver.env, the key type as aString, and the property type as aString.The keyed indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value typeC- the collection type- Parameters:
name- The configuration property name to look for in the configurationkeyClass- The type into which the resolved property keys are convertedvalueClass- The type into which the resolved property values are convertedcollectionFactory- the resulting instance of aCollectionto return the property values- Returns:
- the resolved property values as a
Mapof keys of the property name and values as aCollectionsof instances of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getValues
<K,V, Map<K,C extends Collection<V>> C> getValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K, C>> mapFactory, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed indexed properties. A keyed indexed property uses the original property name plus an additional dotted segment to represent aMapkey followed by square brackets and an index in between, asmy.property.key[0], wheremy.propertyis the property name,keyis theMapkey and {code [0]} the index of theCollectionelement. All keyed indexed properties are queried for their value, which represent a single entry in the returningMap, and single element in theCollectionvalue, converting both the key and value using the specified Converters. The following configuration:- server.env.prod[0]=alpha
- server.env.prod[1]=beta
- server.env.dev[0]=local
Results in a
Mapwith the entry keyprodand entry valueCollectionwith the valuesalphaandbeta, and the entry keydevand entry valueCollectionwith the valuelocal, considering the configuration name asserver.envand Converters to convert the key type as aStringand the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;and value as a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofserver.env=prod=alpha,beta;dev=localresults in aMapwith the entry keyprodand entry valueCollectionwith the valuesalphaandbeta, and the entry keydevand entry valueCollectionwith the valuelocal, considering the configuration name asserver.env, and Converters to convert the key type as aStringand the property type as aString.The keyed indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value typeC- the collection type- Parameters:
name- The configuration property name to look for in the configurationkeyConverter- TheConverterto use to convert the resolved property keysvalueConverter- TheConverterto use to convert the resolved property valuesmapFactory- the resulting instance of aMapto return the property keys and valuescollectionFactory- the resulting instance of aCollectionto return the property values- Returns:
- the resolved property values as a
Mapof keys of the property name and values as aCollectionsof instances of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getValue
Returns the value for the specified configuration name from the underlying configuration sources.If the requested type is a type array, the lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returning type array converted to their specified property type. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in an array with the elements
dog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in an array with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Specified by:
getValuein interfaceorg.eclipse.microprofile.config.Config- Type Parameters:
T- the property type- Parameters:
name- The configuration property name to look for in the configurationpropertyType- The type into which the resolved property value is converted- Returns:
- the resolved property value as an instance of the property type
- Throws:
IllegalArgumentException- if the property values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getValue
Returns the value for the specified configuration name from the underlying configuration sources.If the requested type is a type array, the lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returning type array converted by the specifiedConverter. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in an array with the elements
dog,cat, andturtle, considering the configuration name asmy.propertyand theConverterto convert the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in an array with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand theConverterto convert the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
T- the property type- Parameters:
name- The configuration property name to look for in the configurationconverter- TheConverterto use to convert the resolved property value- Returns:
- the resolved property value as an instance of the converter type
- Throws:
IllegalArgumentException- if the property values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
convertValue
<T> T convertValue(ConfigValue configValue, org.eclipse.microprofile.config.spi.Converter<T> converter) Returns the value for the specifiedConfigValue, converting the value using the specifiedConverter.- Type Parameters:
T- the property type- Parameters:
configValue- aConfigValuewith the value to convertconverter- TheConverterto use to convert the resolved property value- Returns:
- the resolved property value as an instance of the converter type
-
getConfigValue
Returns theConfigValuefor the specified configuration name from the underlying configuration sources.The lookup of the configuration is performed immediately, meaning that calls to
ConfigValuewill always yield the same results.A
ConfigValueis always returned even if a property name cannot be found. In this case, every method inConfigValuereturnsnull, or the default value for primitive types, except forConfigValue.getName(), which includes the original property name being looked up.- Specified by:
getConfigValuein interfaceorg.eclipse.microprofile.config.Config- Parameters:
name- The configuration property name to look for in the configuration- Returns:
- the resolved property value as a
ConfigValue
-
getOptionalValue
Returns the value for the specified configuration name from the underlying configuration sources.If the requested type is a type array, the lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returning type array converted to their specified property type. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in an array with the elements
dog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in an array with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Specified by:
getOptionalValuein interfaceorg.eclipse.microprofile.config.Config- Type Parameters:
T- the property type- Parameters:
name- The configuration property name to look for in the configurationpropertyType- The type into which the resolved property value is converted- Returns:
- the resolved property value as a
Optionalinstance of the property type - Throws:
IllegalArgumentException- if the property values cannot be converted to the specified type- See Also:
-
getOptionalValue
<T> Optional<T> getOptionalValue(String name, org.eclipse.microprofile.config.spi.Converter<T> converter) Returns the value for the specified configuration name from the underlying configuration sources.If the requested type is a type array, the lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returning type array converted by the specifiedConverter. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in an array with the elements
dog,cat, andturtle, considering the configuration name asmy.propertyand theConverterto convert the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in an array with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand theConverterto convert the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
T- the property type- Parameters:
name- The configuration property name to look for in the configurationconverter- TheConverterto use to convert the resolved property value- Returns:
- the resolved property value as a
Optionalinstance of the property type - Throws:
IllegalArgumentException- if the property values cannot be converted to the specified type- See Also:
-
getOptionalValues
Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returningOptional<List>converted to their specified property type. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in an
Optional<List>with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in aOptional<List>with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Specified by:
getOptionalValuesin interfaceorg.eclipse.microprofile.config.Config- Type Parameters:
T- the item type- Parameters:
name- The configuration property name to look for in the configurationpropertyType- The type into which the resolved property values are converted- Returns:
- the resolved property values as a
Optional<List>of instances of the property type - Throws:
IllegalArgumentException- if the property values cannot be converted to the specified type- See Also:
-
getOptionalValues
<T,C extends Collection<T>> Optional<C> getOptionalValues(String name, Class<T> itemClass, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returningOptional<Collection>converted to their specified property type. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in a
Optional<Collection>with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in aOptional<Collection>with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
T- the item typeC- the collection type- Parameters:
name- The configuration property name to look for in the configurationitemClass- The type into which the resolved property values are convertedcollectionFactory- the resulting instance of aCollectionto return the property values- Returns:
- the resolved property values as a
Optional<Collection>of instances of the property type - Throws:
IllegalArgumentException- if the property values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getOptionalValues
<T,C extends Collection<T>> Optional<C> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<T> converter, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for indexed properties. An indexed property uses the original property name with square brackets and an index in between, asmy.property[0]. All indexed properties are queried for their value, which represents a single element in the returningOptional<Collection>converted by the specifiedConverter. The following configuration:- my.property[0]=dog
- my.property[1]=cat
- my.property[2]=turtle
Results in a
Optional<Collection>with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.Otherwise, the configuration value is a single element that a comma-separated string (
,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofmy.property=dog,cat,turtleresults in aOptional<Collection>with the elementsdog,cat, andturtle, considering the configuration name asmy.propertyand the property type as aString.The indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
T- the item typeC- the collection type- Parameters:
name- The configuration property name to look for in the configurationconverter- TheConverterto use to convert the resolved property valuescollectionFactory- the resulting instance of aCollectionto return the property values- Returns:
- the resolved property values as a
Optional<Collection>of instances of the property type - Throws:
IllegalArgumentException- if the property values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getOptionalValues
Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent aMapkey, asmy.property.key, wheremy.propertyis the property name andkeyis theMapkey. All keyed properties are queried for their values, which represent a single entry in the returningOptional<Map>converting both the key and value to their specified types. The following configuration:- server.reasons.200=OK
- server.reasons.201=CREATED
- server.reasons.404=NOT_FOUND
Results in a
Optional<Map>with the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasons, the key type asIntegerand the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;with the backslash (\) as the escape character. A configuration ofserver.reasons=200=OK;201=CREATED;404=NOT_FOUNDresults in aOptional<Map>with the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasons, the key type asIntegerand the property type as aString.The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value type- Parameters:
name- The configuration property name to look for in the configurationkeyClass- The type into which the resolved property keys are convertedvalueClass- The type into which the resolved property values are converted- Returns:
- the resolved property values as a
Optional<Map>of keys of the property name and values of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getOptionalValues
<K,V> Optional<Map<K,V>> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent aMapkey, asmy.property.key, wheremy.propertyis the property name andkeyis theMapkey. All keyed properties are queried for their values, which represent a single entry in the returningOptional<Map>converting both the key and value using the specified Converters. The following configuration:- server.reasons.200=OK
- server.reasons.201=CREATED
- server.reasons.404=NOT_FOUND
Results in a
Optional<Map>with the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasonsand Converters to convert the key type as anIntegerand the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;with the backslash (\) as the escape character. A configuration ofserver.reasons=200=OK;201=CREATED;404=NOT_FOUNDresults in aOptional<Map>with the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasonsand Converters to convert the key type as anIntegerand the property type as aString.The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value type- Parameters:
name- The configuration property name to look for in the configurationkeyConverter- TheConverterto use to convert the resolved property keysvalueConverter- TheConverterto use to convert the resolved property values- Returns:
- the resolved property values as a
Optional<Map>of keys of the property name and values of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getOptionalValues
<K,V> Optional<Map<K,V>> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K, V>> mapFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed properties. A keyed property uses the original property name plus an additional dotted segment to represent aMapkey, asmy.property.key, wheremy.propertyis the property name andkeyis theMapkey. All keyed properties are queried for their values, which represent a single entry in the returningOptional<Map>converting both the key and value using the specified Converters. The following configuration:- server.reasons.200=OK
- server.reasons.201=CREATED
- server.reasons.404=NOT_FOUND
Results in a
Optional<Map>with the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasonsand Converters to convert the key type as anIntegerand the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;with the backslash (\) as the escape character. A configuration ofserver.reasons=200=OK;201=CREATED;404=NOT_FOUNDresults in aOptional<Map>with the entries200=OK,201=CREATED, and404=NOT_FOUND, considering the configuration name asserver.reasonsand Converters to convert the key type as anIntegerand the property type as aString.The keyed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value type- Parameters:
name- The configuration property name to look for in the configurationkeyConverter- TheConverterto use to convert the resolved property keysvalueConverter- TheConverterto use to convert the resolved property valuesmapFactory- the resulting instance of aMapto return the property keys and values- Returns:
- the resolved property values as a
Optional<Map>of keys of the property name and values of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified typeNoSuchElementException- if the property isn't present in the configuration or is defined as an empty string, or the converter returnsnull- See Also:
-
getOptionalValues
<K,V, Optional<Map<K,C extends Collection<V>> C>> getOptionalValues(String name, Class<K> keyClass, Class<V> valueClass, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed indexed properties. A keyed indexed property uses the original property name plus an additional dotted segment to represent aMapkey followed by square brackets and an index in between, asmy.property.key[0], wheremy.propertyis the property name,keyis theMapkey and {code [0]} the index of theCollectionelement. All keyed indexed properties are queried for their value, which represent a single entry in the returningOptional<Map>, and single element in theCollectionvalue, converting both the key and value to their specified types. The following configuration:- server.env.prod[0]=alpha
- server.env.prod[1]=beta
- server.env.dev[0]=local
Results in a
Optional<Map>with the entry keyprodand entry valueCollectionwith the valuesalphaandbeta, and the entry keydevand entry valueCollectionwith the valuelocal, considering the configuration name asserver.env, the key type as aString, and the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;and value as a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofserver.env=prod=alpha,beta;dev=localresults in aOptional<Map>with the entry keyprodand entry valueCollectionwith the valuesalphaandbeta, and the entry keydevand entry valueCollectionwith the valuelocal, considering the configuration name asserver.env, the key type as aString, and the property type as aString.The keyed indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value typeC- the collection type- Parameters:
name- The configuration property name to look for in the configurationkeyClass- The type into which the resolved property keys are convertedvalueClass- The type into which the resolved property values are convertedcollectionFactory- the resulting instance of aCollectionto return the property values- Returns:
- the resolved property values as a
Optional<Map>of keys of the property name and values as aCollectionsof instances of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified type- See Also:
-
getOptionalValues
<K,V, Optional<Map<K,C extends Collection<V>> C>> getOptionalValues(String name, org.eclipse.microprofile.config.spi.Converter<K> keyConverter, org.eclipse.microprofile.config.spi.Converter<V> valueConverter, IntFunction<Map<K, C>> mapFactory, IntFunction<C> collectionFactory) Returns the values for the specified configuration name from the underlying configuration sources.The lookup to the configuration will first query
getPropertyNames()for keyed indexed properties. A keyed indexed property uses the original property name plus an additional dotted segment to represent aMapkey followed by square brackets and an index in between, asmy.property.key[0], wheremy.propertyis the property name,keyis theMapkey and {code [0]} the index of theCollectionelement. All keyed indexed properties are queried for their value, which represent a single entry in the returningOptional<Map>, and single element in theCollectionvalue, converting both the key and value using the specified Converters. The following configuration:- server.env.prod[0]=alpha
- server.env.prod[1]=beta
- server.env.dev[0]=local
Results in a
Optional<Map>with the entry keyprodand entry valueCollectionwith the valuesalphaandbeta, and the entry keydevand entry valueCollectionwith the valuelocal, considering the configuration name asserver.envand Converters to convert the key type as aStringand the property type as aString.Otherwise, the configuration value is a single element represented by key value pairs as
<key1>=<value1>;<key2>=<value2>...separated by a semicolon;and value as a comma-separated string (,) can represent, and split into multiple elements with the backslash (\) as the escape character. A configuration ofserver.env=prod=alpha,beta;dev=localresults in aOptional<Map>with the entry keyprodand entry valueCollectionwith the valuesalphaandbeta, and the entry keydevand entry valueCollectionwith the valuelocal, considering the configuration name asserver.env, and Converters to convert the key type as aStringand the property type as aString.The keyed indexed property format has priority when both styles are found in the same configuration source. When available in multiple sources, the higher ordinal source wins, like any other configuration lookup.
- Type Parameters:
K- the key typeV- the value typeC- the collection type- Parameters:
name- The configuration property name to look for in the configurationkeyConverter- TheConverterto use to convert the resolved property keysvalueConverter- TheConverterto use to convert the resolved property valuesmapFactory- the resulting instance of aMapto return the property keys and valuescollectionFactory- the resulting instance of aCollectionto return the property values- Returns:
- the resolved property values as a
Optional<Map>of keys of the property name and values as aCollectionsof instances of the property type - Throws:
IllegalArgumentException- if the property keys or values cannot be converted to the specified type- See Also:
-
getConfigMapping
Returns an instance of aConfigMappingannotated type, mapping all the configuration names matching theConfigMapping.prefix()and theConfigMappingmembers to values from the underlying configuration sources.ConfigMapping instances are cached. They are populated when the
SmallRyeConfiginstance is initialized and their values are not updated on configuration sources changes.- Type Parameters:
T- the type of theConfigMapping- Parameters:
type- an interface annotated withConfigMapping- Returns:
- an instance of a
ConfigMappingannotated type - Throws:
ConfigValidationException- if the mapping names or values cannot be converter to the specified types, if the properties values are not present, defined as an empty string, or the conversion returnsnull- See Also:
-
getConfigMapping
Returns an instance of aConfigMappingannotated type, mapping all the configuration names matching the prefix and theConfigMappingmembers to values from the underlying configuration sources.ConfigMapping instances are cached. They are populated when the
SmallRyeConfiginstance is initialized and their values are not updated on configuration sources changes.- Type Parameters:
T- the type of theConfigMapping- Parameters:
type- an interface annotated withConfigMappingprefix- the prefix to overrideConfigMapping.prefix()- Returns:
- an instance of a
ConfigMappingannotated type - Throws:
ConfigValidationException- if the mapping names or values cannot be converter to the specified types, if the properties values are not present, defined as an empty string, or the conversion returnsnull- See Also:
-
getPropertyNames
This implementation caches the list of property names collected whenSmallRyeConfigis built viaSmallRyeConfigBuilder.build(). The cache may be disabled withSmallRyeConfigBuilder.isCachePropertyNames().- Specified by:
getPropertyNamesin interfaceorg.eclipse.microprofile.config.Config- Returns:
- the cached names of all configured keys of the underlying configuration
- See Also:
-
getLatestPropertyNames
Provides a way to retrieve an updated list of all property names. The updated list replaces the cached list returned bySmallRyeConfig.getPropertyNames().- Returns:
- the names of all configured keys of the underlying configuration
-
isPropertyPresent
Checks if a property is present in theConfiginstance.
BecauseConfigSource.getPropertyNames()may not include all available properties, it is not possible to reliably determine if the property is present in the properties list. The property needs to be retrieved to make sure it exists. The lookup is done without expression expansion, because the expansion value may not be available, and it is not relevant for the final check.- Parameters:
name- the property name.- Returns:
- true if the property is present or false otherwise.
-
getConfigSources
Iterable<org.eclipse.microprofile.config.spi.ConfigSource> getConfigSources()- Specified by:
getConfigSourcesin interfaceorg.eclipse.microprofile.config.Config
-
getConfigSources
Return the currently registered configuration sources inSmallRyeConfigthat match the specified type.The returned sources will be sorted by descending ordinal value and name, which can be iterated in a thread-safe manner. The
Iterablecontains a fixed number of configuration sources, determined at configuration initialization, and the config sources themselves may be static or dynamic.- Parameters:
type- The type of theConfigSourceto look for in the configuration- Returns:
- an
Iterableof configuration sources
-
getConfigSource
Return the first registered configuration sources inSmallRyeConfigthat match the specified name, sorted by descending ordinal value and name. -
requireConverter
Return theConverterused by this instance to produce instances of the specified type fromStringvalues.- Type Parameters:
T- the conversion type- Parameters:
asType- the type to be produced by the converter- Returns:
- an instance of the
Converterthe specified type - Throws:
IllegalArgumentException- if noConverteris registered for the specified type
-
getProfiles
Returns aListof the active profiles inSmallRyeConfig.Profiles are sorted in reverse order according to how they were set in
SmallRyeConfig.SMALLRYE_CONFIG_PROFILE, as the last profile overrides the previous one until there are no profiles left in the list.- Returns:
- a
Listof the active profiles
-
get
Get aSmallRyeConfiginstance for the currentThread.getContextClassLoader().- Returns:
- the
SmallRyeConfiginstance for the thread context class loader - Throws:
IllegalArgumentException- if the config is not registered for the thread context class loaderIllegalArgumentException- if the registered config is not aSmallRyeConfig
-
getOrCreate
Get or Create aSmallRyeConfiginstance for the currentThread.getContextClassLoader().The
SmallRyeConfiginstance will be created and registered to the context classloader if no such configuration is already created and registered.- Returns:
- the
SmallRyeConfiginstance for the thread context class loader - Throws:
IllegalArgumentException- if the registered config is not aSmallRyeConfig
-
get
Get aSmallRyeConfiginstance for the specifiedClassLoader.- Returns:
- the
SmallRyeConfiginstance for the specified class loader - Throws:
IllegalArgumentException- if the config is not registered for the thread context class loaderIllegalArgumentException- if the registered config is not aSmallRyeConfig
-
getOrCreate
Get or Create aSmallRyeConfiginstance for the specifiedClassLoader.The
SmallRyeConfiginstance will be created and registered to the specified class loader if no such configuration is already created and registered.- Returns:
- the
SmallRyeConfiginstance for the specified class loader - Throws:
IllegalArgumentException- if the registered config is not aSmallRyeConfig
-