diff -r ed84c8bdd87b -r f8894df2d079 src/org/sonews/config/BackendConfig.java --- a/src/org/sonews/config/BackendConfig.java Sun Aug 29 17:28:58 2010 +0200 +++ b/src/org/sonews/config/BackendConfig.java Wed May 04 18:06:24 2011 +0200 @@ -33,83 +33,67 @@ class BackendConfig extends AbstractConfig { - private static BackendConfig instance = new BackendConfig(); - - public static BackendConfig getInstance() - { - return instance; - } - - private final TimeoutMap values - = new TimeoutMap(); - - private BackendConfig() - { - super(); - } - - /** - * Returns the config value for the given key or the defaultValue if the - * key is not found in config. - * @param key - * @param defaultValue - * @return - */ - @Override - public String get(String key, String defaultValue) - { - try - { - String configValue = values.get(key); - if(configValue == null) - { - if(StorageManager.current() == null) - { - Log.get().warning("BackendConfig not available, using default."); - return defaultValue; - } + private static BackendConfig instance = new BackendConfig(); - configValue = StorageManager.current().getConfigValue(key); - if(configValue == null) - { - return defaultValue; - } - else - { - values.put(key, configValue); - return configValue; - } - } - else - { - return configValue; - } - } - catch(StorageBackendException ex) - { - Log.get().log(Level.SEVERE, "Storage backend problem", ex); - return defaultValue; - } - } - - /** - * Sets the config value which is identified by the given key. - * @param key - * @param value - */ - public void set(String key, String value) - { - values.put(key, value); - - try - { - // Write values to database - StorageManager.current().setConfigValue(key, value); - } - catch(StorageBackendException ex) - { - ex.printStackTrace(); - } - } - + public static BackendConfig getInstance() + { + return instance; + } + private final TimeoutMap values = new TimeoutMap(); + + private BackendConfig() + { + super(); + } + + /** + * Returns the config value for the given key or the defaultValue if the + * key is not found in config. + * @param key + * @param defaultValue + * @return + */ + @Override + public String get(String key, String defaultValue) + { + try { + String configValue = values.get(key); + if (configValue == null) { + if (StorageManager.current() == null) { + Log.get().warning("BackendConfig not available, using default."); + return defaultValue; + } + + configValue = StorageManager.current().getConfigValue(key); + if (configValue == null) { + return defaultValue; + } else { + values.put(key, configValue); + return configValue; + } + } else { + return configValue; + } + } catch (StorageBackendException ex) { + Log.get().log(Level.SEVERE, "Storage backend problem", ex); + return defaultValue; + } + } + + /** + * Sets the config value which is identified by the given key. + * @param key + * @param value + */ + public void set(String key, String value) + { + values.put(key, value); + + try { + // Write values to database + StorageManager.current().setConfigValue(key, value); + } catch (StorageBackendException ex) { + ex.printStackTrace(); + } + } }