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 commonAbstractSource
builder, suitable for concreteBuilder
implementations related toAbstractSource
extensions 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
executor
and subscriber'sbuffer size
- related to propagating source changes
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract S
build()
Builds new instance ofS
.protected Executor
changesExecutor()
Returns changes-executor property.B
changesExecutor(Executor changesExecutor)
Specifies "observe-on"Executor
to be used to deliverconfig source changes
.protected int
changesMaxBuffer()
Returns changes-max-buffer property.B
changesMaxBuffer(int changesMaxBuffer)
Specifies maximum capacity for each subscriber's buffer to be used to deliverconfig source changes
.protected B
init(Config metaConfig)
Initialize builder from specified configuration properties.protected boolean
isMandatory()
Returns mandatory property.B
optional()
BuiltConfigSource
will not be mandatory, i.e.protected PollingStrategy
pollingStrategy()
Returns polling-strategy property.B
pollingStrategy(Function<T,Supplier<PollingStrategy>> pollingStrategyProvider)
Sets the polling strategy that accepts key source attributes.B
pollingStrategy(Supplier<PollingStrategy> pollingStrategySupplier)
Sets a polling strategy.protected RetryPolicy
retryPolicy()
Retry policy configured in this builder.B
retryPolicy(Supplier<RetryPolicy> retryPolicySupplier)
Sets a supplier ofRetryPolicy
that will be responsible for invocation ofAbstractSource.load()
.protected T
target()
Returns key source attributes (target).protected B
thisBuilder()
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
- seePollingStrategy
for 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, theBuilder
for aFileConfigSource
orClasspathConfigSource
uses thePath
to the corresponding file or resource as the key source attribute (target), while theBuilder
for aUrlConfigSource
uses theURL
.- Parameters:
pollingStrategyProvider
- a polling strategy provider- Returns:
- a modified builder instance
- Throws:
UnsupportedOperationException
- if the concreteBuilder
implementation 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()
BuiltConfigSource
will 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"Executor
to 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 ofRetryPolicy
that 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
-
-