com.emarsys.ecommon.prefs.config.backend
Class FallbackDefaultConfigurationBackend

java.lang.Object
  extended by com.emarsys.ecommon.prefs.config.backend.FallbackDefaultConfigurationBackend
All Implemented Interfaces:
ConfigurationBackend

public class FallbackDefaultConfigurationBackend
extends java.lang.Object
implements ConfigurationBackend

A ConfigurationBackend that provides both a fallback and defaults mechanism.

The priority chain for resolving setting names is: primary --> fallback --> default --> fallback default

Author:
Michael "kULO" Kulovits
See Also:
ConfigurationBackend, DefaultsConfigurationBackend, FallbackConfigurationBackend

Field Summary
protected  ConfigurationBackend defaults
           
protected  ConfigurationBackend fallbackDefaults
           
protected  ConfigurationBackend fallbacks
           
protected  ConfigurationBackend primaries
           
 
Constructor Summary
FallbackDefaultConfigurationBackend(ConfigurationBackend primarySettings, ConfigurationBackend defaultSettings, java.util.Map<java.lang.String,java.lang.String> fallbackNames)
           
 
Method Summary
 ISetting get(java.lang.String name)
          Retrieves the ISetting with the passed name.
 SettingMode getMode(java.lang.String name)
           
 java.util.List<ISetting> getSettings()
           Retrieves all ISettings from this backend.
 void set(ISetting setting)
          Sets the passed setting which must not be null in this configuration backend, if a setting with the given name is already present it will be overridden.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

primaries

protected ConfigurationBackend primaries

defaults

protected ConfigurationBackend defaults

fallbacks

protected ConfigurationBackend fallbacks

fallbackDefaults

protected ConfigurationBackend fallbackDefaults
Constructor Detail

FallbackDefaultConfigurationBackend

public FallbackDefaultConfigurationBackend(ConfigurationBackend primarySettings,
                                           ConfigurationBackend defaultSettings,
                                           java.util.Map<java.lang.String,java.lang.String> fallbackNames)
Parameters:
defaultSettings -
fallbackNames -
Method Detail

getMode

public SettingMode getMode(java.lang.String name)
Parameters:
name -
Returns:

get

public ISetting get(java.lang.String name)
             throws java.lang.IllegalArgumentException
Description copied from interface: ConfigurationBackend
Retrieves the ISetting with the passed name.

Specified by:
get in interface ConfigurationBackend
Returns:
the ISetting with the passed name or null if not present.
Throws:
java.lang.IllegalArgumentException - - if the passed name is null.
See Also:
com.emarsys.core.setting.backend.ConfigurationBackend#get(java.lang.String)

set

public void set(ISetting setting)
         throws java.lang.IllegalArgumentException
Description copied from interface: ConfigurationBackend
Sets the passed setting which must not be null in this configuration backend, if a setting with the given name is already present it will be overridden. The next call to ConfigurationBackend.get(String) with the passed setting's name will return the passed setting.

Specified by:
set in interface ConfigurationBackend
Throws:
java.lang.IllegalArgumentException - - if the passed setting, its name or value is null.
See Also:
com.emarsys.core.setting.backend.ConfigurationBackend#set(ISetting)

getSettings

public java.util.List<ISetting> getSettings()
Description copied from interface: ConfigurationBackend

Retrieves all ISettings from this backend.

What exactly "all" means in the context of the concrete ConfigurationBackend is up to the implementation. For instance the List may or may not contain default values or fallbacked ISettings or might even return a cached list.

The only requirement for this method is to be logically in synch with ConfigurationBackend.get(String) and ConfigurationBackend.set(ISetting). Thus if a Setting is inserted/updated/deleted and nothing is changed in the meantime the next call to ConfigurationBackend.getSettings() has to reflect the changes made.

Specified by:
getSettings in interface ConfigurationBackend
Returns:
always a valid List of ISettings, never null.
See Also:
com.emarsys.core.setting.backend.ConfigurationBackend#getSettings()


Copyright © 2010 emarsys AG. All Rights Reserved.