java.lang.Object
io.helidon.config.AbstractSource
io.helidon.config.AbstractConfigSource
io.helidon.config.FileConfigSource
- All Implemented Interfaces:
ConfigSource,ParsableSource,PollableSource<byte[]>,Source,WatchableSource<Path>,Supplier<ConfigSource>
public class FileConfigSource
extends AbstractConfigSource
implements WatchableSource<Path>, ParsableSource, PollableSource<byte[]>
ConfigSource implementation that loads configuration content from a file on a filesystem.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFile ConfigSource Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic FileConfigSource.Builderbuilder()Get a builder instance to create a new config source.A change watcher of this source, if it implementsWatchableSourceand has one configured.static FileConfigSourceInitializes config source instance from configuration properties.booleanexists()If the underlying data exist at this time.booleanisModified(byte[] stamp) This method is invoked to check if this source has changed.load()Loads the underlying source data.Media type if on eis configured for parsing content ofParsableSource.parser()Config parser if one is configured to use for parsing content ofParsableSource.A polling strategy of this source, if it implementsPollableSourceand has one configured.Resolve relative resource to the current resource.target()The target of this source.protected Stringuid()Returns universal id of source to be used to constructAbstractSource.description().Methods inherited from class io.helidon.config.AbstractConfigSource
toStringMethods inherited from class io.helidon.config.AbstractSource
description, optional, retryPolicyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.helidon.config.spi.ConfigSource
get, initMethods inherited from interface io.helidon.config.spi.Source
description, optional, retryPolicyMethods inherited from interface io.helidon.config.spi.WatchableSource
targetType
-
Method Details
-
create
public static FileConfigSource create(Config metaConfig) throws ConfigMappingException, MissingValueException Initializes config source instance from configuration properties.Mandatory
properties, seeConfigSources.file(String):path- typePath
properties: seeAbstractConfigSourceBuilder.config(Config).- Parameters:
metaConfig- meta-configuration used to initialize returned config source instance from.- Returns:
- new instance of config source described by
metaConfig - Throws:
MissingValueException- in case the configuration tree does not contain all expected sub-nodes required by the mapper implementation to provide instance of Java type.ConfigMappingException- in case the mapper fails to map the (existing) configuration tree represented by the supplied configuration node to an instance of a given Java type.- See Also:
-
builder
Get a builder instance to create a new config source.- Returns:
- a fluent API builder
-
uid
Description copied from class:AbstractSourceReturns universal id of source to be used to constructAbstractSource.description().- Overrides:
uidin classAbstractSource- Returns:
- universal id of source
-
isModified
public boolean isModified(byte[] stamp) Description copied from interface:PollableSourceThis method is invoked to check if this source has changed.- Specified by:
isModifiedin interfacePollableSource<byte[]>- Parameters:
stamp- the stamp of the last loaded content- Returns:
trueif the current data of this config source differ from the loaded data, including cases when the source has disappeared
-
target
Description copied from interface:WatchableSourceThe target of this source.- Specified by:
targetin interfaceWatchableSource<Path>- Returns:
- target this source is configured with, never
null
-
load
Description copied from interface:ParsableSourceLoads the underlying source data. This method is only called when the sourceSource.exists().The method can be invoked repeatedly, for example during retries. In case the underlying data is gone or does not exist, return an empty optional.
- Specified by:
loadin interfaceParsableSource- Returns:
- An instance of
Tas read from the underlying origin of the data (if it exists) - Throws:
ConfigException- in case of errors loading from the underlying origin
-
relativeResolver
Description copied from interface:ParsableSourceResolve relative resource to the current resource.- Specified by:
relativeResolverin interfaceParsableSource- Returns:
- a function to resolve resource name into an input stream
-
parser
Description copied from class:AbstractConfigSourceConfig parser if one is configured to use for parsing content ofParsableSource. If one is not configured on a source (default), a parser is chosen based onAbstractConfigSource.mediaType().- Specified by:
parserin interfaceParsableSource- Overrides:
parserin classAbstractConfigSource- Returns:
- a configured parser, or empty if one should be chosen from media type (or if this is not a parsable source)
-
mediaType
Description copied from class:AbstractConfigSourceMedia type if on eis configured for parsing content ofParsableSource. If there is none configured (default), a parser is chosen based onConfigParser.Content.mediaType()- media type detected during load of data.- Specified by:
mediaTypein interfaceParsableSource- Overrides:
mediaTypein classAbstractConfigSource- Returns:
- configured media type or empty if none configured
-
pollingStrategy
Description copied from class:AbstractSourceA polling strategy of this source, if it implementsPollableSourceand has one configured.- Specified by:
pollingStrategyin interfacePollableSource<byte[]>- Overrides:
pollingStrategyin classAbstractSource- Returns:
- polling strategy if any configured
-
changeWatcher
Description copied from class:AbstractSourceA change watcher of this source, if it implementsWatchableSourceand has one configured.- Specified by:
changeWatcherin interfaceWatchableSource<Path>- Overrides:
changeWatcherin classAbstractSource- Returns:
- change watcher if any configured
-
exists
public boolean exists()Description copied from interface:SourceIf the underlying data exist at this time. This is to prevent us loading such a source if we know it does not exist.
-