當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。