B - type of Builder implementationT - type of key source attributes (target) used to construct
polling strategy fromS - type of source that should be builtpublic abstract static class AbstractSource.Builder<B extends AbstractSource.Builder<B,T,S>,T,S> extends Object
AbstractSource builder, suitable for concrete Builder implementations
related to AbstractSource extensions to extend.
The application can control this behavior:
mandatory - whether the resource is mandatory (by default) or
optionalpollingStrategy - which source reload policy to useexecutor and subscriber's buffer size -
related to propagating source changes| Modifier | Constructor and Description |
|---|---|
protected |
Builder(Class<T> targetType)
Initializes builder.
|
| Modifier and Type | Method and Description |
|---|---|
abstract S |
build()
Builds new instance of
S. |
protected Executor |
changesExecutor()
Returns changes-executor property.
|
B |
changesExecutor(Executor changesExecutor)
Specifies "observe-on"
Executor to be used to deliver
config 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 deliver
config source changes. |
protected B |
init(Config metaConfig)
Initialize builder from specified configuration properties.
|
protected boolean |
isMandatory()
Returns mandatory property.
|
B |
optional()
Built
ConfigSource 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 of
RetryPolicy that will be responsible for invocation of AbstractSource.load(). |
protected T |
target()
Returns key source attributes (target).
|
protected B |
thisBuilder()
Returns current builder instance.
|
protected B thisBuilder()
protected B init(Config metaConfig)
Supported configuration properties:
optional - type boolean, see optional()polling-strategy - see PollingStrategy for details about configuration format,
see pollingStrategy(Supplier) or pollingStrategy(Function)metaConfig - configuration properties used to initialize a builder instance.public B pollingStrategy(Supplier<PollingStrategy> pollingStrategySupplier)
pollingStrategySupplier - a polling strategyPollingStrategies.regular(java.time.Duration)public final B pollingStrategy(Function<T,Supplier<PollingStrategy>> pollingStrategyProvider)
Concrete subclasses should override target() to provide
the key source attributes (target). For example, the Builder
for a FileConfigSource or ClasspathConfigSource uses
the Path to the corresponding file or resource as the key
source attribute (target), while the Builder for a
UrlConfigSource uses the URL.
pollingStrategyProvider - a polling strategy providerUnsupportedOperationException - if the concrete Builder
implementation does not support the polling strategypollingStrategy(Supplier),
target()protected T target()
public B optional()
ConfigSource will not be mandatory, i.e. it is ignored if configuration target does not exists.public B changesExecutor(Executor changesExecutor)
Executor to be used to deliver
config source changes. The same
executor is also used to reload the source, as triggered by the
polling strategy event.
The default executor is from a dedicated thread pool which reuses threads as possible.
changesExecutor - the executor to use for async delivery of
Source.changes() eventschangesMaxBuffer(int),
Source.changes(),
PollingStrategy.ticks()public B changesMaxBuffer(int changesMaxBuffer)
config source changes.
By default Flow.defaultBufferSize() is used.
Note: Not consumed events will be dropped off.
changesMaxBuffer - the maximum capacity for each subscriber's buffer of Source.changes() events.changesExecutor(Executor),
Source.changes()public B retryPolicy(Supplier<RetryPolicy> retryPolicySupplier)
RetryPolicy that will be responsible for invocation of AbstractSource.load().
The default reply policy is RetryPolicies.justCall().
Create a custom policy or use the built-in policy constructed with a builder.
retryPolicySupplier - a execute policy supplierpublic abstract S build()
S.S.protected boolean isMandatory()
protected PollingStrategy pollingStrategy()
protected Executor changesExecutor()
protected int changesMaxBuffer()
protected RetryPolicy retryPolicy()
Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.