Package io.smallrye.config
Class AbstractLocationConfigSourceLoader
java.lang.Object
io.smallrye.config.AbstractLocationConfigSourceLoader
- Direct Known Subclasses:
AbstractLocationConfigSourceFactory,DotEnvConfigSourceProvider,PropertiesConfigSourceLoader
This
AbstractLocationConfigSourceLoader loads ConfigSources from a list of specific
locations.
The locations comprise a list of valid URIs which are loaded in order. The following URI schemes are
supported:
- file or directory
- classpath resource
- jar resource
- http resource
If a profile is active, the profile resource is only loaded if the unprofiled resource is available in the exact
location. This is to keep a consistent loading order and match the unprofiled resource when looking for resources
in the classpath. The order is usually not guaranteed when querying a ClassLoader for multiple resources.
The implementation queries the ClassLoader for the profiled resources by requiring the unprofiled resource
first. It pairs them with unprofiled resources to ensure a consistent order and override behavior.
Profiles are not taken into account if the location is a directory.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected final classprotected final classprotected final class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanIf the lookup from anURLwhich the schemefile:should fail.protected List<org.eclipse.microprofile.config.spi.ConfigSource> fallbackToUnknownProtocol(URI uri, int ordinal, ClassLoader classLoader) protected abstract String[]The file extensions to filter the locations to load.protected abstract org.eclipse.microprofile.config.spi.ConfigSourceloadConfigSource(URL url, int ordinal) Loads aConfigSourcefrom anURL.protected List<org.eclipse.microprofile.config.spi.ConfigSource> loadConfigSources(String[] locations, int ordinal) protected List<org.eclipse.microprofile.config.spi.ConfigSource> loadConfigSources(String[] locations, int ordinal, ClassLoader classLoader) protected List<org.eclipse.microprofile.config.spi.ConfigSource> loadConfigSources(String location, int ordinal) protected List<org.eclipse.microprofile.config.spi.ConfigSource> loadConfigSources(String location, int ordinal, ClassLoader classLoader) protected List<org.eclipse.microprofile.config.spi.ConfigSource> tryClassPath(URI uri, int ordinal, ClassLoader classLoader) protected List<org.eclipse.microprofile.config.spi.ConfigSource> tryFileSystem(URI uri, int ordinal) protected List<org.eclipse.microprofile.config.spi.ConfigSource> tryHttpResource(URI uri, int ordinal) protected List<org.eclipse.microprofile.config.spi.ConfigSource>
-
Constructor Details
-
AbstractLocationConfigSourceLoader
public AbstractLocationConfigSourceLoader()
-
-
Method Details
-
failOnMissingFile
protected boolean failOnMissingFile()If the lookup from anURLwhich the schemefile:should fail. By default, a failed load does not throw an exception. In situations where the resource is required, a return value oftrueenables the exception.- Returns:
trueif file lookup should fail with an exception,falseotherwise.
-
getFileExtensions
The file extensions to filter the locations to load. It does not require to include the dot separator.- Returns:
- an array with the file extensions.
-
loadConfigSource
protected abstract org.eclipse.microprofile.config.spi.ConfigSource loadConfigSource(URL url, int ordinal) throws IOException - Parameters:
url- theURLto load theConfigSource.ordinal- the ordinal of theConfigSource.- Returns:
- the loaded
ConfigSource. - Throws:
IOException- if an error occurred when reading from theURL.
-
loadConfigSources
-
loadConfigSources
protected List<org.eclipse.microprofile.config.spi.ConfigSource> loadConfigSources(String location, int ordinal, ClassLoader classLoader) -
loadConfigSources
-
loadConfigSources
protected List<org.eclipse.microprofile.config.spi.ConfigSource> loadConfigSources(String[] locations, int ordinal, ClassLoader classLoader) -
tryFileSystem
-
tryClassPath
protected List<org.eclipse.microprofile.config.spi.ConfigSource> tryClassPath(URI uri, int ordinal, ClassLoader classLoader) -
tryJar
-
fallbackToUnknownProtocol
protected List<org.eclipse.microprofile.config.spi.ConfigSource> fallbackToUnknownProtocol(URI uri, int ordinal, ClassLoader classLoader) -
tryHttpResource
-