Package io.helidon.config.spi
Class AbstractSource<T,S>
- java.lang.Object
-
- io.helidon.config.spi.AbstractSource<T,S>
-
- Type Parameters:
T- a type of source dataS- a type of data stamp
- All Implemented Interfaces:
Changeable<T>,Source<T>,AutoCloseable
- Direct Known Subclasses:
AbstractConfigSource,AbstractOverrideSource
public abstract class AbstractSource<T,S> extends Object implements Source<T>
Abstract base implementation for a variety of sources.The inner
AbstractSource.Builderclass is ready-to-extend with built-in support of changes (polling strategy, executor, buffer size) and mandatory/optional attribute.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractSource.Builder<B extends AbstractSource.Builder<B,T,S>,T,S>A commonAbstractSourcebuilder, suitable for concreteBuilderimplementations related toAbstractSourceextensions to extend.static classAbstractSource.Data<D,S>Data loaded at appropriate time.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Optional<S>dataStamp()Returns current stamp of data in config source.Stringdescription()Short, human-readable summary referring to the underlying source.protected voidfireChangeEvent()Fires a change event when source has changed.protected booleanisMandatory()Optional<T>load()Loads data from source whendataexpires.protected abstract AbstractSource.Data<T,S>loadData()Loads new data from config source.protected AbstractSource.Data<T,S>processLoadedData(AbstractSource.Data<T,S> data)Performs any postprocessing of config data after loading.protected Stringuid()Returns universal id of source to be used to constructdescription().
-
-
-
Method Detail
-
uid
protected String uid()
Returns universal id of source to be used to constructdescription().- Returns:
- universal id of source
-
isMandatory
protected boolean isMandatory()
-
fireChangeEvent
protected void fireChangeEvent()
Fires a change event when source has changed.
-
processLoadedData
protected AbstractSource.Data<T,S> processLoadedData(AbstractSource.Data<T,S> data)
Performs any postprocessing of config data after loading. By default, the method simply returns the provided inputData.- Parameters:
data- an input data- Returns:
- a post-processed data
-
dataStamp
protected abstract Optional<S> dataStamp()
Returns current stamp of data in config source.- Returns:
- current datastamp of data in config source
-
loadData
protected abstract AbstractSource.Data<T,S> loadData() throws ConfigException
Loads new data from config source.- Returns:
- newly loaded data with appropriate data timestamp used for future method calls
- Throws:
ConfigException- in case it is not possible to load configuration data
-
description
public final String description()
Description copied from interface:SourceShort, human-readable summary referring to the underlying source.For example, a file path or a URL or any other information that helps the user recognize the underlying origin of the data this
Sourceprovides.Default is the implementation class simple name with any
"Source"suffix removed.- Specified by:
descriptionin interfaceSource<T>- Returns:
- description of the source
-
-