Class JsonConfigurationStore

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

public class JsonConfigurationStore extends Component
This component provides a store for an application’s configuration backed by a JSON file.

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