當前位置: 首頁>>代碼示例>>Java>>正文


Java Config.getString方法代碼示例

本文整理匯總了Java中com.typesafe.config.Config.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java Config.getString方法的具體用法?Java Config.getString怎麽用?Java Config.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.typesafe.config.Config的用法示例。


在下文中一共展示了Config.getString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAppContext

import com.typesafe.config.Config; //導入方法依賴的package包/類
private static ListIterable<IntToObjectFunction<DbDeployerAppContext>> getAppContext(final Config config) {
    final String sourcePath = config.getString("sourcePath");
    String env = getStringOptional(config, "env");

    final String[] envArgs = env != null ? env.split(",") : new String[] { null };
    final String username = getStringOptional(config, "username");
    final String password = getStringOptional(config, "password");
    return ArrayAdapter.adapt(envArgs).collect(new Function<String, IntToObjectFunction<DbDeployerAppContext>>() {
        @Override
        public IntToObjectFunction<DbDeployerAppContext> valueOf(final String envArg) {
            return new IntToObjectFunction<DbDeployerAppContext>() {
                @Override
                public DbDeployerAppContext valueOf(int stepNumber) {
                    String stepSourcePath = replaceStepNumber(sourcePath, stepNumber, config);

                    DbEnvironment dbEnvironment = DbEnvironmentFactory.getInstance().readOneFromSourcePath(stepSourcePath, envArg != null ? new String[] {envArg} : new String[0]);
                    if (username != null && password != null) {
                        return dbEnvironment.buildAppContext(username, password);
                    } else {
                        return dbEnvironment.buildAppContext();
                    }
                }
            };
        }
    });
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:27,代碼來源:ParamReader.java

示例2: MLUpdate

import com.typesafe.config.Config; //導入方法依賴的package包/類
protected MLUpdate(Config config) {
  this.testFraction = config.getDouble("oryx.ml.eval.test-fraction");
  int candidates = config.getInt("oryx.ml.eval.candidates");
  this.evalParallelism = config.getInt("oryx.ml.eval.parallelism");
  this.threshold = ConfigUtils.getOptionalDouble(config, "oryx.ml.eval.threshold");
  this.maxMessageSize = config.getInt("oryx.update-topic.message.max-size");
  Preconditions.checkArgument(testFraction >= 0.0 && testFraction <= 1.0);
  Preconditions.checkArgument(candidates > 0);
  Preconditions.checkArgument(evalParallelism > 0);
  Preconditions.checkArgument(maxMessageSize > 0);
  if (testFraction == 0.0) {
    if (candidates > 1) {
      log.info("Eval is disabled (test fraction = 0) so candidates is overridden to 1");
      candidates = 1;
    }
  }
  this.candidates = candidates;
  this.hyperParamSearch = config.getString("oryx.ml.eval.hyperparam-search");
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:20,代碼來源:MLUpdate.java

示例3: apply

import com.typesafe.config.Config; //導入方法依賴的package包/類
/**
 * @param config      the akka configuration object
 * @param actorSystem the akk actor system
 * @return the created snapshot ignite cache
 */
@Override
public IgniteCache<Long, SnapshotItem> apply(Config config, ActorSystem actorSystem) {
    final IgniteExtension extension = IgniteExtensionProvider.EXTENSION.get(actorSystem);
    final String cachePrefix = config.getString(CACHE_PREFIX_PROPERTY);
    final int cacheBackups = config.getInt(CACHE_BACKUPS);
    final CacheConfiguration<Long, SnapshotItem> eventStore = new CacheConfiguration();
    eventStore.setCopyOnRead(false);
    if (cacheBackups > 0) {
        eventStore.setBackups(cacheBackups);
    } else {
        eventStore.setBackups(1);
    }
    eventStore.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    eventStore.setName(cachePrefix + "_SNAPSHOT");
    eventStore.setCacheMode(CacheMode.PARTITIONED);
    eventStore.setReadFromBackup(true);
    eventStore.setIndexedTypes(Long.class, SnapshotItem.class);
    eventStore.setIndexedTypes(String.class, SnapshotItem.class);
    return extension.getIgnite().getOrCreateCache(eventStore);
}
 
開發者ID:Romeh,項目名稱:akka-persistance-ignite,代碼行數:26,代碼來源:SnapshotCacheProvider.java

示例4: KafkaOutputConfiguration

import com.typesafe.config.Config; //導入方法依賴的package包/類
@Inject
public KafkaOutputConfiguration(@Assisted String id,
                                @Assisted Config config,
                                KafkaOutput.Factory outputFactory) {
    super(id, config);
    this.outputFactory = outputFactory;
    if (config.hasPath("host")) {
        this.host = config.getString("host");
    }
    if (config.hasPath("topic")) {
        this.topic = config.getString("topic");
    }
    if (config.hasPath("port")) {
        this.port = config.getInt("port");
    }
}
 
開發者ID:DevOpsStudio,項目名稱:Re-Collector,代碼行數:17,代碼來源:KafkaOutputConfiguration.java

示例5: WindowsEventlogInputConfiguration

import com.typesafe.config.Config; //導入方法依賴的package包/類
@Inject
public WindowsEventlogInputConfiguration(@Assisted String id,
                                         @Assisted Config config,
                                         WindowsEventlogInput.Factory inputFactory) {
    super(id, config);
    this.inputFactory = inputFactory;

    if (config.hasPath("source-name")) {
        this.sourceName = config.getString("source-name");
    } else {
        this.sourceName = "Application";
    }

    if (config.hasPath("poll-interval")) {
        this.pollInterval = config.getDuration("poll-interval", TimeUnit.MILLISECONDS);
    } else {
        this.pollInterval = 1000L;
    }
}
 
開發者ID:DevOpsStudio,項目名稱:Re-Collector,代碼行數:20,代碼來源:WindowsEventlogInputConfiguration.java

示例6: GrapheneRESTServer

import com.typesafe.config.Config; //導入方法依賴的package包/類
GrapheneRESTServer() {

		Config config = ConfigFactory.load()
			.withFallback(ConfigFactory.load("reference"))
			.withFallback(ConfigFactory.load("application"));

		log.debug("initializing Graphene");
		Graphene graphene = new Graphene(config);
		log.debug("Graphene initialized");

		ResourceConfig rc = generateResourceConfig(config, graphene);

		String uri = "http://" + config.getString("graphene.server.host-name");
		uri += config.hasPath("graphene.server.port") ? ":" + config.getInt("graphene.server.port") : "";
		uri += "/";
		uri += config.hasPath("graphene.server.path") ? config.getString("graphene.server.path") : "";

		log.info("Server will run at: '{}'", uri);

		server = JettyHttpContainerFactory.createServer(
				URI.create(uri),
				rc,
				false);

		log.info("Server successfully initialized, waiting for start.");
	}
 
開發者ID:Lambda-3,項目名稱:Graphene,代碼行數:27,代碼來源:GrapheneRESTServer.java

示例7: KMeansUpdate

import com.typesafe.config.Config; //導入方法依賴的package包/類
public KMeansUpdate(Config config) {
  super(config);
  initializationStrategy = config.getString("oryx.kmeans.initialization-strategy");
  evaluationStrategy = Enum.valueOf(KMeansEvalStrategy.class, config.getString("oryx.kmeans.evaluation-strategy"));
  numberOfRuns = config.getInt("oryx.kmeans.runs");
  maxIterations = config.getInt("oryx.kmeans.iterations");
  hyperParamValues = new ArrayList<>();
  hyperParamValues.add(HyperParams.fromConfig(config, "oryx.kmeans.hyperparams.k"));
  inputSchema = new InputSchema(config);
  Preconditions.checkArgument(maxIterations > 0);
  Preconditions.checkArgument(numberOfRuns > 0);
  Preconditions.checkArgument(
      initializationStrategy.equals(KMeans.K_MEANS_PARALLEL()) ||
          initializationStrategy.equals(KMeans.RANDOM()));
  // Should be an unsupervised problem. This impl only supports numeric features.
  Preconditions.checkArgument(!inputSchema.hasTarget());
  for (int i = 0; i < inputSchema.getNumFeatures(); i++) {
    Preconditions.checkArgument(!inputSchema.isCategorical(i));
  }
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:21,代碼來源:KMeansUpdate.java

示例8: RelationExtractionRunner

import com.typesafe.config.Config; //導入方法依賴的package包/類
public RelationExtractionRunner(Config config) {

		// load boolean values
		this.exploitCore = config.getBoolean("exploit-core");
		this.exploitContexts = config.getBoolean("exploit-contexts");
		this.separateNounBased = config.getBoolean("separate-noun-based");
		this.separatePurposes = config.getBoolean("separate-purposes");
		this.separateAttributions = config.getBoolean("separate-attributions");

		// instantiate extractor
		String extractorClassName = config.getString("relation-extractor");
		try {
			Class<?> extractorClass = Class.forName(extractorClassName);
			Constructor<?> extractorConst = extractorClass.getConstructor();
			this.extractor = (RelationExtractor) extractorConst.newInstance();
		} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) {
			logger.error("Failed to create instance of {}", extractorClassName);
			throw new ConfigException.BadValue("relation-extractor." + extractorClassName, "Failed to create instance.");
		}

		this.elementCoreExtractionMap = new LinkedHashMap<>();
	}
 
開發者ID:Lambda-3,項目名稱:Graphene,代碼行數:23,代碼來源:RelationExtractionRunner.java

示例9: getJdbcDs

import com.typesafe.config.Config; //導入方法依賴的package包/類
private static DataSource getJdbcDs(final Config config, final int numConnections) {
    String jdbcUrl = config.getString("jdbcUrl");
    final String username = config.getString("username");
    final String password = config.getString("password");
    final String driver = config.getString("driver");
    try {
        return JdbcDataSourceFactory.createFromJdbcUrl(
                (Class<? extends Driver>) Class.forName(driver),
                jdbcUrl,
                new Credential(username, password),
                numConnections);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:16,代碼來源:ParamReader.java

示例10: ModelParams

import com.typesafe.config.Config; //導入方法依賴的package包/類
public ModelParams(Config config, String prefix) {
    data_path = config.getString(prefix + KEY + "data_path");
    delim = config.getString(prefix + KEY + "delim");
    need_dict = config.getBoolean(prefix + KEY + "need_dict");
    dict_path = config.getString(prefix + KEY + "dict_path");
    dump_freq = config.getInt(prefix + KEY + "dump_freq");
    need_bias = config.getBoolean(prefix + KEY + "need_bias");
    bias_feature_name = config.getString(prefix + KEY + "bias_feature_name");
    continue_train = config.getBoolean(prefix + KEY + "continue_train");
}
 
開發者ID:yuantiku,項目名稱:ytk-learn,代碼行數:11,代碼來源:ModelParams.java

示例11: ServingLayer

import com.typesafe.config.Config; //導入方法依賴的package包/類
/**
 * Creates a new instance with the given configuration.
 *
 * @param config configuration for the serving layer
 */
public ServingLayer(Config config) {
  Objects.requireNonNull(config);
  log.info("Configuration:\n{}", ConfigUtils.prettyPrint(config));
  this.config = config;
  this.id = ConfigUtils.getOptionalString(config, "oryx.id");
  this.port = config.getInt("oryx.serving.api.port");
  this.securePort = config.getInt("oryx.serving.api.secure-port");
  this.userName = ConfigUtils.getOptionalString(config, "oryx.serving.api.user-name");
  this.password = ConfigUtils.getOptionalString(config, "oryx.serving.api.password");
  String keystoreFileString =
      ConfigUtils.getOptionalString(config, "oryx.serving.api.keystore-file");
  this.keystoreFile = keystoreFileString == null ? null : Paths.get(keystoreFileString);
  this.keystorePassword =
      ConfigUtils.getOptionalString(config, "oryx.serving.api.keystore-password");
  this.keyAlias = ConfigUtils.getOptionalString(config, "oryx.serving.api.key-alias");
  String contextPathString = config.getString("oryx.serving.api.context-path");
  if (contextPathString == null ||
      contextPathString.isEmpty() ||
      "/".equals(contextPathString)) {
    contextPathString = "";
  }
  this.contextPathURIBase = contextPathString;
  this.appResourcesPackages =
      config.getString("oryx.serving.application-resources") + "," +
      "com.cloudera.oryx.lambda.serving"; // Always append package for e.g. error page
  // For tests only:
  this.doNotInitTopics = config.getBoolean("oryx.serving.no-init-topics");
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:34,代碼來源:ServingLayer.java

示例12: CollectorIdConfiguration

import com.typesafe.config.Config; //導入方法依賴的package包/類
@Inject
public CollectorIdConfiguration(Config config) {
    if (config.hasPath(collectorIdStatement)) {
        this.collectorId = config.getString(collectorIdStatement);
    } else {
        this.collectorId = "file:config/collector-id";
    }
}
 
開發者ID:DevOpsStudio,項目名稱:Re-Collector,代碼行數:9,代碼來源:CollectorIdConfiguration.java

示例13: LocalSnapshotStore

import com.typesafe.config.Config; //導入方法依賴的package包/類
public LocalSnapshotStore(final Config config) {
    this.executionContext = context().system().dispatchers().lookup(config.getString("stream-dispatcher"));
    snapshotDir = new File(config.getString("dir"));

    int localMaxLoadAttempts = config.getInt("max-load-attempts");
    maxLoadAttempts = localMaxLoadAttempts > 0 ? localMaxLoadAttempts : 1;

    LOG.debug("LocalSnapshotStore ctor: snapshotDir: {}, maxLoadAttempts: {}", snapshotDir, maxLoadAttempts);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:10,代碼來源:LocalSnapshotStore.java

示例14: AbstractSparkLayer

import com.typesafe.config.Config; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected AbstractSparkLayer(Config config) {
  Objects.requireNonNull(config);
  log.info("Configuration:\n{}", ConfigUtils.prettyPrint(config));

  String group = getConfigGroup();
  this.config = config;
  String configuredID = ConfigUtils.getOptionalString(config, "oryx.id");
  this.id = configuredID == null ? UUID.randomUUID().toString() : configuredID;
  this.streamingMaster = config.getString("oryx." + group + ".streaming.master");
  this.inputTopic = config.getString("oryx.input-topic.message.topic");
  this.inputTopicLockMaster = config.getString("oryx.input-topic.lock.master");
  this.inputBroker = config.getString("oryx.input-topic.broker");
  this.updateTopic = ConfigUtils.getOptionalString(config, "oryx.update-topic.message.topic");
  this.updateTopicLockMaster = ConfigUtils.getOptionalString(config, "oryx.update-topic.lock.master");
  this.keyClass = ClassUtils.loadClass(config.getString("oryx.input-topic.message.key-class"));
  this.messageClass =
      ClassUtils.loadClass(config.getString("oryx.input-topic.message.message-class"));
  this.keyDecoderClass = (Class<? extends Deserializer<K>>) ClassUtils.loadClass(
      config.getString("oryx.input-topic.message.key-decoder-class"), Deserializer.class);
  this.messageDecoderClass = (Class<? extends Deserializer<M>>) ClassUtils.loadClass(
      config.getString("oryx.input-topic.message.message-decoder-class"), Deserializer.class);
  this.generationIntervalSec = config.getInt("oryx." + group + ".streaming.generation-interval-sec");

  this.extraSparkConfig = new HashMap<>();
  config.getConfig("oryx." + group + ".streaming.config").entrySet().forEach(e ->
    extraSparkConfig.put(e.getKey(), e.getValue().unwrapped())
  );

  Preconditions.checkArgument(generationIntervalSec > 0);
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:32,代碼來源:AbstractSparkLayer.java

示例15: loadProvider

import com.typesafe.config.Config; //導入方法依賴的package包/類
/**
 * Look for the configuration key "remote-configuration.provider" and
 * try to instantiate class.
 *
 * @param localConfiguration The local configuration
 * @return An optional {@code RemoteConfigProvider}
 * @since 17.08.20
 */
private RemoteConfigProvider loadProvider(final Config localConfiguration) {
    final String provider = localConfiguration.getString("remote-configuration.provider");
    if (!provider.isEmpty()) {
        final ServiceLoader<RemoteConfigProvider> serviceLoaderRCP = ServiceLoader.load(RemoteConfigProvider.class);
        for (final RemoteConfigProvider rcp : serviceLoaderRCP) {
            if (rcp.getShortName().compareToIgnoreCase(provider) == 0) {
                return rcp;
            }
        }
        throw new RuntimeException("Can't resolve the remote configuration provider '" + provider + "'");
    }
    return null;
}
 
開發者ID:payintech,項目名稱:play-remote-configuration,代碼行數:22,代碼來源:PlayApplicationLoader.java


注:本文中的com.typesafe.config.Config.getString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。