本文整理汇总了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)
);
}
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
}
}
示例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()));
}
示例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
}
示例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();
}
示例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");
}
示例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;
}
示例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()));
}
示例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));
}
示例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"
))
);
}
示例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);
}
示例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);
}