- java.lang.Object
-
- io.helidon.config.AbstractSource
-
- io.helidon.config.AbstractConfigSource
-
- io.helidon.config.DirectoryConfigSource
-
- All Implemented Interfaces:
ConfigSource,NodeConfigSource,PollableSource<Instant>,Source,WatchableSource<Path>,Supplier<ConfigSource>
public class DirectoryConfigSource extends AbstractConfigSource implements PollableSource<Instant>, WatchableSource<Path>, NodeConfigSource
ConfigSourceimplementation that loads configuration content from a directory on a filesystem.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDirectoryConfigSource.BuilderCommon ancestor for config source builders, taking care of configurable options understood by the config module.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DirectoryConfigSource.Builderbuilder()Create a fluent API builder to construct a directory config source.Optional<ChangeWatcher<Object>>changeWatcher()A change watcher of this source, if it implementsWatchableSourceand has one configured.static DirectoryConfigSourcecreate(Config metaConfig)Initializes config source instance from configuration properties.booleanexists()If the underlying data exist at this time.booleanisModified(Instant stamp)This method is invoked to check if this source has changed.Optional<ConfigContent.NodeContent>load()Loads the underlying source data.Optional<PollingStrategy>pollingStrategy()A polling strategy of this source, if it implementsPollableSourceand has one configured.Pathtarget()The target of this source.Class<Path>targetType()Target type as supported by this source.protected Stringuid()Returns universal id of source to be used to constructAbstractSource.description().-
Methods inherited from class io.helidon.config.AbstractConfigSource
mediaType, parser, toString
-
Methods inherited from class io.helidon.config.AbstractSource
description, optional, retryPolicy
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.helidon.config.spi.ConfigSource
get, init
-
Methods inherited from interface io.helidon.config.spi.Source
description, optional, retryPolicy
-
-
-
-
Method Detail
-
create
public static DirectoryConfigSource create(Config metaConfig) throws ConfigMappingException, MissingValueException
Initializes config source instance from configuration properties.Mandatory
properties, seeConfigSources.directory(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:
ConfigSources.directory(String),AbstractConfigSourceBuilder.config(Config)
-
builder
public static DirectoryConfigSource.Builder builder()
Create a fluent API builder to construct a directory config source.- Returns:
- a new builder instance
-
uid
protected String 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(Instant stamp)
Description copied from interface:PollableSourceThis method is invoked to check if this source has changed.- Specified by:
isModifiedin interfacePollableSource<Instant>- 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
-
pollingStrategy
public Optional<PollingStrategy> pollingStrategy()
Description copied from class:AbstractSourceA polling strategy of this source, if it implementsPollableSourceand has one configured.- Specified by:
pollingStrategyin interfacePollableSource<Instant>- Overrides:
pollingStrategyin classAbstractSource- Returns:
- polling strategy if any configured
-
changeWatcher
public Optional<ChangeWatcher<Object>> 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
-
target
public Path target()
Description copied from interface:WatchableSourceThe target of this source.- Specified by:
targetin interfaceWatchableSource<Path>- Returns:
- target this source is configured with, never
null
-
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.
-
targetType
public Class<Path> targetType()
Description copied from interface:WatchableSourceTarget type as supported by this source.- Specified by:
targetTypein interfaceWatchableSource<Path>- Returns:
- class of the target, by default used for
WatchableSource.target()
-
load
public Optional<ConfigContent.NodeContent> load() throws ConfigException
Description copied from interface:NodeConfigSourceLoads the underlying source data. This method is only called when the sourceSource.exists().The method can be invoked repeatedly, for example during retries.
- Specified by:
loadin interfaceNodeConfigSource- 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
-
-