Pax ConfMan - Scanner - Dir
This page is a scratch pad for the redesigned Pax ConfMan.
Scans directories for properties files. The scanner will scan the content of the configured directory and for each found properties file (files with .properties or .cfg extension) will be considered as a configuration. The file name without extension will be used as pid. If the scanned directory contains directories then each directory will be considerd as containing factory configurations where directory name is the factory pid and each property file contained in that directory is considered a factory configuration with the pid equal ith file name without extension.
The configured directories can point to files that are not directories or do not exist or cannot be read. This fact is verified at each scan. If that's the case it will just not create any configuration. This way of working ensures that if the state of the configured directories change over time during scanners lifetime (as for example the directory is removed or created, permissions changes,...) the scanners will still work properly.
The configuration files can be of any type as far as an available adaptor|Pax Confman - Design#adaptors] that is able to convert it to a configuration dictionary.
For system safety files that do not have a known MIME type will be filtered out (no configuration will be created for them).
Configuration
Directory scanner can be itself configured in two ways: via system properties and via Configuration Admin Service. On start the system properties configuration will be read and scanners are created and started as can be seen bellow. As soon as configurations are available via Configuration Admin Service the scanners created via system properties configuration will be stopped and the ones configured via Configuration Admin Service will be started. If during its lifetime Configuration Admin service becomes unavailable or there are no configurations available from configuration admin the scanners configured via system properties will be once again activated.
If there are more scanners configured to scan to the same directory only one scanner will be created, the first one configured.
Configuration via system properties
You can configure registry scanner by setting the following system properties:
Key |
Description |
|---|---|
org.ops4j.pax.cm.scanner.directory.directories |
A comma separated list of directories to be scanned for configurations. |
org.ops4j.pax.cm.scanner.directory.interval |
The number of milliseconds between scans. If no value is provided or the value is not a number a default 2000ms (2 seconds) will be used. |
Configuration via Configuration Admin Service
Registry scanner is itself a Managed Service Factory registered with factory pid org.ops4j.pax.cm.scanner.directory. For each received configuration it will create and start a directory scanning process. If a configuration is deleted the corresponding scanner will be stopped and disposed. Each configuration is expected / can contain:
Key |
Description |
|---|---|
directory |
A file path to the targeted directory. Value must be a String and cannot be null. In case that the value is null the configuration will not be accepted and a |
interval |
number of milliseconds between pooling of the directory. Value can be anything that can be converted to a long value and is optional. If not set da default 2000ms (2 seconds) will be used. If value is set but is not a number teh configuration will not be accepted and a |
Road map
- stop scanners if configuration admin becomes unavailable and restart the system properties ones.
- add configuration options for filtering of file names in the scanned directories (e.g. *.cfg = only files with cfg extension).
- (maybe) scanned directories can contain a "known" file that can override the configured properties for that file (e.g. interval). As soon as this file changes the scanned for that directory reconfigure itself.
Issue tracker
Issues, bugs, and feature requests can be submitted to the issue tracking system.
scanner-dir