Example usage for org.apache.commons.configuration.reloading ReloadingStrategy ReloadingStrategy

List of usage examples for org.apache.commons.configuration.reloading ReloadingStrategy ReloadingStrategy

Introduction

In this page you can find the example usage for org.apache.commons.configuration.reloading ReloadingStrategy ReloadingStrategy.

Prototype

ReloadingStrategy

Source Link

Usage

From source file:org.finra.dm.dao.ReloadablePropertySourceTest.java

/**
 * Gets a new properties configuration that will re-load the properties from a file every time it is called.
 *
 * @return the properties configuration.
 * @throws ConfigurationException if the properties configuration couldn't be created.
 *///from   ww  w . j ava 2  s.co m
private PropertiesConfiguration getNewPropertiesConfiguration() throws ConfigurationException {
    // Create a new properties configuration.
    // We are using this instead of a database configuration for easier testing.
    PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(propertiesFile);

    // Create a reloading strategy that will always reload when asked.
    // There were some problems using the FileChangedReloadingStrategy where it wasn't detecting changed files and causing some methods in this
    // JUnit to fail.
    propertiesConfiguration.setReloadingStrategy(new ReloadingStrategy() {
        @Override
        public void setConfiguration(FileConfiguration configuration) {
        }

        @Override
        public void init() {
        }

        @Override
        public boolean reloadingRequired() {
            // Tell the caller that the properties should always be reloaded.
            return true;
        }

        @Override
        public void reloadingPerformed() {
        }
    });

    return propertiesConfiguration;
}