Package io.micronaut.context.env
Class AbstractPropertySourceLoader
- java.lang.Object
-
- io.micronaut.context.env.AbstractPropertySourceLoader
-
- All Implemented Interfaces:
PropertySourceLoader
,PropertySourceLocator
,PropertySourceReader
,io.micronaut.core.order.Ordered
,io.micronaut.core.util.Toggleable
- Direct Known Subclasses:
PropertiesPropertySourceLoader
,YamlPropertySourceLoader
public abstract class AbstractPropertySourceLoader extends java.lang.Object implements PropertySourceLoader, io.micronaut.core.util.Toggleable, io.micronaut.core.order.Ordered
An abstract implementation of thePropertySourceLoader
interface.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_POSITION
Default position for the property source loader.protected org.slf4j.Logger
log
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPropertySourceLoader()
protected
AbstractPropertySourceLoader(boolean logEnabled)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected MapPropertySource
createPropertySource(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> map, int order)
int
getOrder()
boolean
isLogEnabled()
Deprecated.don't need to have this methodjava.util.Optional<PropertySource>
load(java.lang.String resourceName, io.micronaut.core.io.ResourceLoader resourceLoader)
Load aPropertySource
for the givenEnvironment
.java.util.Optional<PropertySource>
loadEnv(java.lang.String resourceName, io.micronaut.core.io.ResourceLoader resourceLoader, ActiveEnvironment activeEnvironment)
Load aPropertySource
for the givenEnvironment
.protected abstract void
processInput(java.lang.String name, java.io.InputStream input, java.util.Map<java.lang.String,java.lang.Object> finalMap)
protected void
processMap(java.util.Map<java.lang.String,java.lang.Object> finalMap, java.util.Map map, java.lang.String prefix)
java.util.Map<java.lang.String,java.lang.Object>
read(java.lang.String name, java.io.InputStream input)
Read a property source from an input stream.protected java.util.Optional<java.io.InputStream>
readInput(io.micronaut.core.io.ResourceLoader resourceLoader, java.lang.String fileName)
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
-
Methods inherited from interface io.micronaut.context.env.PropertySourceLoader
load
-
Methods inherited from interface io.micronaut.context.env.PropertySourceReader
getExtensions, read
-
-
-
-
Field Detail
-
DEFAULT_POSITION
public static final int DEFAULT_POSITION
Default position for the property source loader.- See Also:
- Constant Field Values
-
log
protected org.slf4j.Logger log
-
-
Method Detail
-
getOrder
public int getOrder()
- Specified by:
getOrder
in interfaceio.micronaut.core.order.Ordered
-
load
public java.util.Optional<PropertySource> load(java.lang.String resourceName, io.micronaut.core.io.ResourceLoader resourceLoader)
Description copied from interface:PropertySourceLoader
Load aPropertySource
for the givenEnvironment
.- Specified by:
load
in interfacePropertySourceLoader
- Parameters:
resourceName
- The resourceName of the resource to loadresourceLoader
- TheResourceLoader
to retrieve the resource- Returns:
- An optional of
PropertySource
-
loadEnv
public java.util.Optional<PropertySource> loadEnv(java.lang.String resourceName, io.micronaut.core.io.ResourceLoader resourceLoader, ActiveEnvironment activeEnvironment)
Description copied from interface:PropertySourceLoader
Load aPropertySource
for the givenEnvironment
.- Specified by:
loadEnv
in interfacePropertySourceLoader
- Parameters:
resourceName
- The resourceName of the resource to loadresourceLoader
- TheResourceLoader
to retrieve the resourceactiveEnvironment
- The environment to load- Returns:
- An optional of
PropertySource
-
createPropertySource
protected MapPropertySource createPropertySource(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> map, int order)
- Parameters:
name
- The name of the property sourcemap
- The maporder
- The order of the property source- Returns:
- property source
-
read
public java.util.Map<java.lang.String,java.lang.Object> read(java.lang.String name, java.io.InputStream input) throws java.io.IOException
Description copied from interface:PropertySourceReader
Read a property source from an input stream.- Specified by:
read
in interfacePropertySourceReader
- Parameters:
name
- The name of the property sourceinput
- The bytes- Returns:
- A map of string to values
- Throws:
java.io.IOException
- if there is an error processing the property source
-
readInput
protected java.util.Optional<java.io.InputStream> readInput(io.micronaut.core.io.ResourceLoader resourceLoader, java.lang.String fileName)
- Parameters:
resourceLoader
- The resource loaderfileName
- The file name- Returns:
- An input stream wrapped inside an
Optional
-
processInput
protected abstract void processInput(java.lang.String name, java.io.InputStream input, java.util.Map<java.lang.String,java.lang.Object> finalMap) throws java.io.IOException
- Parameters:
name
- The nameinput
- The input streamfinalMap
- The map with all the properties processed- Throws:
java.io.IOException
- If the input stream doesn't exist
-
processMap
protected void processMap(java.util.Map<java.lang.String,java.lang.Object> finalMap, java.util.Map map, java.lang.String prefix)
- Parameters:
finalMap
- The map with all the properties processedmap
- The map to processprefix
- The prefix for the keys
-
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
-
-