Class TomlConfigurationStore

All Implemented Interfaces:
Iterable<ComponentType>, Channel, ComponentType, Eligible, Manager

This component provides a store for an application’s configuration backed by a TOML file.

The component reads the initial values from File passed to the constructor. During application bootstrap, it intercepts the Start event using a handler with priority 999999. When receiving this event, it fires all known preferences values on the channels of the start event as a InitialPreferences event, using a new EventPipeline and waiting for its completion. Then, allows the intercepted Start event to continue.

Components that depend on configuration values define handlers for ConfigurationUpdate events and adapt themselves to the values received. Note that due to the intercepted Start event, the initial preferences values are received before the Start event, so components’ configurations can be rearranged before they actually start doing something.

Besides initially publishing the stored preferences values, the component also listens for ConfigurationUpdate events on its channel and updates the TOML file (may be suppressed).

  • Constructor Details

    • TomlConfigurationStore

      public TomlConfigurationStore(Channel componentChannel, File file) throws IOException
      Creates a new component with its channel set to the given channel and the given file.

      The component handles ConfigurationUpdate events and FileChanged events for the configuration file (see

      Throws:
      IOException
    • TomlConfigurationStore

      public TomlConfigurationStore(Channel componentChannel, File file, boolean update) throws IOException
      Creates a new component with its channel set to the given channel and the given file.

      The component handles FileChanged events for the configuration file (see

      Throws:
      IOException
    • TomlConfigurationStore

      public TomlConfigurationStore(Channel componentChannel, File file, boolean update, boolean watch) throws IOException
      Creates a new component with its channel set to the given channel and the given file.

      If update is true, the configuration file is updated when ConfigurationUpdate events are received.

      If watch is true, FileChanged events are processed and the configuration file is reloaded when it changes. Note that the generation of the FileChanged events must be configured independently (see FileSystemWatcher).

      Parameters:
      componentChannel - the channel
      file - the file used to store the configuration
      update - if the configuration file is to be updated
      watch - if FileChanged events are to be processed
      Throws:
      IOException - Signals that an I/O exception has occurred.