当前位置: 首页>>代码示例>>Java>>正文


Java Config.getConfig方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:florentw,项目名称:bench,代码行数:25,代码来源:ClusterClients.java

示例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();
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:17,代码来源:PackageMetadataReader.java

示例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));
        }
    }
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:13,代码来源:MetricServiceConfiguration.java

示例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);
        }
    }
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:15,代码来源:MemoryReporterServiceConfiguration.java

示例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());
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:10,代码来源:ConfigurationRegistry.java

示例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;
            }
        }
    }
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:33,代码来源:InputConfiguration.java

示例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"));
}
 
开发者ID:Lambda-3,项目名称:Graphene,代码行数:9,代码来源:CoreferenceTest.java

示例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;
}
 
开发者ID:conf4j,项目名称:conf4j,代码行数:14,代码来源:RootConfigurationProvider.java

示例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);
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:11,代码来源:ParamReader.java

示例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);
}
 
开发者ID:florentw,项目名称:bench,代码行数:7,代码来源:AgentConfig.java

示例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"));
}
 
开发者ID:oneops,项目名称:secrets-cli,代码行数:6,代码来源:SecretsProxyConfig.java

示例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}}
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:48,代码来源:TypesafeConfigExamples.java

示例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;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:42,代码来源:MemberNode.java


注:本文中的com.typesafe.config.Config.getConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。