Package io.helidon.config.spi
Class AbstractSource.Builder<B extends AbstractSource.Builder<B,T,S>,T,S>
- java.lang.Object
-
- io.helidon.config.spi.AbstractSource.Builder<B,T,S>
-
- Type Parameters:
B- type of Builder implementationT- type of key source attributes (target) used to construct polling strategy fromS- type of source that should be built
- Direct Known Subclasses:
AbstractConfigSource.Builder,AbstractOverrideSource.Builder
- Enclosing class:
- AbstractSource<T,S>
public abstract static class AbstractSource.Builder<B extends AbstractSource.Builder<B,T,S>,T,S> extends Object
A commonAbstractSourcebuilder, suitable for concreteBuilderimplementations related toAbstractSourceextensions to extend.The application can control this behavior:
mandatory- whether the resource is mandatory (by default) or optionalpollingStrategy- which source reload policy to use- changes
executorand subscriber'sbuffer size- related to propagating source changes
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Sbuild()Builds new instance ofS.protected ExecutorchangesExecutor()Returns changes-executor property.BchangesExecutor(Executor changesExecutor)Specifies "observe-on"Executorto be used to deliverconfig source changes.protected intchangesMaxBuffer()Returns changes-max-buffer property.BchangesMaxBuffer(int changesMaxBuffer)Specifies maximum capacity for each subscriber's buffer to be used to deliverconfig source changes.protected Binit(Config metaConfig)Initialize builder from specified configuration properties.protected booleanisMandatory()Returns mandatory property.Boptional()BuiltConfigSourcewill not be mandatory, i.e.protected PollingStrategypollingStrategy()Returns polling-strategy property.BpollingStrategy(Function<T,Supplier<PollingStrategy>> pollingStrategyProvider)Sets the polling strategy that accepts key source attributes.BpollingStrategy(Supplier<PollingStrategy> pollingStrategySupplier)Sets a polling strategy.protected RetryPolicyretryPolicy()Retry policy configured in this builder.BretryPolicy(Supplier<RetryPolicy> retryPolicySupplier)Sets a supplier ofRetryPolicythat will be responsible for invocation ofAbstractSource.load().protected Ttarget()Returns key source attributes (target).protected BthisBuilder()Returns current builder instance.
-
-
-
Method Detail
-
thisBuilder
protected B thisBuilder()
Returns current builder instance.- Returns:
- builder instance
-
init
protected B init(Config metaConfig)
Initialize builder from specified configuration properties.Supported configuration
properties:optional- typeboolean, seeoptional()polling-strategy- seePollingStrategyfor details about configuration format, seepollingStrategy(Supplier)orpollingStrategy(Function)
- Parameters:
metaConfig- configuration properties used to initialize a builder instance.- Returns:
- modified builder instance
-
pollingStrategy
public B pollingStrategy(Supplier<PollingStrategy> pollingStrategySupplier)
Sets a polling strategy.- Parameters:
pollingStrategySupplier- a polling strategy- Returns:
- a modified builder instance
- See Also:
PollingStrategies.regular(java.time.Duration)
-
pollingStrategy
public final B pollingStrategy(Function<T,Supplier<PollingStrategy>> pollingStrategyProvider)
Sets the polling strategy that accepts key source attributes.Concrete subclasses should override
target()to provide the key source attributes (target). For example, theBuilderfor aFileConfigSourceorClasspathConfigSourceuses thePathto the corresponding file or resource as the key source attribute (target), while theBuilderfor aUrlConfigSourceuses theURL.- Parameters:
pollingStrategyProvider- a polling strategy provider- Returns:
- a modified builder instance
- Throws:
UnsupportedOperationException- if the concreteBuilderimplementation does not support the polling strategy- See Also:
pollingStrategy(Supplier),target()
-
target
protected T target()
Returns key source attributes (target).- Returns:
- key source attributes (target).
-
optional
public B optional()
BuiltConfigSourcewill not be mandatory, i.e. it is ignored if configuration target does not exists.- Returns:
- a modified builder instance
-
changesExecutor
public B changesExecutor(Executor changesExecutor)
Specifies "observe-on"Executorto be used to deliverconfig source changes. The same executor is also used to reload the source, as triggered by thepolling strategy event.The default executor is from a dedicated thread pool which reuses threads as possible.
- Parameters:
changesExecutor- the executor to use for async delivery ofSource.changes()events- Returns:
- a modified builder instance
- See Also:
changesMaxBuffer(int),Source.changes(),PollingStrategy.ticks()
-
changesMaxBuffer
public B changesMaxBuffer(int changesMaxBuffer)
Specifies maximum capacity for each subscriber's buffer to be used to deliverconfig source changes.By default
Flow.defaultBufferSize()is used.Note: Not consumed events will be dropped off.
- Parameters:
changesMaxBuffer- the maximum capacity for each subscriber's buffer ofSource.changes()events.- Returns:
- a modified builder instance
- See Also:
changesExecutor(Executor),Source.changes()
-
retryPolicy
public B retryPolicy(Supplier<RetryPolicy> retryPolicySupplier)
Sets a supplier ofRetryPolicythat will be responsible for invocation ofAbstractSource.load().The default reply policy is
RetryPolicies.justCall().Create a custom policy or use the built-in policy constructed with a
builder.- Parameters:
retryPolicySupplier- a execute policy supplier- Returns:
- a modified builder instance
-
build
public abstract S build()
Builds new instance ofS.- Returns:
- new instance of
S.
-
isMandatory
protected boolean isMandatory()
Returns mandatory property.- Returns:
- mandatory property.
-
pollingStrategy
protected PollingStrategy pollingStrategy()
Returns polling-strategy property.- Returns:
- polling-strategy property.
-
changesExecutor
protected Executor changesExecutor()
Returns changes-executor property.- Returns:
- changes-executor property.
-
changesMaxBuffer
protected int changesMaxBuffer()
Returns changes-max-buffer property.- Returns:
- changes-max-buffer property.
-
retryPolicy
protected RetryPolicy retryPolicy()
Retry policy configured in this builder.- Returns:
- retry policy
-
-