Interface PollingStrategy

  • 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 a Config tree, as accessed through PollableSources.

    Once it loads a Config tree from ConfigSources the config system does not itself change the in-memory Config tree. Even so, the underlying data available via the tree's ConfigSources 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 ConfigSources 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 in Duration format, e.g. PT15S means 15 seconds

    • class - fully-qualified class name of a custom polling strategy implementation or a builder class that implements a build() method that returns a PollingStrategy.
    For a given config source use either 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 to MetaConfigurableProvider.create(String, io.helidon.config.Config)
    See Also:
    PollingStrategies - access built-in implementations., to implement custom polling strategies, to implement change watchers that notify config system when a target actually changes
    • Method Detail

      • start

        void start​(PollingStrategy.Polled polled)
        Start this polling strategy. From this point in time, the polled will receive events on PollingStrategy.Polled.poll(java.time.Instant). It is the responsibility of the PollingStrategy.Polled to handle such requests. A ConfigSource 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 implement PollingStrategy.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.