protected void putDefaultTimeUnitProperty(IClientConfigKey propName, TimeUnit defaultValue) { TimeUnit value = defaultValue; String propValue = ConfigurationManager.getConfigInstance().getString(getDefaultPropName(propName)); if (propValue != null && propValue.length() > 0) { value = TimeUnit.valueOf(propValue); } setPropertyInternal(propName, value); }
public IClientConfig applyOverride(IClientConfig override) { if (override == null) { return this; } Map<String, Object> props = override.getProperties(); for (Map.Entry<String, Object> entry : props.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { setPropertyInternal(key, value); } } return this; }
/** * Load properties for a given client. It first loads the default values for all properties, and * any properties already defined with Archaius ConfigurationManager. */ @Override public void loadProperties(String restClientName) { enableDynamicProperties = true; setClientName(restClientName); loadDefaultValues(); Configuration props = ConfigurationManager.getConfigInstance().subset(restClientName); for (Iterator<String> keys = props.getKeys(); keys.hasNext(); ) { String key = keys.next(); String prop = key; try { if (prop.startsWith(getNameSpace())) { prop = prop.substring(getNameSpace().length() + 1); } setPropertyInternal(prop, getStringValue(props, key)); } catch (Exception ex) { throw new RuntimeException(String.format("Property %s is invalid", prop)); } } }
/* (non-Javadoc) * @see com.netflix.niws.client.CliengConfig#setProperty(com.netflix.niws.client.ClientConfigKey, java.lang.Object) */ @Override public void setProperty(IClientConfigKey key, Object value) { setPropertyInternal(key.key(), value); }
protected void putDefaultBooleanProperty(IClientConfigKey propName, Boolean defaultValue) { Boolean value = ConfigurationManager.getConfigInstance() .getBoolean(getDefaultPropName(propName), defaultValue); setPropertyInternal(propName, value); }
protected void putDefaultStringProperty(IClientConfigKey propName, String defaultValue) { String value = ConfigurationManager.getConfigInstance() .getString(getDefaultPropName(propName), defaultValue); setPropertyInternal(propName, value); }
protected void putDefaultFloatProperty(IClientConfigKey propName, Float defaultValue) { Float value = ConfigurationManager.getConfigInstance() .getFloat(getDefaultPropName(propName), defaultValue); setPropertyInternal(propName, value); }
// Helper methods which first check if a "default" (with rest client name) // property exists. If so, that value is used, else the default value // passed as argument is used to put into the properties member variable protected void putDefaultIntegerProperty(IClientConfigKey propName, Integer defaultValue) { Integer value = ConfigurationManager.getConfigInstance() .getInteger(getDefaultPropName(propName), defaultValue); setPropertyInternal(propName, value); }
protected void setPropertyInternal(IClientConfigKey propName, Object value) { setPropertyInternal(propName.key(), value); }