Pax Coin File System Configuration Provider will scan the content of configurable directories for configuration files and each found file (see supported file formats) will be considered as a configuration.
To see how you can use this provider take a look at the example use case.
Persistent identifier
The persistent identifier for the configuration will be determined as follow:
- if configuration file name does not contain "$", persistent identifier will be equal with file name without the extension. This type of configuration file is considered to target a ManagedService.
Example: for a file named "foo.properties" the persistent identifier will be "foo". - if configuration file name contains "$", persistent identifier will be equal with file name without extension and "$" replaced with "-", and factory persistent identifier will be equal with the left side of "$". This type of configuration is considered to target a ManagedServiceFactory.
Example: for a file named "foo$bar.properties" the persistent identifier will be "foo-bar" and factory persistent identifier will be "foo".
File formats
This provider supports two file formats:
- Files with a ".properties" extension will be loaded using Properties Loader
- Files with a ".xml" extension will be loaded using Apache Commons Configuration
Scanning
File System Configuration Provider will poll the configured directory for changes. As soon as a change is encountered, the change will trigger an update on the configuration corresponding to the changed file as follow:
- new file available or file content is updated — corresponding ManagedService / ManagedServiceFactory will be updated with the new configuration; a file is considered changed if is new or the last update time has changed;
- file is deleted — corresponding ManagedService / ManagedServiceFactory configuration will be deleted.
Configuration
File System Configuration Provider can be itself configured in two ways: via system properties and via Configuration Admin Service as ManagedServiceFactory. By default (not configured) the file system provider will not scan any directory.
Configuration via system properties
The most trivial way to configure file system provider is via setting the following system properties:
org.ops4j.pax.coin.directory
— the file path of the ops4j:scanned directory containing configuration files.org.ops4j.pax.coin.directory.poll.interval
— the interval in milliseconds between scans of the specified directory. If not set the default scanning interval will be 1 minute.
Configuration via Configuration Admin Service
A more powerful way to configure file system provider is by configuring it via Configuration Admin. The file system provider will register itself as a ManagedServiceFactory with factory pid org.ops4j.pax.coin.file.system
in order to be able to configure multiple directories to be scanned. Each configuration must contain the following properties:
directory
— the file path of the ops4j:scanned directory containing configuration files.poll.interval
— the interval in milliseconds between scans of the specified directory. If not set the default scanning interval will be 1 minute.