本文整理汇总了Java中com.typesafe.config.ConfigUtil类的典型用法代码示例。如果您正苦于以下问题:Java ConfigUtil类的具体用法?Java ConfigUtil怎么用?Java ConfigUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigUtil类属于com.typesafe.config包,在下文中一共展示了ConfigUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPoint
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
/**
* This method is used to create all actual scheduler implementations.
* Change the behavior here to change whatever type of scheduler is actually
* used.
*/
private static Scheduler createPoint(String schedulerName) {
Config config = ConfigFactory.load();
// The default scheduler type to use
String schedulerType = config.getString(DEFAULT_SCHEDULER_KEY);
// Check to see whether this named throttling point is individually
// configured
String customConfigPath = ConfigUtil.joinPath(schedulerName);
if (config.getConfig(CUSTOM_SCHEDULERS_KEY).hasPath(customConfigPath)) {
schedulerType = config.getConfig(CUSTOM_SCHEDULERS_KEY).getString(customConfigPath);
}
// Get the instance and throw an exception if incorrectly configured
Scheduler instance = getSchedulerInstance(schedulerType, schedulerName);
if (instance == null) {
throw new IllegalArgumentException("Invalid throttling point type for " + schedulerName + ": " + schedulerType);
}
return instance;
}
示例2: createPoint
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
/**
* This method is used to create all actual throttling point
* implementations. Change the behavior here to change whatever type of
* throttling point is actually used.
*/
private static ThrottlingPoint createPoint(String throttlingPointName) {
Config config = ConfigFactory.load();
// The default throttling point type to use
String throttlingPointType = config.getString(DEFAULT_THROTTLINGPOINT_PROPERTY_KEY);
// Check to see whether this named throttling point is individually
// configured
String customConfigPath = ConfigUtil.joinPath(throttlingPointName);
if (config.getConfig(CUSTOM_THROTTLINGPOINT_KEY_PREFIX).hasPath(customConfigPath)) {
throttlingPointType = config.getConfig(CUSTOM_THROTTLINGPOINT_KEY_PREFIX).getString(customConfigPath);
}
// Get the instance and throw an exception if incorrectly configured
ThrottlingPoint instance = getThrottlingPointInstance(throttlingPointType, throttlingPointName);
if (instance == null) {
throw new IllegalArgumentException("Invalid throttling point type for " + throttlingPointName + ": " + throttlingPointType);
}
return instance;
}
示例3: createQueue
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
/**
* This method is used to create all actual throttling point
* implementations. Change the behavior here to change whatever type of
* throttling point is actually used.
*/
private static <T> ThrottlingQueue<T> createQueue(String throttlingQueueName) {
Config config = ConfigFactory.load();
// The default throttling point type to use
String throttlingQueueType = config.getString(DEFAULT_THROTTLINGQUEUE_PROPERTY_KEY);
// Check to see whether this named throttling point is individually
// configured
String customConfigPath = ConfigUtil.joinPath(throttlingQueueName);
if (config.getConfig(CUSTOM_THROTTLINGQUEUE_KEY_PREFIX).hasPath(customConfigPath)) {
throttlingQueueType = config.getConfig(CUSTOM_THROTTLINGQUEUE_KEY_PREFIX).getString(customConfigPath);
}
// Get the instance and throw an exception if incorrectly configured
ThrottlingQueue<T> instance = getThrottlingQueueInstance(throttlingQueueType, throttlingQueueName);
if (instance == null) {
throw new IllegalArgumentException("Invalid throttling queue type for " + throttlingQueueName + ": " + throttlingQueueType);
}
return instance;
}
示例4: testHazelcastConfigFactory
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
/**
* Test of hazelcastConfigFactory method, of class HazelcastConfigFactory.
*/
@Test
public void testHazelcastConfigFactory() {
LOG.info("hazelcastConfigFactory");
String hazelcastInstanceName = "testHazelcastConfigFactory";
final HazelcastConfigFactory factory1 = HazelcastConfigFactory.hazelcastConfigFactory(hazelcastInstanceName + 1);
final com.hazelcast.config.Config hazelcastConfig1 = factory1.apply(config.getConfig(ConfigUtil.joinPath("Hazelcast", "application-1")));
final HazelcastInstance hazelcast1 = Hazelcast.newHazelcastInstance(hazelcastConfig1);
final HazelcastConfigFactory factory2 = HazelcastConfigFactory.hazelcastConfigFactory(hazelcastInstanceName + 2);
final com.hazelcast.config.Config hazelcastConfig2 = factory2.apply(config.getConfig(ConfigUtil.joinPath("Hazelcast", "application-2")));
final HazelcastInstance hazelcast2 = Hazelcast.newHazelcastInstance(hazelcastConfig2);
test(hazelcast1, hazelcast2);
}
示例5: internalExtractURIQueryParams
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
private void internalExtractURIQueryParams(String paramName, String url, List expected, int maxParams) throws Exception {
String fileName = "test-morphlines/extractURIQueryParameters";
String overridesStr = "queryParam : " + ConfigUtil.quoteString(paramName);
if (maxParams >= 0) {
fileName += "WithMaxParameters";
overridesStr += "\nmaxParameters : " + maxParams;
}
Config override = ConfigFactory.parseString(overridesStr);
morphline = createMorphline(fileName, override);
Record record = new Record();
record.put("in", url);
Record expectedRecord = new Record();
expectedRecord.put("in", url);
expectedRecord.getFields().putAll("out", expected);
processAndVerifySuccess(record, expectedRecord);
}
示例6: put
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
private static void put(com.typesafe.config.Config typesafeConfig, Config destination,
ParsingMode parsingMode) {
for (Map.Entry<String, ConfigValue> entry : typesafeConfig.entrySet()) {
List<String> path = ConfigUtil.splitPath(entry.getKey());
parsingMode.put(destination, path, unwrap(entry.getValue().unwrapped()));
}
}
示例7: configPath
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
static String configPath(final String name, final String... names) {
checkArgument(StringUtils.isNotBlank(name));
if (ArrayUtils.isNotEmpty(names)) {
return ConfigUtil.joinPath(ImmutableList.<String>builder().add(name).add(names).build());
}
return name;
}
示例8: testHazelcastConfigFactory_withSerializers
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
/**
* Test of hazelcastConfigFactory method, of class HazelcastConfigFactory.
*/
@Test
public void testHazelcastConfigFactory_withSerializers() {
LOG.info("hazelcastConfigFactory");
String hazelcastInstanceName = "testHazelcastConfigFactory_withSerializers";
final Set<SerializerConfig> serializerConfigs = ImmutableSet.of(
new SerializerConfig().setImplementation(new JsonObjectSerializer()).setTypeClass(JsonObject.class)
);
final HazelcastConfigFactory factory1 = HazelcastConfigFactory.hazelcastConfigFactory(hazelcastInstanceName + 1, serializerConfigs);
final com.hazelcast.config.Config hazelcastConfig1 = factory1.apply(config.getConfig(ConfigUtil.joinPath("Hazelcast", "application-1")));
final HazelcastInstance hazelcast1 = Hazelcast.newHazelcastInstance(hazelcastConfig1);
final HazelcastConfigFactory factory2 = HazelcastConfigFactory.hazelcastConfigFactory(hazelcastInstanceName + 2, serializerConfigs);
final com.hazelcast.config.Config hazelcastConfig2 = factory2.apply(config.getConfig(ConfigUtil.joinPath("Hazelcast", "application-2")));
final HazelcastInstance hazelcast2 = Hazelcast.newHazelcastInstance(hazelcastConfig2);
test(hazelcast1, hazelcast2);
final JsonObject json = Json.createObjectBuilder().add("a", 1).build();
final String mapName = "testHazelcastConfigFactory_withSerializers_map";
final Map<String, Object> map1 = hazelcast1.getMap(mapName);
map1.put("json", json);
final Map<String, Object> map2 = hazelcast2.getMap(mapName);
final JsonObject json2 = (JsonObject) map2.get("json");
assertThat(json2.getInt("a"), is(1));
}
示例9: testGetHazelcastConfig
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
/**
* Test of getHazelcastConfig method, of class TypesafeHazelcastConfig.
*/
@Test
public void testGetHazelcastConfig() {
System.out.println("getConfig");
final TypesafeHazelcastConfig typesafeHazelcastConfig = new TypesafeHazelcastConfig("testGetConfig", config.getConfig(ConfigUtil.joinPath("Hazelcast", "application-1")));
final Config hazelcastConfig = typesafeHazelcastConfig.getHazelcastConfig();
assertThat(hazelcastConfig, is(notNullValue()));
assertThat(hazelcastConfig.getInstanceName(), is("testGetConfig"));
}
示例10: setStringToConfig
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
/**
* Sets the String value for current configuration's variable to config.
*
* @param key
* The name of settings section.
* @param subKey
* The name of needed variable.
* @param value
* The value to set.
*/
private static void setStringToConfig(String key, String subKey, String newValue,
boolean hideValue) {
String fullPath = MAINKEY + "." + key + "." + subKey;
if (getString(key, subKey).equals(newValue)) {
String messageToLog = hideValue
? String.format("Setting secret configuration value. Key: %s.%s", key, subKey)
: String.format("Configuration value unchanged. Key: %s.%s Value: %s", key,
subKey, newValue);
logger.info(messageToLog);
return;
}
String processedNewValue = ConfigUtil.quoteString(newValue);
// Lets make new Config object with just a single variable.
// Also lets preserve the comments from the original Config.
ConfigOrigin or = conf.getValue(fullPath).origin();
StringBuilder toParse = new StringBuilder();
for (String comment : or.comments()) {
toParse.append("#").append(comment).append("\n");
}
toParse.append(fullPath).append("=").append(processedNewValue);
Config newLittleConfig = ConfigFactory.parseString(toParse.toString());
// Now we have our little Config with the single variable and old comments.
// Let's merge it with the old Config.
conf = newLittleConfig.withFallback(conf);
if (!hideValue) {
logger.info(String.format("Configuration update in RAM. Key: %s.%s Value: %s", key, subKey, newValue));
}
needsSave = true;
}
示例11: toJson
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
private String toJson(Object key) {
String str = key == null ? "" : key.toString();
str = ConfigUtil.quoteString(str);
return str;
}
示例12: names
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
private Iterable<String> names(final Config conf) {
Set<String> result = new LinkedHashSet<>();
conf.root().forEach((k, v) -> result.add(ConfigUtil.splitPath(k).get(0)));
return result;
}
示例13: set
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
public static Configuration set(Configuration configuration, ServerInetAddressView value) {
Configurable configurable = getConfigurable();
return configuration.withConfig(ConfigFactory.parseMap(ImmutableMap.<String,Object>builder().put(ConfigUtil.joinPath(configurable.path(), configurable.arg()), value.toString()).build()));
}
示例14: set
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
public static Configuration set(Configuration configuration, EnsembleView<ServerInetAddressView> value) {
Configurable configurable = getConfigurable();
return configuration.withConfig(ConfigFactory.parseMap(ImmutableMap.<String,Object>builder().put(ConfigUtil.joinPath(configurable.path(), configurable.arg()), EnsembleView.toString(value)).build()));
}
示例15: set
import com.typesafe.config.ConfigUtil; //导入依赖的package包/类
public static Configuration set(Configuration configuration, EnsembleView<ServerInetAddressView> value) {
Configurable configurable = getConfigurable();
return configuration.withConfig(ConfigFactory.parseMap(ImmutableMap.<String,Object>builder().put(ConfigUtil.joinPath(configurable.path(), configurable.key()), EnsembleView.toString(value)).build()));
}