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<java.lang.String>,java.lang.AutoCloseable
- Direct Known Subclasses:
DefaultEnvironment
public class PropertySourcePropertyResolver extends java.lang.Object implements io.micronaut.core.value.PropertyResolver, java.lang.AutoCloseableA
PropertyResolverthat resolves from one or manyPropertySourceinstances.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPropertySourcePropertyResolver.PropertyCatalogThe property catalog to use.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>[]catalogprotected io.micronaut.core.convert.ConversionService<?>conversionServiceprotected org.slf4j.Loggerlogprotected java.util.Map<java.lang.String,java.lang.Object>[]nonGeneratedprotected PropertyPlaceholderResolverpropertyPlaceholderResolverprotected java.util.Map<java.lang.String,PropertySource>propertySourcesprotected java.util.Map<java.lang.String,java.lang.Object>[]rawCatalog
-
Constructor Summary
Constructors Constructor Description PropertySourcePropertyResolver()Creates 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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PropertySourcePropertyResolveraddPropertySource(PropertySource propertySource)Add aPropertySourceto this resolver.PropertySourcePropertyResolveraddPropertySource(java.lang.String name, java.util.Map<java.lang.String,? super java.lang.Object> values)Add a property source for the given map.voidclose()booleancontainsProperties(java.lang.String name)booleancontainsProperty(java.lang.String name)java.util.Map<java.lang.String,java.lang.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.java.util.Map<java.lang.String,java.lang.Object>getProperties(java.lang.String name, io.micronaut.core.naming.conventions.StringConvention keyFormat)<T> java.util.Optional<T>getProperty(java.lang.String name, io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext)java.util.Collection<java.lang.String>getPropertyEntries(java.lang.String name)booleanisLogEnabled()Deprecated.don't need to have this methodprotected voidprocessPropertySource(PropertySource properties, PropertySource.PropertyConvention convention)protected voidresetCaches()Subclasses can override to reset caches.protected java.util.Map<java.lang.String,java.lang.Object>resolveEntriesForKey(java.lang.String name, boolean allowCreate)protected java.util.Map<java.lang.String,java.lang.Object>resolveEntriesForKey(java.lang.String name, boolean allowCreate, PropertySourcePropertyResolver.PropertyCatalog propertyCatalog)protected java.util.Map<java.lang.String,java.lang.Object>resolveSubMap(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext)protected java.util.Map<java.lang.String,java.lang.Object>resolveSubMap(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext, 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 java.util.PropertiesresolveSubProperties(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext)voidsetLogEnabled(boolean logEnabled)Deprecated.set logEnabled value by constructor-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
conversionService
protected final io.micronaut.core.convert.ConversionService<?> conversionService
-
propertyPlaceholderResolver
protected final PropertyPlaceholderResolver propertyPlaceholderResolver
-
propertySources
protected final java.util.Map<java.lang.String,PropertySource> propertySources
-
catalog
protected final java.util.Map<java.lang.String,java.lang.Object>[] catalog
-
rawCatalog
protected final java.util.Map<java.lang.String,java.lang.Object>[] rawCatalog
-
nonGenerated
protected final java.util.Map<java.lang.String,java.lang.Object>[] nonGenerated
-
log
protected org.slf4j.Logger log
-
-
Constructor Detail
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService<?> conversionService, boolean logEnabled)Creates a new, initially empty,PropertySourcePropertyResolverfor the givenConversionService.- Parameters:
conversionService- TheConversionServicelogEnabled- logEnabled 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
public PropertySourcePropertyResolver(PropertySource... propertySources)
Creates a newPropertySourcePropertyResolverfor the givenPropertySourceinstances.- Parameters:
propertySources- ThePropertySourceinstances
-
-
Method Detail
-
addPropertySource
public PropertySourcePropertyResolver addPropertySource(@Nullable PropertySource propertySource)
Add aPropertySourceto this resolver.- Parameters:
propertySource- ThePropertySourceto add- Returns:
- This
PropertySourcePropertyResolver
-
addPropertySource
public PropertySourcePropertyResolver addPropertySource(java.lang.String name, @Nullable java.util.Map<java.lang.String,? super java.lang.Object> values)
Add a property source for the given map.- Parameters:
name- The name of the property sourcevalues- The values- Returns:
- This environment
-
containsProperty
public boolean containsProperty(@Nullable java.lang.String name)- Specified by:
containsPropertyin interfaceio.micronaut.core.value.PropertyResolver
-
containsProperties
public boolean containsProperties(@Nullable java.lang.String name)- Specified by:
containsPropertiesin interfaceio.micronaut.core.value.PropertyResolver
-
getPropertyEntries
@NonNull public java.util.Collection<java.lang.String> getPropertyEntries(@NonNull java.lang.String name)- Specified by:
getPropertyEntriesin interfaceio.micronaut.core.value.PropertyResolver
-
getProperties
@NonNull public java.util.Map<java.lang.String,java.lang.Object> getProperties(java.lang.String name, io.micronaut.core.naming.conventions.StringConvention keyFormat)- Specified by:
getPropertiesin interfaceio.micronaut.core.value.PropertyResolver
-
getProperty
public <T> java.util.Optional<T> getProperty(@NonNull java.lang.String name, @NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext)- Specified by:
getPropertyin interfaceio.micronaut.core.value.PropertyResolver
-
getAllProperties
public java.util.Map<java.lang.String,java.lang.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 java.util.Properties resolveSubProperties(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext)- Parameters:
name- The property nameentries- The entriesconversionContext- The conversion context- Returns:
- The subproperties
-
resolveSubMap
protected java.util.Map<java.lang.String,java.lang.Object> resolveSubMap(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext)- Parameters:
name- The property nameentries- The entriesconversionContext- The conversion context- Returns:
- The submap
-
resolveSubMap
@NonNull protected java.util.Map<java.lang.String,java.lang.Object> resolveSubMap(java.lang.String name, java.util.Map<java.lang.String,java.lang.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.- 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 java.util.Map<java.lang.String,java.lang.Object> resolveEntriesForKey(java.lang.String name, boolean allowCreate)- Parameters:
name- The nameallowCreate- Whether allows creation- Returns:
- The map with the resolved entries for the name
-
resolveEntriesForKey
protected java.util.Map<java.lang.String,java.lang.Object> resolveEntriesForKey(java.lang.String name, boolean allowCreate, @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
public void close() throws java.lang.Exception- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-
isLogEnabled
@Deprecated public boolean isLogEnabled()
Deprecated.don't need to have this methodReturn logEnabled value.- Returns:
- is log enabled
- Since:
- 3.9.0
-
setLogEnabled
@Deprecated public void setLogEnabled(boolean logEnabled)
Deprecated.set logEnabled value by constructorSetter for logEnabled.- Parameters:
logEnabled- is log enabled- Since:
- 3.9.0
-
-