commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Pugh <trashspam2...@yahoo.com>
Subject [CONFIGURATION] FileChangedReloadingStrategy not working for SubnodeConfiguration with a CombinedConfiguration parent
Date Thu, 16 Oct 2008 22:33:00 GMT
Hi,

I'm somewhat new to configuration and have run into what appears to be a bug (but maybe I'm
just doing something wrong).  I'm hoping to either confirm that this is a bug (in which case
I'll enter a JIRA) or get some insight on what I'm doing wrong.

I'm trying to use an Combined configuration that consists of two XMLConfigurations.  I want
to then get a SubnodeConfiguration from the combined configuration.  The XMLConfigurations
have the FileChangedReloadingStrategy set, the combined configuration has the setForceReloadCheck
flag set and the subnodeconfiguration was obtained passing in the true flag to the configurationAt
method.  However, I don't seem to see changes that are made to the two underlying files. 
It does work if I operate on the combined configuration or if a subnodeconfiguration has an
XMLConfiguration as its parent, but if a subnode configuration has a combined configuration
as the parent, the changes are not detected.  

Below is some code that shows how I'm using the various configurations and the various scenarios
I described above.  The last assertion fails because the change to the file is not detected
when the subnodeconfiguration has a parent that is a combinedconfiguration.  Any help or
insight would be greatly appreciated!


 @Test
  public void testSubnodeReadload() throws ConfigurationException {
    XMLConfiguration xmlConfiguration = new XMLConfiguration("service.xml");
    FileChangedReloadingStrategy fileReloadStrategy = new FileChangedReloadingStrategy();
    fileReloadStrategy.setRefreshDelay(1000);
    xmlConfiguration.setReloadingStrategy(fileReloadStrategy);
    XMLConfiguration config2 = new XMLConfiguration("environment.xml");
    FileChangedReloadingStrategy fileReloadStrategy2 = new FileChangedReloadingStrategy();
    fileReloadStrategy2.setRefreshDelay(1000);
    xmlConfiguration.setReloadingStrategy(fileReloadStrategy2);

    CombinedConfiguration combinedConfig = new CombinedConfiguration();
    combinedConfig.setForceReloadCheck(true);
    combinedConfig.addConfiguration(xmlConfiguration);
    combinedConfig.addConfiguration(config2);
    int queue0threads2 = xmlConfiguration.getInt("messaging-new.queue(0).threads");
    assert 2 == queue0threads2;

    //change the value in service.xml to 4
    int queue0threads4 = xmlConfiguration.getInt("messaging-new.queue(0).threads");
    assert 4 == queue0threads4;


    SubnodeConfiguration subConfigHier = xmlConfiguration.configurationAt("messaging-new.queue(0)",
true);
    int queue0threadsCombinedSub4 = subConfigHier.getInt("threads");
    assert queue0threadsCombinedSub4 == 4;

    //change the value service.xml to 8
    int queue0threadsCombinedSub8 = subConfigHier.getInt("threads");
    assert queue0threadsCombinedSub8 == 8;


    SubnodeConfiguration subNodeConfigParentIsCombinedConfig = combinedConfig.configurationAt("messaging-new.queue(0)",
true);
    int queue0threadsSub8 = subNodeConfigParentIsCombinedConfig.getInt("threads");
    assert queue0threadsSub8 == 8;

    //change the value service.xml file to 16
    int queue0threadsSub16 = subNodeConfigParentIsCombinedConfig.getInt("threads");
    assert queue0threadsSub16 == 16;         //THIS TEST FAILS

  }





      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message