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.AutoCloseable
A
PropertyResolver
that resolves from one or manyPropertySource
instances.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
PropertySourcePropertyResolver.PropertyCatalog
The property catalog to use.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>[]
catalog
protected io.micronaut.core.convert.ConversionService<?>
conversionService
protected org.slf4j.Logger
log
protected java.util.Map<java.lang.String,java.lang.Object>[]
nonGenerated
protected PropertyPlaceholderResolver
propertyPlaceholderResolver
protected java.util.Map<java.lang.String,PropertySource>
propertySources
protected 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 newPropertySourcePropertyResolver
for the givenPropertySource
instances.PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService<?> conversionService)
Creates a new, initially empty,PropertySourcePropertyResolver
for the givenConversionService
.PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService<?> conversionService, boolean logEnabled)
Creates a new, initially empty,PropertySourcePropertyResolver
for the givenConversionService
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PropertySourcePropertyResolver
addPropertySource(PropertySource propertySource)
Add aPropertySource
to this resolver.PropertySourcePropertyResolver
addPropertySource(java.lang.String name, java.util.Map<java.lang.String,? super java.lang.Object> values)
Add a property source for the given map.void
close()
boolean
containsProperties(java.lang.String name)
boolean
containsProperty(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)
boolean
isLogEnabled()
Deprecated.don't need to have this methodprotected void
processPropertySource(PropertySource properties, PropertySource.PropertyConvention convention)
protected void
resetCaches()
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.Properties
resolveSubProperties(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext)
void
setLogEnabled(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,PropertySourcePropertyResolver
for the givenConversionService
.- Parameters:
conversionService
- TheConversionService
logEnabled
- logEnabled flag to enable or disable logger
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService<?> conversionService)
Creates a new, initially empty,PropertySourcePropertyResolver
for the givenConversionService
.- Parameters:
conversionService
- TheConversionService
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver()
Creates a new, initially empty,PropertySourcePropertyResolver
.
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver(PropertySource... propertySources)
Creates a newPropertySourcePropertyResolver
for the givenPropertySource
instances.- Parameters:
propertySources
- ThePropertySource
instances
-
-
Method Detail
-
addPropertySource
public PropertySourcePropertyResolver addPropertySource(@Nullable PropertySource propertySource)
Add aPropertySource
to this resolver.- Parameters:
propertySource
- ThePropertySource
to 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:
containsProperty
in interfaceio.micronaut.core.value.PropertyResolver
-
containsProperties
public boolean containsProperties(@Nullable java.lang.String name)
- Specified by:
containsProperties
in interfaceio.micronaut.core.value.PropertyResolver
-
getPropertyEntries
@NonNull public java.util.Collection<java.lang.String> getPropertyEntries(@NonNull java.lang.String name)
- Specified by:
getPropertyEntries
in 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:
getProperties
in 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:
getProperty
in 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:
close
in 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
-
-