org.apache.tamaya.events.folderobserver

## Class ObservingPropertySourceProvider

- java.lang.Object
- - org.apache.tamaya.events.folderobserver.ObservingPropertySourceProvider

- All Implemented Interfaces:
    PropertySourceProvider

      public class ObservingPropertySourceProvider
      extends Object
      implements PropertySourceProvider

  This implementation run in a folder taking up all file compatible with the given ConfigurationFormats. When a file is added, deleted or modified the PropertySourceProvider will adapt the changes automatically and trigger according `PropertySourceChange` events. The default folder is META-INF/config, but you can change using the absolute path in "-Dtamaya.configdir" parameter.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ObservingPropertySourceProvider(ConfigurationFormat... formats)` Constructor, reading the config file from classpath resource and system property.
    `ObservingPropertySourceProvider(Path directory, ConfigurationFormat... formats)` Constructorm using an explicit directory, ignoring all kind of configuration, if set.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `directoryChanged(Path directory)` Called when a file has been modified.
    `Collection<PropertySource>` | `getPropertySources()`
    `protected Collection<PropertySource>` | `getPropertySources(ConfigurationData data)`
    `protected ConfigurationData` | `loadFile(Path file)` Load a single file.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ObservingPropertySourceProvider

          public ObservingPropertySourceProvider(ConfigurationFormat... formats)

      Constructor, reading the config file from classpath resource and system property.

    - #### ObservingPropertySourceProvider

          public ObservingPropertySourceProvider(Path directory,
                                                 ConfigurationFormat... formats)

      Constructorm using an explicit directory, ignoring all kind of configuration, if set.
      Parameters:
        `directory` - the target directory. If null, the default configuration and system property are used.
        `formats` - the formats to be used.

  - ### Method Detail

    - #### getPropertySources

          protected Collection<PropertySource> getPropertySources(ConfigurationData data)

    - #### loadFile

          protected ConfigurationData loadFile(Path file)

      Load a single file.
      Parameters:
        `file` - the file, not null.

    - #### directoryChanged

          public void directoryChanged(Path directory)

      Called when a file has been modified.
      Parameters:
        `directory` - the file path, not null.

    - #### getPropertySources

          public Collection<PropertySource> getPropertySources()

      Specified by:
        `getPropertySources` in interface `PropertySourceProvider`

Copyright © 2014–2015 Apache Software Foundation. All rights reserved.