本文整理汇总了Java中com.typesafe.config.Config.getConfig方法的典型用法代码示例。如果您正苦于以下问题:Java Config.getConfig方法的具体用法?Java Config.getConfig怎么用?Java Config.getConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.typesafe.config.Config
的用法示例。
在下文中一共展示了Config.getConfig方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newFactory
import com.typesafe.config.Config; //导入方法依赖的package包/类
public static <T> T newFactory(@NotNull final Class<T> clusterClientInterface,
@NotNull final Config clusterConfig,
@NotNull final ActorRegistry actorRegistry) {
requireNonNull(clusterClientInterface);
requireNonNull(clusterConfig);
requireNonNull(actorRegistry);
String factoryClassName = clusterConfig.getString(FACTORY_CLASS);
Config factoryConfig = clusterConfig.getConfig(FACTORY_CONFIG);
MutablePicoContainer container = new DefaultPicoContainer();
container.addComponent(factoryConfig);
container.addComponent(actorRegistry);
try {
Class<? extends T> factoryClass = Class.forName(factoryClassName) // NOSONAR
.asSubclass(clusterClientInterface); // NOSONAR
container.addComponent(factoryClass);
return container.getComponent(factoryClass);
} catch (ClassNotFoundException e) {
throw propagate(e);
}
}
示例2: getSourceEncodings
import com.typesafe.config.Config; //导入方法依赖的package包/类
private ImmutableMap<String, String> getSourceEncodings(Config metadataConfig) {
if (metadataConfig.hasPath("sourceEncodings")) {
Config sourceEncodings = metadataConfig.getConfig("sourceEncodings");
MutableMap<String, String> encodingsMap = Maps.mutable.empty();
for (String encoding : sourceEncodings.root().keySet()) {
String fileList = sourceEncodings.getString(encoding);
for (String file : fileList.split(",")) {
encodingsMap.put(file, encoding);
}
}
return encodingsMap.toImmutable();
}
return Maps.immutable.empty();
}
示例3: MetricServiceConfiguration
import com.typesafe.config.Config; //导入方法依赖的package包/类
@Inject
public MetricServiceConfiguration(Config config) {
if (config.hasPath("metrics")) {
final Config metrics = config.getConfig("metrics");
this.enableLog = metrics.hasPath("enable-logging") && metrics.getBoolean("enable-logging");
if (metrics.hasPath("log-duration")) {
this.reportDuration = new Duration(metrics.getDuration("log-duration", TimeUnit.MILLISECONDS));
}
}
}
示例4: MemoryReporterServiceConfiguration
import com.typesafe.config.Config; //导入方法依赖的package包/类
@Inject
public MemoryReporterServiceConfiguration(final Config config) {
if (config.hasPath("debug")) {
final Config debug = config.getConfig("debug");
if (debug.hasPath("memory-reporter")) {
this.enable = debug.getBoolean("memory-reporter");
}
if (debug.hasPath("memory-reporter-interval")) {
this.interval = debug.getDuration("memory-reporter-interval", TimeUnit.MILLISECONDS);
}
}
}
示例5: processConfig
import com.typesafe.config.Config; //导入方法依赖的package包/类
private void processConfig(Config config) {
final Config inputs = config.getConfig("inputs");
final Config outputs = config.getConfig("outputs");
buildInputs(inputs);
buildOutputs(outputs);
errors.addAll(validator.getErrors());
}
示例6: InputConfiguration
import com.typesafe.config.Config; //导入方法依赖的package包/类
public InputConfiguration(String id, Config config) {
this.id = id;
if (config.hasPath("outputs")) {
this.outputs = Sets.newHashSet(Splitter.on(",").omitEmptyStrings().trimResults().split(config.getString("outputs")));
}
if (config.hasPath("message-fields")) {
final Config messageFieldsConfig = config.getConfig("message-fields");
for (Map.Entry<String, ConfigValue> entry : messageFieldsConfig.entrySet()) {
final String key = entry.getKey();
final ConfigValue value = entry.getValue();
switch (value.valueType()) {
case NUMBER:
this.messageFields.put(key, messageFieldsConfig.getNumber(key));
break;
case BOOLEAN:
this.messageFields.put(key, messageFieldsConfig.getBoolean(key));
break;
case STRING:
this.messageFields.put(key, messageFieldsConfig.getString(key));
break;
default:
log.warn("{}[{}] Message field value of type \"{}\" is not supported for key \"{}\" (value: {})",
getClass().getSimpleName(), getId(), value.valueType(), key, value.toString());
break;
}
}
}
}
示例7: beforeAll
import com.typesafe.config.Config; //导入方法依赖的package包/类
@BeforeClass
public static void beforeAll() {
Config config = ConfigFactory
.load("reference.local")
.withFallback(ConfigFactory.load("reference"));
coreference = new Coreference(config.getConfig("graphene.coreference"));
}
示例8: loadConfiguration
import com.typesafe.config.Config; //导入方法依赖的package包/类
private T loadConfiguration() {
Config config = configurationSource.getConfig().resolve();
if (!configRootPath.equals(EMPTY_STRING)) {
config = config.getConfig(configRootPath);
}
configurationExtensions.beforeTypeConversion(config, configurationClass);
Map<String, Object> configMap = config.root().unwrapped();
T configurationBean = mapper.convertValue(configMap, configurationClass);
configurationExtensions.afterConfigBeanAssembly(configurationBean);
return configurationBean;
}
示例9: populateConfig
import com.typesafe.config.Config; //导入方法依赖的package包/类
private static void populateConfig(Config config, MutableMap<String, Object> params, String attr) {
if (config.hasPath(attr)) {
Config attrs = config.getConfig(attr);
MutableMap<String, String> attrsMap = Maps.mutable.empty();
for (String key : attrs.root().keySet()) {
attrsMap.put(key, config.getString(attr + "." + key));
}
params.put(attr, attrsMap);
}
}
示例10: AgentConfig
import com.typesafe.config.Config; //导入方法依赖的package包/类
public AgentConfig(final File configFile) {
requireNonNull(configFile);
Config agentConfig = ConfigFactory.parseFile(configFile);
clusterConfig = agentConfig.getConfig(AGENT_CLUSTER_TAG);
}
示例11: SecretsProxyConfig
import com.typesafe.config.Config; //导入方法依赖的package包/类
public SecretsProxyConfig(Config config) {
this.baseUrl = config.getString("secretsProxy.baseUrl");
this.timeout = config.getInt("secretsProxy.timeout");
this.trustStore = new KeyStoreConfig(config.getConfig("secretsProxy.truststore"));
}
示例12: main
import com.typesafe.config.Config; //导入方法依赖的package包/类
public static void main(String[] args) {
// {{start:resource}}
Config defaultConfig = ConfigFactory.parseResources("defaults.conf");
// {{end:resource}}
// {{start:fallback}}
Config fallbackConfig = ConfigFactory.parseResources("overrides.conf")
.withFallback(defaultConfig)
.resolve();
// {{end:fallback}}
// {{start:text}}
log.info("name: {}", defaultConfig.getString("conf.name"));
log.info("name: {}", fallbackConfig.getString("conf.name"));
log.info("title: {}", defaultConfig.getString("conf.title"));
log.info("title: {}", fallbackConfig.getString("conf.title"));
// {{end:text}}
// {{start:resolved}}
log.info("combined: {}", fallbackConfig.getString("conf.combined"));
// {{end:resolved}}
// {{start:durations}}
log.info("redis.ttl minutes: {}", fallbackConfig.getDuration("redis.ttl", TimeUnit.MINUTES));
log.info("redis.ttl seconds: {}", fallbackConfig.getDuration("redis.ttl", TimeUnit.SECONDS));
// {{end:durations}}
// {{start:memorySize}}
// Any path in the configuration can be treated as a separate Config object.
Config uploadService = fallbackConfig.getConfig("uploadService");
log.info("maxChunkSize bytes: {}", uploadService.getMemorySize("maxChunkSize").toBytes());
log.info("maxFileSize bytes: {}", uploadService.getMemorySize("maxFileSize").toBytes());
// {{end:memorySize}}
// {{start:whitelist}}
List<Integer> whiteList = fallbackConfig.getIntList("conf.nested.whitelistIds");
log.info("whitelist: {}", whiteList);
List<String> whiteListStrings = fallbackConfig.getStringList("conf.nested.whitelistIds");
log.info("whitelist as Strings: {}", whiteListStrings);
// {{end:whitelist}}
// {{start:booleans}}
log.info("yes: {}", fallbackConfig.getBoolean("featureFlags.featureA"));
log.info("true: {}", fallbackConfig.getBoolean("featureFlags.featureB"));
// {{end:booleans}}
}
示例13: build
import com.typesafe.config.Config; //导入方法依赖的package包/类
public MemberNode build() throws Exception {
Preconditions.checkNotNull(moduleShardsConfig, "moduleShardsConfig must be specified");
Preconditions.checkNotNull(akkaConfig, "akkaConfig must be specified");
Preconditions.checkNotNull(testName, "testName must be specified");
if (schemaContext == null) {
schemaContext = SchemaContextHelper.full();
}
MemberNode node = new MemberNode();
node.datastoreContextBuilder = datastoreContextBuilder;
Config baseConfig = ConfigFactory.load();
Config config;
if (useAkkaArtery) {
config = baseConfig.getConfig(akkaConfig);
} else {
config = baseConfig.getConfig(akkaConfig + "-without-artery")
.withFallback(baseConfig.getConfig(akkaConfig));
}
ActorSystem system = ActorSystem.create("cluster-test", config);
String member1Address = useAkkaArtery ? MEMBER_1_ADDRESS : MEMBER_1_ADDRESS.replace("akka", "akka.tcp");
Cluster.get(system).join(AddressFromURIString.parse(member1Address));
node.kit = new IntegrationTestKit(system, datastoreContextBuilder);
String memberName = new ClusterWrapperImpl(system).getCurrentMemberName().getName();
node.kit.getDatastoreContextBuilder().shardManagerPersistenceId("shard-manager-config-" + memberName);
node.configDataStore = node.kit.setupAbstractDataStore(DistributedDataStore.class,
"config_" + testName, moduleShardsConfig, true, schemaContext, waitForshardLeader);
if (createOperDatastore) {
node.kit.getDatastoreContextBuilder().shardManagerPersistenceId("shard-manager-oper-" + memberName);
node.operDataStore = node.kit.setupAbstractDataStore(DistributedDataStore.class,
"oper_" + testName, moduleShardsConfig, true, schemaContext, waitForshardLeader);
}
members.add(node);
return node;
}