You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Oliver Heger (JIRA)" <ji...@apache.org> on 2015/05/27 21:42:17 UTC

[jira] [Commented] (CONFIGURATION-602) DatabaseConfiguration doesn't reload from database.

    [ https://issues.apache.org/jira/browse/CONFIGURATION-602?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14561581#comment-14561581 ] 

Oliver Heger commented on CONFIGURATION-602:
--------------------------------------------

The reloading functionality as implemented in the 1.x series is limited to file-based configurations; there is simply no reloading support for DatabaseConfiguration.

In version 2.0 (currently available as alpha release), situation has improved. The reloading mechanism is now more generic and can be customized. You can find a description of the new features in the updated user's guide:
http://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html

However, the new reloading mechanism will not work out of the box with DatabaseConfiguration either. The reason is that it is very much application-specific when checks for a reload are to be executed and which triggers are to be used - you probably do not want that each access to a combined configuration causes a full scan of the configuration database table. So, Commons Configuration 2.0 gives you enhanced flexibility in this area, but you still have to write some code on your own to implement your specific use case.

If you agree, I will close this ticket as "Won't fix" for the reasons outlined above.

> DatabaseConfiguration doesn't reload from database.
> ---------------------------------------------------
>
>                 Key: CONFIGURATION-602
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-602
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Build
>    Affects Versions: 1.10
>         Environment: Windows, Eclipse, apache commons 1.10
>            Reporter: Chethan Shankar_apache
>            Priority: Critical
>              Labels: DatabaseConfigurationProvider, commons-configuration, configuration
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Hi,
> I have successfully setup Apache configuration to read from a database table by using DatabaseConfigurationProvider. However when I change the database property in the DB table and read the property again, it always has the previous value and not the updated value from Table.
> My code is:
> {quote}
> *Setup:*
> 			DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(propFileUrl);
> 			DefaultConfigurationBuilder.ConfigurationProvider provider = new DatabaseConfigurationProvider();
> 			builder.addConfigurationProvider("database", provider);
> 			ReloadingStrategy strategy = new FileChangedReloadingStrategy(); 
> 			((FileChangedReloadingStrategy) strategy).setRefreshDelay(5000);
> 			builder.setReloadingStrategy(strategy);			
>                         combinedConfig = builder.getConfiguration(true);
> *Config.xml:*
>                          <configuration>
>                          <database jndi="jdbc/semsDs" table="CSW_APPL_PROPERTIES" keyColumn="PROP_NAME" valueColumn="PROP_VALUE"/>
>                          </configuration>
> *To access table property:*
> String dbProp = combinedConfig.getString("TEST_PROP");
> {quote}
> *Steps to recreate:*
> 1) Setup Apache database configuration as above.
> 2) Access the property from DB table TEST_PROP=TEMP_1
> 3) Now change the TEST_PROP value to TEMP_2 in the DB table.
> 4) Access the property from  the same DB Table.
> 5) Property Value still says TEMP_1.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)