Class YamlConfigurationStore

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

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

The YAML object described by this file represents the root directory. If an entry does not start with a slash, it represents the key of a key value pair. If it does starts with a slash, the value is another JSON object that describes the respective subdirectory.

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 YAML file (may be suppressed).

  • Constructor Details

    • YamlConfigurationStore

      public YamlConfigurationStore(Channel componentChannel, File file) throws IOException
      Creates a new component with its channel set to the given channel and the given file.
      Parameters:
      componentChannel - the component channel
      file - the file
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • YamlConfigurationStore

      public YamlConfigurationStore(Channel componentChannel, File file, boolean update) throws IOException
      Creates a new component with its channel set to the given channel and the given file.
      Parameters:
      componentChannel - the channel
      file - the file used to store the YAML
      update - if the file is to be updated when ConfigurationUpdate events are received
      Throws:
      IOException - Signals that an I/O exception has occurred.