List of usage examples for org.apache.commons.configuration Configuration getProperty
Object getProperty(String key);
From source file:com.twitter.distributedlog.config.ConfigTestUtil.java
static void waitForConfig(Configuration conf, String name, String value) throws Exception { while (!Objects.equal(conf.getProperty(name), value)) { Thread.sleep(100);//ww w. j av a 2 s . c o m } }
From source file:com.comcast.viper.flume2storm.F2SConfigurationException.java
/** * @param config//from w ww . j a va 2s. c om * The configuration that contains the invalid parameter * @param parameter * The name of the configuration parameter that is invalid * @param throwable * The exception that occurred when setting the parameter's value * @return The newly built F2SConfigurationException related to a specific * invalid parameter */ public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) { return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable); }
From source file:it.geosolutions.httpproxy.utils.Utils.java
/** * Obtain a property value as Set of String from a properties configuration * //from w w w. ja v a 2 s .co m * @param props * @param key * * @return Set with all values as String or null if the key can't be found */ public static final Set<String> getProperty(Configuration props, String key) { Object tmpProperty = props.getProperty(key); if (tmpProperty != null) { Set<String> set = new HashSet<String>(); if (tmpProperty instanceof Collection<?>) { for (Object tmpElement : (Collection<?>) tmpProperty) { if (tmpElement != null) { String element = tmpElement.toString(); set.add(element); } } } else { set.add(tmpProperty.toString()); } return set; } else { return null; } }
From source file:io.servicecomb.config.ConfigUtil.java
public static DynamicWatchedConfiguration createConfigFromConfigCenter(Configuration localConfiguration) { if (localConfiguration.getProperty(configCenterUrlKey) == null) { LOGGER.info("config center URL is missing, skip to load configuration from config center"); return null; }/*from w w w .jav a 2 s.c o m*/ ConfigCenterConfigurationSource configCenterConfigurationSource = SPIServiceUtils .getTargetService(ConfigCenterConfigurationSource.class); if (null == configCenterConfigurationSource) { LOGGER.info("config center SPI service can not find, skip to load configuration from config center"); return null; } configCenterConfigurationSource.init(localConfiguration); return new DynamicWatchedConfiguration(configCenterConfigurationSource); }
From source file:com.kixeye.chassis.bootstrap.configuration.Configurations.java
public static Map<String, ?> asMap(Configuration configuration) { Map<String, Object> config = new TreeMap<>(); Iterator<String> keys = configuration.getKeys(); while (keys.hasNext()) { String key = keys.next(); config.put(key, configuration.getProperty(key)); }// w w w .j a v a 2s.c om return config; }
From source file:io.servicecomb.config.ConfigUtil.java
public static Object getProperty(Object config, String key) { if (null != config && Configuration.class.isInstance(config)) { Configuration configuration = (Configuration) config; return configuration.getProperty(key); }/*from ww w. ja v a 2 s.c om*/ return null; }
From source file:com.germinus.easyconf.ConfUtil.java
public static String toString(Configuration configuration) { Iterator it = configuration.getKeys(); StringBuffer result = new StringBuffer(); result.append("{"); while (it.hasNext()) { String key = (String) it.next(); result.append(key + "=" + configuration.getProperty(key)); result.append(", "); }/* ww w.j a v a 2 s . c o m*/ result.append("}"); return result.toString(); }
From source file:net.sf.zekr.common.util.ConfigUtils.java
@SuppressWarnings("unchecked") public static void write(Configuration configuration, Writer w) throws IOException { Iterator keys = configuration.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); Object value = configuration.getProperty(key); w.write(key);// w ww. j ava 2 s . c o m w.write(" = "); if (value instanceof Collection) { w.write(CollectionUtils.toString((List) value, ", ")); } else { w.write(ObjectUtils.toString(value)); } if (keys.hasNext()) { w.write(GlobalConfig.LINE_SEPARATOR); } } }
From source file:com.xemantic.tadedon.guice.configuration.GuiceConfigurations.java
public static void bindProperties(Binder binder, Configuration configuration) { for (@SuppressWarnings("unchecked") Iterator<String> iterator = configuration.getKeys(); iterator.hasNext();) { String key = iterator.next(); Object property = configuration.getProperty(key); if (property instanceof String) { String value = (String) property; binder.bindConstant().annotatedWith(Names.named(key)).to(value); } else if (property instanceof Collection) { List<String> list = new ArrayList<String>((Collection) property); binder.bind(new TypeLiteral<List<String>>() { }).annotatedWith(Names.named(key)).toInstance(list); } else {/*from ww w.jav a 2 s .c o m*/ throw new UnsupportedPropertyTypeExeception(property.getClass()); } } }
From source file:com.linkedin.pinot.broker.broker.helix.DefaultHelixBrokerConfig.java
public static Configuration getDefaultBrokerConf(Configuration externalConfigs) { final Configuration defaultConfigs = getDefaultBrokerConf(); @SuppressWarnings("unchecked") Iterator<String> iterable = externalConfigs.getKeys(); while (iterable.hasNext()) { String key = iterable.next(); defaultConfigs.setProperty(key, externalConfigs.getProperty(key)); }/*from w w w .ja v a 2 s. c o m*/ return defaultConfigs; }