com.netflix.config
Class ConfigurationWithPollingSource

java.lang.Object
  extended by com.netflix.config.ConfigurationWithPollingSource
All Implemented Interfaces:
org.apache.commons.configuration.Configuration

public class ConfigurationWithPollingSource
extends java.lang.Object
implements org.apache.commons.configuration.Configuration

This class delegates property read/write to an another configuration but is also attached with a dynamic configuration source and polling scheduler so that its properties can be changed dynamically at runtime. In other words, if the same property is defined in both the original configuration and the dynamic configuration source, the value in the original configuration will be overridden.

This class can be served as a decorator to an existing configuration to make the property values dynamic.


Constructor Summary
ConfigurationWithPollingSource(org.apache.commons.configuration.Configuration config, PolledConfigurationSource source, AbstractPollingScheduler scheduler)
          Create an instance and start polling the configuration source
 
Method Summary
 void addProperty(java.lang.String key, java.lang.Object value)
          Delegates to the underlying configuration.
 void clear()
          Delegates to the underlying configuration.
 void clearProperty(java.lang.String key)
          Delegates to the underlying configuration.
 boolean containsKey(java.lang.String arg0)
          Delegates to the underlying configuration.
 java.math.BigDecimal getBigDecimal(java.lang.String key)
          Delegates to the underlying configuration.
 java.math.BigDecimal getBigDecimal(java.lang.String key, java.math.BigDecimal defaultValue)
          Delegates to the underlying configuration.
 java.math.BigInteger getBigInteger(java.lang.String key)
          Delegates to the underlying configuration.
 java.math.BigInteger getBigInteger(java.lang.String key, java.math.BigInteger defaultValue)
          Delegates to the underlying configuration.
 boolean getBoolean(java.lang.String key)
          Delegates to the underlying configuration.
 boolean getBoolean(java.lang.String key, boolean defaultValue)
          Delegates to the underlying configuration.
 java.lang.Boolean getBoolean(java.lang.String key, java.lang.Boolean defaultValue)
          Delegates to the underlying configuration.
 byte getByte(java.lang.String key)
          Delegates to the underlying configuration.
 byte getByte(java.lang.String key, byte defaultValue)
          Delegates to the underlying configuration.
 java.lang.Byte getByte(java.lang.String key, java.lang.Byte defaultValue)
          Delegates to the underlying configuration.
 org.apache.commons.configuration.Configuration getConfiguration()
           
 double getDouble(java.lang.String key)
          Delegates to the underlying configuration.
 double getDouble(java.lang.String key, double defaultValue)
          Delegates to the underlying configuration.
 java.lang.Double getDouble(java.lang.String key, java.lang.Double defaultValue)
          Delegates to the underlying configuration.
 float getFloat(java.lang.String key)
          Delegates to the underlying configuration.
 float getFloat(java.lang.String key, float defaultValue)
          Delegates to the underlying configuration.
 java.lang.Float getFloat(java.lang.String key, java.lang.Float defaultValue)
          Delegates to the underlying configuration.
 int getInt(java.lang.String key)
          Delegates to the underlying configuration.
 int getInt(java.lang.String key, int defaultValue)
          Delegates to the underlying configuration.
 java.lang.Integer getInteger(java.lang.String key, java.lang.Integer defaultValue)
          Delegates to the underlying configuration.
 java.util.Iterator getKeys()
          Delegates to the underlying configuration.
 java.util.Iterator getKeys(java.lang.String prefix)
          Delegates to the underlying configuration.
 java.util.List getList(java.lang.String key)
          Delegates to the underlying configuration.
 java.util.List getList(java.lang.String key, java.util.List defaultValue)
          Delegates to the underlying configuration.
 long getLong(java.lang.String key)
          Delegates to the underlying configuration.
 long getLong(java.lang.String key, long defaultValue)
          Delegates to the underlying configuration.
 java.lang.Long getLong(java.lang.String key, java.lang.Long defaultValue)
          Delegates to the underlying configuration.
 java.util.Properties getProperties(java.lang.String key)
          Delegates to the underlying configuration.
 java.lang.Object getProperty(java.lang.String arg0)
          Delegates to the underlying configuration.
 short getShort(java.lang.String key)
          Delegates to the underlying configuration.
 short getShort(java.lang.String key, short defaultValue)
          Delegates to the underlying configuration.
 java.lang.Short getShort(java.lang.String key, java.lang.Short defaultValue)
          Delegates to the underlying configuration.
 java.lang.String getString(java.lang.String key)
          Delegates to the underlying configuration.
 java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
          Delegates to the underlying configuration.
 java.lang.String[] getStringArray(java.lang.String key)
          Delegates to the underlying configuration.
 boolean isEmpty()
          Delegates to the underlying configuration.
 void setProperty(java.lang.String key, java.lang.Object value)
          Delegates to the underlying configuration.
 void stopPolling()
           
 org.apache.commons.configuration.Configuration subset(java.lang.String prefix)
          Delegates to the underlying configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationWithPollingSource

public ConfigurationWithPollingSource(org.apache.commons.configuration.Configuration config,
                                      PolledConfigurationSource source,
                                      AbstractPollingScheduler scheduler)
Create an instance and start polling the configuration source

Parameters:
config - Configuration to delegate to
source - PolledConfigurationSource to poll get new/changed properties
scheduler - AbstractPollingScheduler to provide the polling schedule
Method Detail

getConfiguration

public final org.apache.commons.configuration.Configuration getConfiguration()

stopPolling

public final void stopPolling()

addProperty

public void addProperty(java.lang.String key,
                        java.lang.Object value)
Delegates to the underlying configuration.

Specified by:
addProperty in interface org.apache.commons.configuration.Configuration

clear

public void clear()
Delegates to the underlying configuration.

Specified by:
clear in interface org.apache.commons.configuration.Configuration

clearProperty

public void clearProperty(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
clearProperty in interface org.apache.commons.configuration.Configuration

containsKey

public boolean containsKey(java.lang.String arg0)
Delegates to the underlying configuration.

Specified by:
containsKey in interface org.apache.commons.configuration.Configuration

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String key,
                                          java.math.BigDecimal defaultValue)
Delegates to the underlying configuration.

Specified by:
getBigDecimal in interface org.apache.commons.configuration.Configuration

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getBigDecimal in interface org.apache.commons.configuration.Configuration

getBigInteger

public java.math.BigInteger getBigInteger(java.lang.String key,
                                          java.math.BigInteger defaultValue)
Delegates to the underlying configuration.

Specified by:
getBigInteger in interface org.apache.commons.configuration.Configuration

getBigInteger

public java.math.BigInteger getBigInteger(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getBigInteger in interface org.apache.commons.configuration.Configuration

getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean defaultValue)
Delegates to the underlying configuration.

Specified by:
getBoolean in interface org.apache.commons.configuration.Configuration

getBoolean

public java.lang.Boolean getBoolean(java.lang.String key,
                                    java.lang.Boolean defaultValue)
Delegates to the underlying configuration.

Specified by:
getBoolean in interface org.apache.commons.configuration.Configuration

getBoolean

public boolean getBoolean(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getBoolean in interface org.apache.commons.configuration.Configuration

getByte

public byte getByte(java.lang.String key,
                    byte defaultValue)
Delegates to the underlying configuration.

Specified by:
getByte in interface org.apache.commons.configuration.Configuration

getByte

public java.lang.Byte getByte(java.lang.String key,
                              java.lang.Byte defaultValue)
Delegates to the underlying configuration.

Specified by:
getByte in interface org.apache.commons.configuration.Configuration

getByte

public byte getByte(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getByte in interface org.apache.commons.configuration.Configuration

getDouble

public double getDouble(java.lang.String key,
                        double defaultValue)
Delegates to the underlying configuration.

Specified by:
getDouble in interface org.apache.commons.configuration.Configuration

getDouble

public java.lang.Double getDouble(java.lang.String key,
                                  java.lang.Double defaultValue)
Delegates to the underlying configuration.

Specified by:
getDouble in interface org.apache.commons.configuration.Configuration

getDouble

public double getDouble(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getDouble in interface org.apache.commons.configuration.Configuration

getFloat

public float getFloat(java.lang.String key,
                      float defaultValue)
Delegates to the underlying configuration.

Specified by:
getFloat in interface org.apache.commons.configuration.Configuration

getFloat

public java.lang.Float getFloat(java.lang.String key,
                                java.lang.Float defaultValue)
Delegates to the underlying configuration.

Specified by:
getFloat in interface org.apache.commons.configuration.Configuration

getFloat

public float getFloat(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getFloat in interface org.apache.commons.configuration.Configuration

getInt

public int getInt(java.lang.String key,
                  int defaultValue)
Delegates to the underlying configuration.

Specified by:
getInt in interface org.apache.commons.configuration.Configuration

getInt

public int getInt(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getInt in interface org.apache.commons.configuration.Configuration

getInteger

public java.lang.Integer getInteger(java.lang.String key,
                                    java.lang.Integer defaultValue)
Delegates to the underlying configuration.

Specified by:
getInteger in interface org.apache.commons.configuration.Configuration

getKeys

public java.util.Iterator getKeys()
Delegates to the underlying configuration.

Specified by:
getKeys in interface org.apache.commons.configuration.Configuration

getKeys

public java.util.Iterator getKeys(java.lang.String prefix)
Delegates to the underlying configuration.

Specified by:
getKeys in interface org.apache.commons.configuration.Configuration

getList

public java.util.List getList(java.lang.String key,
                              java.util.List defaultValue)
Delegates to the underlying configuration.

Specified by:
getList in interface org.apache.commons.configuration.Configuration

getList

public java.util.List getList(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getList in interface org.apache.commons.configuration.Configuration

getLong

public long getLong(java.lang.String key,
                    long defaultValue)
Delegates to the underlying configuration.

Specified by:
getLong in interface org.apache.commons.configuration.Configuration

getLong

public java.lang.Long getLong(java.lang.String key,
                              java.lang.Long defaultValue)
Delegates to the underlying configuration.

Specified by:
getLong in interface org.apache.commons.configuration.Configuration

getLong

public long getLong(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getLong in interface org.apache.commons.configuration.Configuration

getProperties

public java.util.Properties getProperties(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getProperties in interface org.apache.commons.configuration.Configuration

getProperty

public java.lang.Object getProperty(java.lang.String arg0)
Delegates to the underlying configuration.

Specified by:
getProperty in interface org.apache.commons.configuration.Configuration

getShort

public short getShort(java.lang.String key,
                      short defaultValue)
Delegates to the underlying configuration.

Specified by:
getShort in interface org.apache.commons.configuration.Configuration

getShort

public java.lang.Short getShort(java.lang.String key,
                                java.lang.Short defaultValue)
Delegates to the underlying configuration.

Specified by:
getShort in interface org.apache.commons.configuration.Configuration

getShort

public short getShort(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getShort in interface org.apache.commons.configuration.Configuration

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String defaultValue)
Delegates to the underlying configuration.

Specified by:
getString in interface org.apache.commons.configuration.Configuration

getString

public java.lang.String getString(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getString in interface org.apache.commons.configuration.Configuration

getStringArray

public java.lang.String[] getStringArray(java.lang.String key)
Delegates to the underlying configuration.

Specified by:
getStringArray in interface org.apache.commons.configuration.Configuration

isEmpty

public boolean isEmpty()
Delegates to the underlying configuration.

Specified by:
isEmpty in interface org.apache.commons.configuration.Configuration

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object value)
Delegates to the underlying configuration.

Specified by:
setProperty in interface org.apache.commons.configuration.Configuration

subset

public org.apache.commons.configuration.Configuration subset(java.lang.String prefix)
Delegates to the underlying configuration.

Specified by:
subset in interface org.apache.commons.configuration.Configuration