- java.lang.Object
-
- io.helidon.config.AbstractSource
-
- io.helidon.config.FileOverrideSource
-
- All Implemented Interfaces:
OverrideSource
,PollableSource<byte[]>
,Source
,WatchableSource<Path>
,Supplier<OverrideSource>
public final class FileOverrideSource extends AbstractSource implements OverrideSource, PollableSource<byte[]>, WatchableSource<Path>
OverrideSource
implementation that loads override definitions from a file on a filesystem.- See Also:
FileOverrideSource.Builder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileOverrideSource.Builder
File OverrideSource Builder.-
Nested classes/interfaces inherited from interface io.helidon.config.spi.OverrideSource
OverrideSource.OverrideData
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FileOverrideSource.Builder
builder()
Create a new builder.Optional<ChangeWatcher<Object>>
changeWatcher()
A change watcher of this source, if it implementsWatchableSource
and has one configured.static FileOverrideSource
create(Config metaConfig)
Create a new file override source from meta configuration.boolean
exists()
If the underlying data exist at this time.boolean
isModified(byte[] stamp)
This method is invoked to check if this source has changed.Optional<ConfigContent.OverrideContent>
load()
Load override data from the underlying source.Optional<PollingStrategy>
pollingStrategy()
A polling strategy of this source, if it implementsPollableSource
and has one configured.Path
target()
The target of this source.Class<Path>
targetType()
Target type as supported by this source.protected String
uid()
Returns universal id of source to be used to constructAbstractSource.description()
.-
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, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.config.spi.OverrideSource
get
-
Methods inherited from interface io.helidon.config.spi.Source
description, optional, retryPolicy
-
-
-
-
Method Detail
-
uid
protected String uid()
Description copied from class:AbstractSource
Returns universal id of source to be used to constructAbstractSource.description()
.- Overrides:
uid
in classAbstractSource
- Returns:
- universal id of source
-
exists
public boolean exists()
Description copied from interface:Source
If the underlying data exist at this time. This is to prevent us loading such a source if we know it does not exist.
-
load
public Optional<ConfigContent.OverrideContent> load() throws ConfigException
Description copied from interface:OverrideSource
Load override data from the underlying source.- Specified by:
load
in interfaceOverrideSource
- Returns:
- override data if present, empty otherwise
- Throws:
ConfigException
- in case the loading of data failed
-
isModified
public boolean isModified(byte[] stamp)
Description copied from interface:PollableSource
This method is invoked to check if this source has changed.- Specified by:
isModified
in interfacePollableSource<byte[]>
- Parameters:
stamp
- the stamp of the last loaded content- Returns:
true
if 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:AbstractSource
A polling strategy of this source, if it implementsPollableSource
and has one configured.- Specified by:
pollingStrategy
in interfacePollableSource<byte[]>
- Overrides:
pollingStrategy
in classAbstractSource
- Returns:
- polling strategy if any configured
-
target
public Path target()
Description copied from interface:WatchableSource
The target of this source.- Specified by:
target
in interfaceWatchableSource<Path>
- Returns:
- target this source is configured with, never
null
-
changeWatcher
public Optional<ChangeWatcher<Object>> changeWatcher()
Description copied from class:AbstractSource
A change watcher of this source, if it implementsWatchableSource
and has one configured.- Specified by:
changeWatcher
in interfaceWatchableSource<Path>
- Overrides:
changeWatcher
in classAbstractSource
- Returns:
- change watcher if any configured
-
targetType
public Class<Path> targetType()
Description copied from interface:WatchableSource
Target type as supported by this source.- Specified by:
targetType
in interfaceWatchableSource<Path>
- Returns:
- class of the target, by default used for
WatchableSource.target()
-
create
public static FileOverrideSource create(Config metaConfig)
Create a new file override source from meta configuration.- Parameters:
metaConfig
- meta configuration containing thepath
and other configuration options- Returns:
- a new file override source
-
builder
public static FileOverrideSource.Builder builder()
Create a new builder.- Returns:
- builder to create new instances of file override source
-
-