-
- 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.
@FunctionalInterface public interface PollingStrategy
Mechanism for notifying interested listeners when they should check for changes that might have been made to the data used to create aConfig
tree, as accessed throughPollableSource
s.Once it loads a
Config
tree fromConfigSource
s the config system does not itself change the in-memoryConfig
tree. Even so, the underlying data available via the tree'sConfigSource
s can change. The Config system nevertheless supports change notification throughConfig.onChange(java.util.function.Consumer)
and that is enabled also by polling strategies.In implementations of
PollingStrategy
provide a notification mechanism throughstart(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 loadConfigSource
s using meta-configuration, which supports specifying polling strategies. Allbuilt-in polling strategies
and custom ones are supported. SeePollingStrategyProvider
for details.The meta-configuration for a config source can set the property
polling-strategy
using the following nestedproperties
: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
orclass
to indicate a polling strategy but not both. If both appear the config system ignores theclass
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)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
PollingStrategy.Polled
A polled component.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
start(PollingStrategy.Polled polled)
Start this polling strategy.default void
stop()
Stop polling and release all resources.
-
-
-
Method Detail
-
start
void start(PollingStrategy.Polled polled)
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.
-
-