Package io.micronaut.context.env
Class PropertySourcePropertyResolver
java.lang.Object
io.micronaut.context.env.PropertySourcePropertyResolver
- All Implemented Interfaces:
io.micronaut.core.value.PropertyResolver,io.micronaut.core.value.ValueResolver<String>,AutoCloseable
- Direct Known Subclasses:
DefaultEnvironment
public class PropertySourcePropertyResolver
extends Object
implements io.micronaut.core.value.PropertyResolver, AutoCloseable
A PropertyResolver that resolves from one or many PropertySource instances.
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumThe property catalog to use. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final io.micronaut.core.convert.ConversionServiceprotected org.slf4j.Loggerprotected final PropertyPlaceholderResolverprotected final Map<String,PropertySource> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new, initially empty,PropertySourcePropertyResolver.PropertySourcePropertyResolver(PropertySource... propertySources) Creates a newPropertySourcePropertyResolverfor the givenPropertySourceinstances.PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService) Creates a new, initially empty,PropertySourcePropertyResolverfor the givenConversionService.PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService, boolean logEnabled) Creates a new, initially empty,PropertySourcePropertyResolverfor the givenConversionService. -
Method Summary
Modifier and TypeMethodDescriptionaddPropertySource(@Nullable PropertySource propertySource) Add aPropertySourceto this resolver.addPropertySource(String name, @Nullable Map<String, ? super Object> values) Add a property source for the given map.voidclose()booleancontainsProperties(@Nullable String name) booleancontainsProperty(@Nullable String name) getAllProperties(io.micronaut.core.naming.conventions.StringConvention keyConvention, io.micronaut.core.convert.format.MapFormat.MapTransformation transformation) Returns a combined Map of all properties in the catalog.getProperties(String name, io.micronaut.core.naming.conventions.StringConvention keyFormat) <T> Optional<T>getProperty(@NonNull String name, @NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext) @NonNull Collection<String>getPropertyEntries(@NonNull String name) getPropertyPathMatches(String pathPattern) protected voidprocessPropertySource(PropertySource properties, PropertySource.PropertyConvention convention) protected voidSubclasses can override to reset caches.resolveEntriesForKey(String name, boolean allowCreate, @Nullable PropertySourcePropertyResolver.PropertyCatalog propertyCatalog) resolveSubMap(String name, Map<String, Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext) resolveSubMap(String name, Map<String, Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext, @Nullable io.micronaut.core.naming.conventions.StringConvention keyConvention, io.micronaut.core.convert.format.MapFormat.MapTransformation transformation) Resolves a submap for the given name and parameters.protected PropertiesresolveSubProperties(String name, Map<String, Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.core.value.PropertyResolver
get, getProperties, getProperty, getProperty, getProperty, getProperty, getRequiredPropertyMethods inherited from interface io.micronaut.core.value.ValueResolver
get, get, get
-
Field Details
-
conversionService
protected final io.micronaut.core.convert.ConversionService conversionService -
propertyPlaceholderResolver
-
propertySources
-
catalog
-
rawCatalog
-
nonGenerated
-
log
protected org.slf4j.Logger log
-
-
Constructor Details
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService, boolean logEnabled) Creates a new, initially empty,PropertySourcePropertyResolverfor the givenConversionService.- Parameters:
conversionService- TheConversionServicelogEnabled- flag to enable or disable logger
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService) Creates a new, initially empty,PropertySourcePropertyResolverfor the givenConversionService.- Parameters:
conversionService- TheConversionService
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver()Creates a new, initially empty,PropertySourcePropertyResolver. -
PropertySourcePropertyResolver
Creates a newPropertySourcePropertyResolverfor the givenPropertySourceinstances.- Parameters:
propertySources- ThePropertySourceinstances
-
-
Method Details
-
addPropertySource
public PropertySourcePropertyResolver addPropertySource(@Nullable @Nullable PropertySource propertySource) Add aPropertySourceto this resolver.- Parameters:
propertySource- ThePropertySourceto add- Returns:
- This
PropertySourcePropertyResolver
-
addPropertySource
public PropertySourcePropertyResolver addPropertySource(String name, @Nullable @Nullable Map<String, ? super Object> values) Add a property source for the given map.- Parameters:
name- The name of the property sourcevalues- The values- Returns:
- This environment
-
containsProperty
- Specified by:
containsPropertyin interfaceio.micronaut.core.value.PropertyResolver
-
containsProperties
- Specified by:
containsPropertiesin interfaceio.micronaut.core.value.PropertyResolver
-
getPropertyEntries
- Specified by:
getPropertyEntriesin interfaceio.micronaut.core.value.PropertyResolver
-
getPropertyPathMatches
- Specified by:
getPropertyPathMatchesin interfaceio.micronaut.core.value.PropertyResolver
-
getProperties
@NonNull public @NonNull Map<String,Object> getProperties(String name, io.micronaut.core.naming.conventions.StringConvention keyFormat) - Specified by:
getPropertiesin interfaceio.micronaut.core.value.PropertyResolver
-
getProperty
public <T> Optional<T> getProperty(@NonNull @NonNull String name, @NonNull @NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext) - Specified by:
getPropertyin interfaceio.micronaut.core.value.PropertyResolver
-
getAllProperties
public Map<String,Object> getAllProperties(io.micronaut.core.naming.conventions.StringConvention keyConvention, io.micronaut.core.convert.format.MapFormat.MapTransformation transformation) Returns a combined Map of all properties in the catalog.- Parameters:
keyConvention- The map key conventiontransformation- The map format- Returns:
- Map of all properties
-
resolveSubProperties
protected Properties resolveSubProperties(String name, Map<String, Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext) - Parameters:
name- The property nameentries- The entriesconversionContext- The conversion context- Returns:
- The subproperties
-
resolveSubMap
protected Map<String,Object> resolveSubMap(String name, Map<String, Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext) - Parameters:
name- The property nameentries- The entriesconversionContext- The conversion context- Returns:
- The submap
-
resolveSubMap
@NonNull protected @NonNull Map<String,Object> resolveSubMap(String name, Map<String, Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext, @Nullable @Nullable io.micronaut.core.naming.conventions.StringConvention keyConvention, io.micronaut.core.convert.format.MapFormat.MapTransformation transformation) Resolves a submap for the given name and parameters.- Parameters:
name- The nameentries- The entriesconversionContext- The conversion contextkeyConvention- The key convention to usetransformation- The map transformation to apply- Returns:
- The resulting map
-
processPropertySource
protected void processPropertySource(PropertySource properties, PropertySource.PropertyConvention convention) - Parameters:
properties- The property sourceconvention- The property convention
-
resolveEntriesForKey
protected Map<String,Object> resolveEntriesForKey(String name, boolean allowCreate, @Nullable @Nullable PropertySourcePropertyResolver.PropertyCatalog propertyCatalog) - Parameters:
name- The nameallowCreate- Whether allows creationpropertyCatalog- The string convention- Returns:
- The map with the resolved entries for the name
-
resetCaches
protected void resetCaches()Subclasses can override to reset caches. -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-