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


Java ConfigFactory类代码示例

本文整理汇总了Java中com.typesafe.config.ConfigFactory的典型用法代码示例。如果您正苦于以下问题:Java ConfigFactory类的具体用法?Java ConfigFactory怎么用?Java ConfigFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConfigFactory类属于com.typesafe.config包,在下文中一共展示了ConfigFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getConfig

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
@Override
public Config getConfig() throws IOException {
  PathMatcher pathMatcher;

  try {
    pathMatcher = FileSystems.getDefault().getPathMatcher(inputFilePattern);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException(
        "Invalid input file pattern: " + inputFilePattern);
  }

  try (Stream<Path> pathStream = Files.walk(baseDirectory)) {
    return pathStream
        .filter(p -> Files.isRegularFile(p) && pathMatcher.matches(p))
        .map(p -> ConfigFactory.parseFile(p.toFile()))
        .reduce(ConfigFactory.empty(), Config::withFallback)
        .resolve(
            ConfigResolveOptions.defaults()
                .setAllowUnresolved(true)
                .setUseSystemEnvironment(false)
        );
  }
}
 
开发者ID:okvee,项目名称:tscfg-docgen,代码行数:24,代码来源:PathMatcherConfigProvider.java

示例2: buildConfigIfAbsent

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
private Config buildConfigIfAbsent(Config currentConfig) {
    if (currentConfig != null) return currentConfig;

    Optional<String> configurationFile = kvClient.getValueAsString(configurationFilePath).toJavaUtil();
    if (configurationFile.isPresent()) {
        return ConfigFactory.parseString(configurationFile.get());
    }

    logger.debug("Missing configuration file at path: {}, ignore flag set to: {}", configurationFilePath, ignoreMissingResource);

    if (ignoreMissingResource) {
        return ConfigFactory.empty();
    }

    throw new IllegalStateException("Missing required configuration resource at path: " + configurationFilePath);
}
 
开发者ID:conf4j,项目名称:conf4j,代码行数:17,代码来源:ConsulFileConfigurationSource.java

示例3: listOrganisations

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
@Restrict({@Group("STUDENT")})
public CompletionStage<Result> listOrganisations() throws MalformedURLException {
    URL url = parseUrl();
    WSRequest request = wsClient.url(url.toString());
    String localRef = ConfigFactory.load().getString("sitnet.integration.iop.organisationRef");

    Function<WSResponse, Result>  onSuccess = response -> {
        JsonNode root = response.asJson();
        if (response.getStatus() != 200) {
            return internalServerError(root.get("message").asText("Connection refused"));
        }
        if (root instanceof ArrayNode) {
            ArrayNode node = (ArrayNode) root;
            for (JsonNode n : node) {
                ((ObjectNode) n).put("homeOrg", n.get("_id").asText().equals(localRef));
            }
        }
        return ok(root);
    };
    return request.get().thenApplyAsync(onSuccess);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:22,代码来源:OrganisationController.java

示例4: staticSetup

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
@BeforeClass
public static void staticSetup() throws InterruptedException {
    AkkaConfigurationReader reader = ConfigFactory::load;

    RemoteRpcProviderConfig config1 = new RemoteRpcProviderConfig.Builder("memberA").gossipTickInterval("200ms")
            .withConfigReader(reader).build();
    RemoteRpcProviderConfig config2 = new RemoteRpcProviderConfig.Builder("memberB").gossipTickInterval("200ms")
            .withConfigReader(reader).build();
    RemoteRpcProviderConfig config3 = new RemoteRpcProviderConfig.Builder("memberC").gossipTickInterval("200ms")
            .withConfigReader(reader).build();
    node1 = ActorSystem.create("opendaylight-rpc", config1.get());
    node2 = ActorSystem.create("opendaylight-rpc", config2.get());
    node3 = ActorSystem.create("opendaylight-rpc", config3.get());

    waitForMembersUp(node1, Cluster.get(node2).selfUniqueAddress(), Cluster.get(node3).selfUniqueAddress());
    waitForMembersUp(node2, Cluster.get(node1).selfUniqueAddress(), Cluster.get(node3).selfUniqueAddress());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:RpcRegistryTest.java

示例5: main

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
public static void main(String []args) {
    Config config = ConfigFactory.parseFile(new File("config/model/fm.conf"));
    RandomParams randomParams = new RandomParams(config, "");
    RandomParamsUtils randomParamsUtils = new RandomParamsUtils(randomParams);

    System.out.println("normal sample:");
    for (int i = 0; i < 50; i++) {
        System.out.println(randomParamsUtils.next());
    }

    System.out.println("uniform sample:");
    for (int i = 0; i < 50000; i++) {
        double r = randomParamsUtils.next();
        if (r < -0.01 || r > 0.01) {
            System.out.println("error");
            break;
        }
    }
}
 
开发者ID:yuantiku,项目名称:ytk-learn,代码行数:20,代码来源:RandomParamsUtils.java

示例6: getConfig

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
private static Config getConfig(int index, String discoveryNode) {
    return ConfigFactory.empty()
            .withValue("peer.discovery.enabled", value(true))
            .withValue("peer.discovery.external.ip", value("127.0.0.1"))
            .withValue("peer.discovery.bind.ip", value("127.0.0.1"))
            .withValue("peer.discovery.persist", value("false"))

            .withValue("peer.listen.port", value(20000 + index))
            .withValue("peer.privateKey", value(Hex.toHexString(ECKey.fromPrivate(("" + index).getBytes()).getPrivKeyBytes())))
            .withValue("peer.networkId", value(555))
            .withValue("sync.enabled", value(true))
            .withValue("database.incompatibleDatabaseBehavior", value("RESET"))
            .withValue("genesis", value("sample-genesis.json"))
            .withValue("database.dir", value("sampleDB-" + index))
            .withValue("peer.discovery.ip.list", value(discoveryNode != null ? Arrays.asList(discoveryNode) : Arrays.asList()));
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:17,代码来源:PrivateNetworkDiscoverySample.java

示例7: helper_shouldPutVersion_afterDatabaseReset

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
@Test
public void helper_shouldPutVersion_afterDatabaseReset() throws IOException {
    Config config = ConfigFactory.empty()
            .withValue("database.reset", ConfigValueFactory.fromAnyRef(true));

    SPO systemProperties = new SPO(config);
    systemProperties.setDataBaseDir(databaseDir);
    systemProperties.setDatabaseVersion(33);
    final File testFile = createFile();

    assertTrue(testFile.exists());
    resetHelper.process(systemProperties);
    assertEquals(new Integer(33), resetHelper.getDatabaseVersion(versionFile));

    assertFalse(testFile.exists()); // reset should have cleared file
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:17,代码来源:InitializerTest.java

示例8: startRemoteActorSystem

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
/**
 * This method will do the basic setup for actors.
 */
private static void startRemoteActorSystem() {
  ProjectLogger.log("startRemoteCreationSystem method called....");
  Config con = null;
  String host = System.getenv(JsonKey.SUNBIRD_ACTOR_SERVICE_IP);
  String port = System.getenv(JsonKey.SUNBIRD_ACTOR_SERVICE_PORT);

  if (!ProjectUtil.isStringNullOREmpty(host) && !ProjectUtil.isStringNullOREmpty(port)) {
    con = ConfigFactory
        .parseString(
            "akka.remote.netty.tcp.hostname=" + host + ",akka.remote.netty.tcp.port=" + port + "")
        .withFallback(ConfigFactory.load().getConfig(ACTOR_CONFIG_NAME));
  } else {
    con = ConfigFactory.load().getConfig(ACTOR_CONFIG_NAME);
  }
  system = ActorSystem.create(REMOTE_ACTOR_SYSTEM_NAME, con);
  ActorRef learnerActorSelectorRef = system.actorOf(Props.create(RequestRouterActor.class),
      RequestRouterActor.class.getSimpleName());

  RequestRouterActor.setSystem(system);

  ProjectLogger.log("normal remote ActorSelectorRef " + learnerActorSelectorRef);
  ProjectLogger.log("NORMAL ACTOR REMOTE SYSTEM STARTED " + learnerActorSelectorRef,
      LoggerEnum.INFO.name());
  checkCassandraConnection();
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:29,代码来源:Application.java

示例9: run

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
public void run() {
  final Config conf = parseString("akka.remote.netty.tcp.hostname=" + config.hostname())
          .withFallback(parseString("akka.remote.netty.tcp.port=" + config.actorPort()))
          .withFallback(ConfigFactory.load("remote"));

  final ActorSystem system = ActorSystem.create("concierge", conf);
  kv = system.actorOf(LinearizableStorage.props(new Cluster(config.cluster().paths(), "kv")), "kv");

  final ActorMaterializer materializer = ActorMaterializer.create(system);

  final Flow<HttpRequest, HttpResponse, NotUsed> theFlow = createRoute().flow(system, materializer);

  final ConnectHttp host = ConnectHttp.toHost(config.hostname(), config.clientPort());
  Http.get(system).bindAndHandle(theFlow, host, materializer);

  LOG.info("Ama up");
}
 
开发者ID:marnikitta,项目名称:Concierge,代码行数:18,代码来源:ConciergeApplication.java

示例10: relaunchIfNeeded

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
public S2Controller relaunchIfNeeded(int baseBuild, String dataVersion) {
    String currentBaseBuild = cfg.getString(GAME_EXE_BUILD);
    String currentDataVersion = cfg.hasPath(GAME_EXE_DATA_VER) ? cfg.getString(GAME_EXE_DATA_VER) : "";
    String baseBuildName = BUILD_PREFIX + baseBuild;
    if (!currentBaseBuild.equals(baseBuildName) || !currentDataVersion.equals(dataVersion)) {

        log.warn("Expected base build: {} and data version: {}. " +
                        "Actual base build: {} and data version: {}. " +
                        "Relaunching to expected version...",
                baseBuildName, dataVersion, currentBaseBuild, currentDataVersion);

        stopAndWait();

        cfg = ConfigFactory.parseMap(
                Map.of(GAME_EXE_BUILD, baseBuildName, GAME_EXE_DATA_VER, dataVersion)
        ).withFallback(cfg);

        return launch();
    }
    return this;
}
 
开发者ID:ocraft,项目名称:ocraft-s2client,代码行数:22,代码来源:S2Controller.java

示例11: expectedConfiguration

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
private Config expectedConfiguration() {
    return ConfigFactory.parseMap(Map.ofEntries(
            entry(GAME_NET_IP, CFG_NET_IP),
            entry(GAME_NET_PORT, CFG_NET_PORT),
            entry(GAME_NET_TIMEOUT, 2000),
            entry(GAME_NET_RETRY_COUNT, 10),
            entry(GAME_EXE_PATH, gameRoot().toString()),
            entry(GAME_EXE_BUILD, CFG_EXE_BUILD_NEW),
            entry(GAME_EXE_FILE, CFG_EXE_FILE),
            entry(GAME_EXE_DATA_VER, CFG_EXE_DATA_VER),
            entry(GAME_EXE_IS_64, true),
            entry(GAME_WINDOW_W, CFG_WINDOW_W),
            entry(GAME_WINDOW_H, CFG_WINDOW_H),
            entry(GAME_WINDOW_X, CFG_WINDOW_X),
            entry(GAME_WINDOW_Y, CFG_WINDOW_Y),
            entry(GAME_WINDOW_MODE, 0)
    )).withValue(GAME_CLI_DATA_DIR, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_EGL_PATH, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_OS_MESA_PATH, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_DATA_DIR, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_TEMP_DIR, ConfigValueFactory.fromAnyRef(nothing()))
            .withValue(GAME_CLI_VERBOSE, ConfigValueFactory.fromAnyRef(nothing()));
}
 
开发者ID:ocraft,项目名称:ocraft-s2client,代码行数:24,代码来源:S2ControllerTest.java

示例12: setUp

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
/**
 * Initial Setup
 */
@Before
public void setUp() {

	this.activeProfile = RestUtil.getCurrentProfile();

	this.conf = ConfigFactory.load("application-" + this.activeProfile);
	this.baseURI = conf.getString("server.baseURI");
	this.port = conf.getInt("server.port");
	this.timeout = conf.getInt("service.api.timeout");

	final RequestSpecBuilder build = new RequestSpecBuilder().setBaseUri(baseURI).setPort(port);

	rspec = build.build();
	RestAssured.config = new RestAssuredConfig().encoderConfig(encoderConfig().defaultContentCharset("UTF-8")
			.encodeContentTypeAs("application-json", ContentType.JSON));
}
 
开发者ID:ERS-HCL,项目名称:itest-starter,代码行数:20,代码来源:AbstractITest.java

示例13: getParamReader

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
public static ParamReader getParamReader() {
    String dbCredsFile = System.getProperty("dbCredsFile");
    if (StringUtils.isEmpty(dbCredsFile)) {
        dbCredsFile = "oracle-creds.properties";
    }

    return new ParamReader(ConfigFactory.parseResources(dbCredsFile),
            "oracle", ConfigFactory.parseMap(Maps.mutable.<String, Object>of(
                    "sysattrs.type", "ORACLE",
                    "logicalSchemas.schema1", "schema1",
                    "logicalSchemas.schema2", "schema2"
            ))
    );
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:15,代码来源:OracleParamReader.java

示例14: parseUrl

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
private static URL parseUrl(String orgRef, String facilityRef, String date, String start, String end, int duration)
        throws MalformedURLException {
    String url = ConfigFactory.load().getString("sitnet.integration.iop.host") +
            String.format("/api/organisations/%s/facilities/%s/slots", orgRef, facilityRef) +
            String.format("?date=%s&startAt=%s&endAt=%s&duration=%d", date, start, end, duration);
    return new URL(url);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:8,代码来源:ExternalCalendarController.java

示例15: createConnectionForBackgroundActors

import com.typesafe.config.ConfigFactory; //导入依赖的package包/类
public static void createConnectionForBackgroundActors() {
  String path = PropertiesCache.getInstance().getProperty("background.remote.actor.path");
  ActorSystem system = null;
  String bkghost = System.getenv(JsonKey.BKG_SUNBIRD_ACTOR_SERVICE_IP);
  String bkgport = System.getenv(JsonKey.BKG_SUNBIRD_ACTOR_SERVICE_PORT);
  Config con = null;
  if ("local"
      .equalsIgnoreCase(PropertiesCache.getInstance().getProperty("api_actor_provider"))) {
    con = ConfigFactory.load().getConfig(ACTOR_CONFIG_NAME);
    system = akka.actor.ActorSystem.create(REMOTE_ACTOR_SYSTEM_NAME, con);
  }else{
    system = RequestRouterActor.getSystem();
  }
  try {
    if (!ProjectUtil.isStringNullOREmpty(bkghost) && !ProjectUtil.isStringNullOREmpty(bkgport)) {
      ProjectLogger.log("value is taking from system env");
      path = MessageFormat.format(
          PropertiesCache.getInstance().getProperty("background.remote.actor.env.path"),
          System.getenv(JsonKey.BKG_SUNBIRD_ACTOR_SERVICE_IP),
          System.getenv(JsonKey.BKG_SUNBIRD_ACTOR_SERVICE_PORT));
    }
    ProjectLogger.log("Actor path is ==" + path, LoggerEnum.INFO.name());
  } catch (Exception e) {
    ProjectLogger.log(e.getMessage(), e);
  }
  selection = system.actorSelection(path);
  ProjectLogger.log("ActorUtility selection reference    : " + selection);
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:29,代码来源:RequestRouterActor.java


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