Package com.avanza.astrix.config
Class DynamicConfig
- java.lang.Object
-
- com.avanza.astrix.config.DynamicConfig
-
public final class DynamicConfig extends Object
This is an abstraction for a hierarchical set of configuration sources. Each property is resolved by querying each ConfigurationSource in turn until the property is resolved.Each
DynamicPropertyread is cached in theDynamicConfiginstance. The first time a property with a given name is read, an instance of the givenDynamicPropertytype is created, and its value is bound to the underlying configuration sources.- Author:
- Elias Lindholm (elilin)
-
-
Constructor Summary
Constructors Constructor Description DynamicConfig(ConfigSource configSource)DynamicConfig(List<? extends ConfigSource> configSources)
-
Method Summary
-
-
-
Constructor Detail
-
DynamicConfig
public DynamicConfig(ConfigSource configSource)
-
DynamicConfig
public DynamicConfig(List<? extends ConfigSource> configSources)
-
-
Method Detail
-
create
public static DynamicConfig create(ConfigSource first, ConfigSource... other)
Creates aDynamicConfiginstance resolving configuration properties using the defined set ofConfigSource's (possiblyDynamicConfigSource).
-
create
public static DynamicConfig create(List<? extends ConfigSource> sources)
-
getStringProperty
public DynamicStringProperty getStringProperty(String name, String defaultValue)
Reads a property of String type.
-
getOptionalStringProperty
public DynamicOptionalProperty<String> getOptionalStringProperty(String name)
-
getBooleanProperty
public DynamicBooleanProperty getBooleanProperty(String name, boolean defaultValue)
-
getOptionalBooleanProperty
public DynamicOptionalProperty<Boolean> getOptionalBooleanProperty(String name)
-
getLongProperty
public DynamicLongProperty getLongProperty(String name, long defaultValue)
-
getOptionalLongProperty
public DynamicOptionalProperty<Long> getOptionalLongProperty(String name)
-
getIntProperty
public DynamicIntProperty getIntProperty(String name, int defaultValue)
-
getOptionalIntegerProperty
public DynamicOptionalProperty<Integer> getOptionalIntegerProperty(String name)
-
getEnumProperty
public <T extends Enum<T>> DynamicEnumProperty<T> getEnumProperty(String name, Class<T> enumClass, T defaultValue)
-
getOptionalEnumProperty
public <T extends Enum<T>> DynamicOptionalProperty<T> getOptionalEnumProperty(String name, Class<T> enumClass)
-
getStringListProperty
public DynamicListProperty<String> getStringListProperty(String name, List<String> defaultValue)
-
getIntListProperty
public DynamicListProperty<Integer> getIntListProperty(String name, List<Integer> defaultValue)
-
getLongListProperty
public DynamicListProperty<Long> getLongListProperty(String name, List<Long> defaultValue)
-
getBooleanListProperty
public DynamicListProperty<Boolean> getBooleanListProperty(String name, List<Boolean> defaultValue)
-
getEnumListProperty
public <T extends Enum<T>> DynamicListProperty<T> getEnumListProperty(String name, Class<T> enumClass, List<T> defaultValue)
-
getEnumSetProperty
public <T extends Enum<T>> DynamicSetProperty<T> getEnumSetProperty(String name, Class<T> enumClass, Set<T> defaultValue)
-
merged
public static DynamicConfig merged(DynamicConfig dynamicConfigA, DynamicConfig dynamicConfigB)
-
addListener
public void addListener(DynamicConfigListener l)
Adds a listener to this DynamicConfig instance. The listener receives a "propertyChanged" event each time the resolved value of a DynamicProperty read from this instance changes. The listener receives a "propertyCreated" each time a new property is created in thisDynamicConfiginstance (i.e. the first time a property with a given name is read).
-
-