- All Known Implementing Classes:
ScheduledPollingStrategy
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Config
tree, as accessed through PollableSource
s.
Once it loads a Config
tree from ConfigSource
s the config
system does not itself change the in-memory Config
tree. Even so, the
underlying data available via the tree's ConfigSource
s can change.
The Config system nevertheless supports change notification through
Config.onChange(java.util.function.Consumer)
and that is enabled
also by polling strategies.
In implementations of PollingStrategy
provide a notification mechanism
through start(io.helidon.config.spi.PollingStrategy.Polled)
, where the
polled component receives events that should check for changes.
In config system itself, this is handled by internals and is not exposed outside
of it.
A config source implements appropriate functionality in method
PollableSource.isModified(Object)
, which will
be invoked each time a polling strategy triggers the listener.
As described with MetaConfig.configSource(io.helidon.config.Config)
, the config system can
load ConfigSource
s using meta-configuration, which supports
specifying polling strategies. All built-in polling
strategies
and custom ones are supported.
See PollingStrategyProvider
for details.
The meta-configuration for a config source can set the property
polling-strategy
using the following nested properties
:
type
- name of the polling strategy implementation (referencing the Java Service Loader service)Built-in Polling Strategies Name Strategy Required Properties regular
Scheduled polling at regular intervals. See PollingStrategies.regular(Duration)
.interval
inDuration
format, e.g.PT15S
means 15 secondsclass
- fully-qualified class name of a custom polling strategy implementation or a builder class that implements abuild()
method that returns aPollingStrategy
.
type
or class
to
indicate a polling strategy but not both. If both appear the config system
ignores the class
setting.
Meta-configuration Support for Custom Polling Strategies
To support settings in meta-configuration, a custom polling strategy must be capable of processing the meta configuration provided toMetaConfigurableProvider.create(String, io.helidon.config.Config)
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
start
(PollingStrategy.Polled polled) Start this polling strategy.default void
stop()
Stop polling and release all resources.
-
Method Details
-
start
Start this polling strategy. From this point in time, the polled will receive events onPollingStrategy.Polled.poll(java.time.Instant)
. It is the responsibility of thePollingStrategy.Polled
to handle such requests. AConfigSource
needs only support for polling stamps to support a polling strategy, the actual reloading is handled by the configuration component. There is no need to implementPollingStrategy.Polled
yourself, unless you want to implement a new component that supports polling. Possible reloads of configuration are happening within the thread that invokes this method.- Parameters:
polled
- a component receiving polling events.
-
stop
default void stop()Stop polling and release all resources.
-