|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.commons.configuration.event.EventSource
org.apache.commons.configuration.AbstractConfiguration
com.netflix.config.ConcurrentMapConfiguration
public class ConcurrentMapConfiguration
This class uses a ConcurrentHashMap for reading/writing a property to achieve high
throughput and thread safety. The implementation is lock free for getProperty(String)
and setProperty(String, Object), but has some synchronization cost for
addProperty(String, Object) if the object to add is not a String or the key already exists.
The methods from AbstractConfiguration related to listeners and event generation are overridden so that adding/deleting listeners and firing events are no longer synchronized. Also, it catches Throwable when it invokes the listeners, making it more robust.
This configuration does not allow null as key or value and will throw NullPointerException when trying to add or set properties with empty key or value.
| Field Summary | |
|---|---|
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object> |
map
|
| Fields inherited from class org.apache.commons.configuration.AbstractConfiguration |
|---|
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN |
| Constructor Summary | |
|---|---|
ConcurrentMapConfiguration()
Create an instance with an empty map. |
|
ConcurrentMapConfiguration(org.apache.commons.configuration.Configuration config)
Create an instance by copying the properties from an existing Configuration. |
|
ConcurrentMapConfiguration(java.util.Map<java.lang.String,java.lang.Object> mapToCopy)
|
|
| Method Summary | |
|---|---|
void |
addConfigurationListener(org.apache.commons.configuration.event.ConfigurationListener l)
|
void |
addErrorListener(org.apache.commons.configuration.event.ConfigurationErrorListener l)
|
void |
addProperty(java.lang.String key,
java.lang.Object value)
|
protected void |
addPropertyDirect(java.lang.String key,
java.lang.Object value)
|
protected void |
addPropertyImpl(java.lang.String key,
java.lang.Object value)
|
void |
clear()
Clear the map and fire corresonding events. |
void |
clearConfigurationListeners()
|
void |
clearErrorListeners()
|
protected void |
clearPropertyDirect(java.lang.String key)
|
boolean |
containsKey(java.lang.String key)
|
void |
copy(org.apache.commons.configuration.Configuration c)
Copy properties of a configuration into this configuration. |
protected void |
fireError(int type,
java.lang.String propName,
java.lang.Object propValue,
java.lang.Throwable ex)
Creates an error event and calls ConfigurationErrorListener.configurationError(ConfigurationErrorEvent)
for all listeners while catching Throwable. |
protected void |
fireEvent(int type,
java.lang.String propName,
java.lang.Object propValue,
boolean beforeUpdate)
Creates an event and calls ConfigurationListener.configurationChanged(ConfigurationEvent)
for all listeners while catching Throwable. |
java.util.Collection<org.apache.commons.configuration.event.ConfigurationListener> |
getConfigurationListeners()
|
java.util.Collection<org.apache.commons.configuration.event.ConfigurationErrorListener> |
getErrorListeners()
|
java.util.Iterator |
getKeys()
|
java.util.Properties |
getProperties()
Utility method to get a Properties object from this Configuration |
java.lang.Object |
getProperty(java.lang.String key)
|
boolean |
isEmpty()
|
void |
loadProperties(java.util.Properties props)
Load properties into the configuration. |
boolean |
removeConfigurationListener(org.apache.commons.configuration.event.ConfigurationListener l)
|
boolean |
removeErrorListener(org.apache.commons.configuration.event.ConfigurationErrorListener l)
|
void |
setProperty(java.lang.String key,
java.lang.Object value)
Override the same method in AbstractConfiguration to simplify the logic
to avoid multiple events being generated. |
protected void |
setPropertyImpl(java.lang.String key,
java.lang.Object value)
|
| Methods inherited from class org.apache.commons.configuration.AbstractConfiguration |
|---|
addErrorLogListener, append, clearProperty, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getList, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, getSubstitutor, interpolate, interpolate, interpolatedConfiguration, interpolateHelper, isDelimiterParsingDisabled, isScalarValue, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setLogger, setThrowExceptionOnMissing, subset |
| Methods inherited from class org.apache.commons.configuration.event.EventSource |
|---|
clone, createErrorEvent, createEvent, isDetailEvents, setDetailEvents |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object> map
| Constructor Detail |
|---|
public ConcurrentMapConfiguration()
public ConcurrentMapConfiguration(java.util.Map<java.lang.String,java.lang.Object> mapToCopy)
public ConcurrentMapConfiguration(org.apache.commons.configuration.Configuration config)
config - Configuration to be copied| Method Detail |
|---|
public java.lang.Object getProperty(java.lang.String key)
protected void addPropertyDirect(java.lang.String key,
java.lang.Object value)
addPropertyDirect in class org.apache.commons.configuration.AbstractConfigurationpublic boolean isEmpty()
public boolean containsKey(java.lang.String key)
protected void clearPropertyDirect(java.lang.String key)
clearPropertyDirect in class org.apache.commons.configuration.AbstractConfigurationpublic java.util.Iterator getKeys()
public void addProperty(java.lang.String key,
java.lang.Object value)
addProperty in interface org.apache.commons.configuration.ConfigurationaddProperty in class org.apache.commons.configuration.AbstractConfiguration
protected void addPropertyImpl(java.lang.String key,
java.lang.Object value)
public void setProperty(java.lang.String key,
java.lang.Object value)
AbstractConfiguration to simplify the logic
to avoid multiple events being generated. It calls clearPropertyDirect(String)
followed by logic to add the property including calling addPropertyDirect(String, Object).
setProperty in interface org.apache.commons.configuration.ConfigurationsetProperty in class org.apache.commons.configuration.AbstractConfiguration
protected void setPropertyImpl(java.lang.String key,
java.lang.Object value)
public void loadProperties(java.util.Properties props)
setProperty(String, Object) for
non-null key/value.
public void copy(org.apache.commons.configuration.Configuration c)
setProperty(String, Object)
for non-null key/value.
copy in class org.apache.commons.configuration.AbstractConfigurationpublic void clear()
clear in interface org.apache.commons.configuration.Configurationclear in class org.apache.commons.configuration.AbstractConfigurationpublic java.util.Properties getProperties()
protected void fireEvent(int type,
java.lang.String propName,
java.lang.Object propValue,
boolean beforeUpdate)
ConfigurationListener.configurationChanged(ConfigurationEvent)
for all listeners while catching Throwable.
fireEvent in class org.apache.commons.configuration.event.EventSourcepublic void addConfigurationListener(org.apache.commons.configuration.event.ConfigurationListener l)
addConfigurationListener in class org.apache.commons.configuration.event.EventSourcepublic void addErrorListener(org.apache.commons.configuration.event.ConfigurationErrorListener l)
addErrorListener in class org.apache.commons.configuration.event.EventSourcepublic void clearConfigurationListeners()
clearConfigurationListeners in class org.apache.commons.configuration.event.EventSourcepublic void clearErrorListeners()
clearErrorListeners in class org.apache.commons.configuration.event.EventSourcepublic java.util.Collection<org.apache.commons.configuration.event.ConfigurationListener> getConfigurationListeners()
getConfigurationListeners in class org.apache.commons.configuration.event.EventSourcepublic java.util.Collection<org.apache.commons.configuration.event.ConfigurationErrorListener> getErrorListeners()
getErrorListeners in class org.apache.commons.configuration.event.EventSourcepublic boolean removeConfigurationListener(org.apache.commons.configuration.event.ConfigurationListener l)
removeConfigurationListener in class org.apache.commons.configuration.event.EventSourcepublic boolean removeErrorListener(org.apache.commons.configuration.event.ConfigurationErrorListener l)
removeErrorListener in class org.apache.commons.configuration.event.EventSource
protected void fireError(int type,
java.lang.String propName,
java.lang.Object propValue,
java.lang.Throwable ex)
ConfigurationErrorListener.configurationError(ConfigurationErrorEvent)
for all listeners while catching Throwable.
fireError in class org.apache.commons.configuration.event.EventSource
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||