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 thePropertySourceLoaderinterface.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_POSITIONDefault position for the property source loader.
-
Constructor Summary
Constructors Constructor Description AbstractPropertySourceLoader()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected MapPropertySourcecreatePropertySource(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> map, int order)intgetOrder()java.util.Optional<PropertySource>load(java.lang.String resourceName, io.micronaut.core.io.ResourceLoader resourceLoader)Load aPropertySourcefor the givenEnvironment.java.util.Optional<PropertySource>loadEnv(java.lang.String resourceName, io.micronaut.core.io.ResourceLoader resourceLoader, ActiveEnvironment activeEnvironment)Load aPropertySourcefor the givenEnvironment.protected abstract voidprocessInput(java.lang.String name, java.io.InputStream input, java.util.Map<java.lang.String,java.lang.Object> finalMap)protected voidprocessMap(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)-
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
-
-
Method Detail
-
getOrder
public int getOrder()
- Specified by:
getOrderin 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:PropertySourceLoaderLoad aPropertySourcefor the givenEnvironment.- Specified by:
loadin interfacePropertySourceLoader- Parameters:
resourceName- The resourceName of the resource to loadresourceLoader- TheResourceLoaderto 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:PropertySourceLoaderLoad aPropertySourcefor the givenEnvironment.- Specified by:
loadEnvin interfacePropertySourceLoader- Parameters:
resourceName- The resourceName of the resource to loadresourceLoader- TheResourceLoaderto 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.IOExceptionDescription copied from interface:PropertySourceReaderRead a property source from an input stream.- Specified by:
readin 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
-
-