Package org.apache.commons.configuration.reloading

Examples of org.apache.commons.configuration.reloading.FileChangedReloadingStrategy


            out.close();
            out = null;

            PropertiesConfiguration config = new PropertiesConfiguration(
                    configFile);
            config.setReloadingStrategy(new FileChangedReloadingStrategy());
            config.setAutoSave(true);

            assertEquals("one", config.getProperty("a"));
            config.setProperty("b", "two");
            assertEquals("one", config.getProperty("a"));
View Full Code Here


       
        configurationRefreshDelay = NumberUtils.toLong(getServletConfig().getInitParameter("reverseproxy.configuration.refresh.delay"), 0L);
       
        if (configurationRefreshDelay > 0L)
        {
            configReloadingStrategy = new FileChangedReloadingStrategy()
            {
                @Override
                public void reloadingPerformed()
                {
                    super.reloadingPerformed();
View Full Code Here

    private XMLConfiguration setUpReloadTest() throws ConfigurationException
    {
        removeTestFile();
        conf.save(testSaveConf);
        XMLConfiguration c = new XMLConfiguration(testSaveConf);
        c.setReloadingStrategy(new FileChangedReloadingStrategy()
        {
            // Report always a change
            protected boolean hasChanged()
            {
                return true;
View Full Code Here

     * implementation accesses methods of the configuration that in turn cause a reload.
     */
    public void testReentrantReload()
    {
        conf.setProperty("shouldReload", Boolean.FALSE);
        conf.setReloadingStrategy(new FileChangedReloadingStrategy()
        {
            public boolean reloadingRequired()
            {
                return configuration.getBoolean("shouldReload");
            }
View Full Code Here

            out.close();
            out = null;

            PropertiesConfiguration config = new PropertiesConfiguration(
                    configFile);
            config.setReloadingStrategy(new FileChangedReloadingStrategy());
            config.setAutoSave(true);

            assertEquals("one", config.getProperty("a"));
            config.setProperty("b", "two");
            assertEquals("one", config.getProperty("a"));
View Full Code Here

   {
      try
      {
         XMLConfiguration commonsConfig = new XMLConfiguration(file);
         commonsConfig.setEncoding("UTF-8");
         commonsConfig.setReloadingStrategy(new FileChangedReloadingStrategy());
         commonsConfig.setAutoSave(true);
         return new ConfigurationAdapter(commonsConfig);
      }
      catch (org.apache.commons.configuration.ConfigurationException e)
      {
View Full Code Here

        PropertiesConfiguration configuration = SwissKnife
                .loadConfigurationInUtf8(fileOrUrl);

        if (configuration != null && ninjaProperties.isDev()) {
            // enable runtime reloading of translations in dev mode
            FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
            configuration.setReloadingStrategy(strategy);
        }

        return configuration;
    }
View Full Code Here

                    + ninjaMode.name());

            // allow application.conf to be reloaded on changes in dev mode
            if (NinjaMode.dev == ninjaMode) {
                defaultConfiguration
                        .setReloadingStrategy(new FileChangedReloadingStrategy());
            }

        } else {

            // If the property was set, but the file not found we emit
            // a RuntimeException
            String errorMessage = String
                    .format("Error reading configuration file. Make sure you got a default config file %s",
                            NinjaProperties.CONF_FILE_LOCATION_BY_CONVENTION);

            logger.error(errorMessage);

            throw new RuntimeException(errorMessage);
        }

        // third step => load external configuration when a system property is
        // defined.
        String ninjaExternalConf = System.getProperty(NINJA_EXTERNAL_CONF);

        if (ninjaExternalConf != null) {

            // only load it when the property is defined.

            externalConfiguration = SwissKnife
                    .loadConfigurationInUtf8(ninjaExternalConf);

            // this should not happen:
            if (externalConfiguration == null) {

                String errorMessage = String
                        .format("Ninja was told to use an external configuration%n"
                                + " %s = %s %n."
                                + "But the corresponding file cannot be found.%n"
                                + " Make sure it is visible to this application and on the classpath.",
                                NINJA_EXTERNAL_CONF, ninjaExternalConf);

                logger.error(errorMessage);

                throw new RuntimeException(errorMessage);

            } else {

                // allow the external configuration to be reloaded at
                // runtime based on detected file changes
                final boolean shouldReload = Boolean.getBoolean(NINJA_EXTERNAL_RELOAD);
                if (shouldReload) {
                    externalConfiguration
                            .setReloadingStrategy(new FileChangedReloadingStrategy());
                }

                // Copy special prefix of mode to parent configuration
                // By convention it will be something like %test.myproperty
                prefixedExternalConfiguration = externalConfiguration
View Full Code Here

     */
    @Test
    public void testMultiConfiguration()
    {
        //set up a reloading strategy
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        strategy.setRefreshDelay(10000);

        MultiFileHierarchicalConfiguration config = new MultiFileHierarchicalConfiguration(PATTERN1);
        config.setReloadingStrategy(strategy);

        System.setProperty("Id", "1001");
View Full Code Here

     */
    @Test
    public void testMultiConfiguration()
    {
        //set up a reloading strategy
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        strategy.setRefreshDelay(10000);

        PatternSubtreeConfigurationWrapper config = new PatternSubtreeConfigurationWrapper(this.conf, PATTERN);
        config.setReloadingStrategy(strategy);
        config.setExpressionEngine(new XPathExpressionEngine());

View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.reloading.FileChangedReloadingStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.