Package io.micronaut.context.env
Class AbstractPropertySourceLoader
java.lang.Object
io.micronaut.context.env.AbstractPropertySourceLoader
- All Implemented Interfaces:
PropertySourceLoader
,PropertySourceLocator
,PropertySourceReader
,Ordered
,Toggleable
- Direct Known Subclasses:
JsonPropertySourceLoader
,JsonPropertySourceLoader
,PropertiesPropertySourceLoader
,YamlPropertySourceLoader
public abstract class AbstractPropertySourceLoader
extends Object
implements PropertySourceLoader, Toggleable, Ordered
An abstract implementation of the
PropertySourceLoader
interface.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default position for the property source loader.Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected MapPropertySource
createPropertySource
(String name, Map<String, Object> map, int order) int
getOrder()
load
(String resourceName, ResourceLoader resourceLoader) Load aPropertySource
for the givenEnvironment
.loadEnv
(String resourceName, ResourceLoader resourceLoader, ActiveEnvironment activeEnvironment) Load aPropertySource
for the givenEnvironment
.protected abstract void
processInput
(String name, InputStream input, Map<String, Object> finalMap) protected void
read
(String name, InputStream input) Read a property source from an input stream.protected Optional<InputStream>
readInput
(ResourceLoader resourceLoader, String fileName) 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
Methods inherited from interface io.micronaut.core.util.Toggleable
isEnabled
-
Field Details
-
DEFAULT_POSITION
public static final int DEFAULT_POSITIONDefault position for the property source loader.- See Also:
-
-
Constructor Details
-
AbstractPropertySourceLoader
public AbstractPropertySourceLoader()
-
-
Method Details
-
getOrder
public int getOrder() -
load
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 Optional<PropertySource> loadEnv(String resourceName, 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
- Parameters:
name
- The name of the property sourcemap
- The maporder
- The order of the property source- Returns:
- property source
-
read
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:
IOException
- if there is an error processing the property source
-
readInput
- Parameters:
resourceLoader
- The resource loaderfileName
- The file name- Returns:
- An input stream wrapped inside an
Optional
-
processInput
protected abstract void processInput(String name, InputStream input, Map<String, Object> finalMap) throws IOException- Parameters:
name
- The nameinput
- The input streamfinalMap
- The map with all the properties processed- Throws:
IOException
- If the input stream doesn't exist
-
processMap
- Parameters:
finalMap
- The map with all the properties processedmap
- The map to processprefix
- The prefix for the keys
-