-
- 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 aConfigtree, as accessed throughPollableSources.Once it loads a
Configtree fromConfigSources the config system does not itself change the in-memoryConfigtree. Even so, the underlying data available via the tree'sConfigSources 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
PollingStrategyprovide 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 loadConfigSources using meta-configuration, which supports specifying polling strategies. Allbuilt-in polling strategiesand custom ones are supported. SeePollingStrategyProviderfor details.The meta-configuration for a config source can set the property
polling-strategyusing the following nestedproperties:type- name of the polling strategy implementation (referencing the Java Service Loader service)Built-in Polling Strategies Name Strategy Required Properties regularScheduled polling at regular intervals. See PollingStrategies.regular(Duration).intervalinDurationformat, e.g.PT15Smeans 15 secondsclass- fully-qualified class name of a custom polling strategy implementation or a builder class that implements abuild()method that returns aPollingStrategy.
typeorclassto indicate a polling strategy but not both. If both appear the config system ignores theclasssetting.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 interfacePollingStrategy.PolledA polled component.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidstart(PollingStrategy.Polled polled)Start this polling strategy.default voidstop()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.Polledto handle such requests. AConfigSourceneeds 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.Polledyourself, 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.
-
-