Java Code Examples for com.typesafe.config.ConfigFactory#load()
The following examples show how to use
com.typesafe.config.ConfigFactory#load() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Compiler.java From kite with Apache License 2.0 | 8 votes |
/** Loads the given config file from the local file system */ public Config parse(File file, Config... overrides) throws IOException { if (file == null || file.getPath().trim().length() == 0) { throw new MorphlineCompilationException("Missing morphlineFile parameter", null); } if (!file.exists()) { throw new FileNotFoundException("File not found: " + file); } if (!file.canRead()) { throw new IOException("Insufficient permissions to read file: " + file); } Config config = ConfigFactory.parseFile(file); for (Config override : overrides) { config = override.withFallback(config); } synchronized (LOCK) { ConfigFactory.invalidateCaches(); config = ConfigFactory.load(config); config.checkValid(ConfigFactory.defaultReference()); // eagerly validate aspects of tree config } return config; }
Example 2
Source File: RawConfigSupplier.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Override public Config get() { /* * 1. Service specific environment config (e. g. concierge-docker.conf) * 2. Service specific base config (e. g. concierge.conf) * 3. Common Ditto services config (ditto-service-base.conf) */ final Config serviceSpecificEnvironmentConfig = getServiceSpecificEnvironmentConfig(); final Config configWithFallbacks = serviceSpecificEnvironmentConfig .withFallback(getServiceSpecificBaseConfig()) .withFallback(getCommonDittoServicesConfig()) .resolve(); return ConfigFactory.load(configWithFallbacks); }
Example 3
Source File: ConfigModule.java From proteus with Apache License 2.0 | 6 votes |
@Override protected void configure() { Config config = ConfigFactory.defaultApplication(); Config referenceConfig = ConfigFactory.load(ConfigFactory.defaultReference()); config = ConfigFactory.load(config).withFallback(referenceConfig); if (configURL != null) { config = ConfigFactory.load(ConfigFactory.parseURL(configURL)).withFallback(config); } else if (configFile != null) { config = fileConfig(configFile).withFallback(config); } this.bindConfig(config); install(new ApplicationModule(this.config)); }
Example 4
Source File: ClickhouseSinkScheduledCheckerTest.java From flink-clickhouse-sink with MIT License | 5 votes |
@Before public void setUp() throws Exception { Config config = ConfigFactory.load(); Map<String, String> params = ConfigUtil.toMap(config); params.put(ClickhouseClusterSettings.CLICKHOUSE_USER, ""); params.put(ClickhouseClusterSettings.CLICKHOUSE_PASSWORD, ""); params.put(ClickhouseClusterSettings.CLICKHOUSE_HOSTS, "http://localhost:8123"); ClickhouseSinkCommonParams commonParams = new ClickhouseSinkCommonParams(params); checker = new ClickhouseSinkScheduledChecker(commonParams); MockitoAnnotations.initMocks(this); }
Example 5
Source File: HeliosConfig.java From helios with Apache License 2.0 | 5 votes |
/** * Return the root configuration loaded from the helios configuration files. */ static Config loadConfig() { final ConfigResolveOptions resolveOptions = ConfigResolveOptions .defaults() .setAllowUnresolved(true); final ConfigParseOptions parseOptions = ConfigParseOptions.defaults(); final Config baseConfig = ConfigFactory.load(BASE_CONFIG_FILE, parseOptions, resolveOptions); final Config appConfig = ConfigFactory.load(APP_CONFIG_FILE, parseOptions, resolveOptions); return appConfig.withFallback(baseConfig); }
Example 6
Source File: ConfigUtilTest.java From adaptive-alerting with Apache License 2.0 | 5 votes |
@Test public void testToProducerConfig() { val config = ConfigFactory.load("producer.conf"); val props = ConfigUtil.toProducerConfig(config); assertEquals(BOOTSTRAP_SERVERS, props.getProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)); assertEquals(CLIENT_ID, props.getProperty(ProducerConfig.CLIENT_ID_CONFIG)); assertEquals(KEY_SER, props.getProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG)); assertEquals(VALUE_SER, props.getProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG)); }
Example 7
Source File: XTraceSettings.java From tracing-framework with BSD 3-Clause "New" or "Revised" License | 5 votes |
public XTraceSettings() { Config config = ConfigFactory.load(); on = config.getBoolean("xtrace.client.reporting.on"); defaultEnabled = config.getBoolean("xtrace.client.reporting.default"); discoveryMode = config.getBoolean("xtrace.client.reporting.discoverymode"); traceMain = config.getBoolean("xtrace.client.tracemain"); defaultLoggingLevel = XTraceLoggingLevel.valueOf(config.getString("xtrace.client.reporting.default_level").toUpperCase()); mainMethodLoggingLevel = XTraceLoggingLevel.valueOf(config.getString("xtrace.client.tracemain_level").toUpperCase()); classesEnabled = Sets.newHashSet(config.getStringList("xtrace.client.reporting.enabled")); classesDisabled = Sets.newHashSet(config.getStringList("xtrace.client.reporting.disabled")); recycleThreshold = config.getInt("xtrace.client.recycle-threshold"); }
Example 8
Source File: MetricsTest.java From xrpc with Apache License 2.0 | 5 votes |
@BeforeEach void beforeEach() throws Exception { config = ConfigFactory.load("test.conf"); server = new Server(config.getConfig("xrpc")); server.listenAndServe(); endpoint = server.localEndpoint(); h11client = OkHttpUnsafe.getUnsafeClient(); h2client = OkHttpUnsafe.getUnsafeClient(Protocol.HTTP_2, Protocol.HTTP_1_1); }
Example 9
Source File: HelloConsumer.java From talk-kafka-zipkin with MIT License | 5 votes |
public static void main(String[] args) { final var config = ConfigFactory.load(); /* START TRACING INSTRUMENTATION */ final var sender = URLConnectionSender.newBuilder() .endpoint(config.getString("zipkin.endpoint")).build(); final var reporter = AsyncReporter.builder(sender).build(); final var tracing = Tracing.newBuilder().localServiceName("hello-consumer") .sampler(Sampler.ALWAYS_SAMPLE).spanReporter(reporter).build(); final var kafkaTracing = KafkaTracing.newBuilder(tracing) .remoteServiceName("kafka").build(); /* END TRACING INSTRUMENTATION */ final var consumerConfigs = new Properties(); consumerConfigs.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, config.getString("kafka.bootstrap-servers")); consumerConfigs.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); consumerConfigs.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); consumerConfigs.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "hello-consumer"); consumerConfigs.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, OffsetResetStrategy.EARLIEST.name().toLowerCase()); final var kafkaConsumer = new KafkaConsumer<String, String>(consumerConfigs); final var tracingConsumer = kafkaTracing.consumer(kafkaConsumer); tracingConsumer.subscribe(Collections.singletonList("hello")); while (!Thread.interrupted()) { var records = tracingConsumer.poll(Duration.ofMillis(Long.MAX_VALUE)); for (var record : records) { brave.Span span = kafkaTracing.nextSpan(record).name("print-hello") .start(); span.annotate("starting printing"); out.println(String.format("Record: %s", record)); span.annotate("printing finished"); span.finish(); } } }
Example 10
Source File: MewbaseTestBase.java From mewbase with MIT License | 5 votes |
protected Config createConfig() { final String testPath; try { testPath = testFolder.newFolder().getPath(); } catch (IOException e) { throw new IllegalStateException("Could not create a directory for file binder", e); } final Properties properties = new Properties(); properties.setProperty("mewbase.binders.files.store.basedir", Paths.get(testPath,"binders").toString() ); properties.setProperty("mewbase.event.sink.file.basedir", Paths.get(testPath,"events").toString() ); properties.setProperty("mewbase.event.source.file.basedir", Paths.get(testPath,"events").toString() ); ConfigFactory.invalidateCaches(); return ConfigFactory.load(ConfigFactory.parseProperties(properties)); }
Example 11
Source File: DefaultTagsConfigTest.java From ditto with Eclipse Public License 2.0 | 4 votes |
@BeforeClass public static void initTestFixture() { snapshotTestConf = ConfigFactory.load("tags-test"); }
Example 12
Source File: SamanthaConfigService.java From samantha with MIT License | 4 votes |
public void reloadConfig() { ConfigFactory.invalidateCaches(); Config config = ConfigFactory.load(); configuration = new Configuration(config); loadConfig(configuration); }
Example 13
Source File: TypesafeConfigLoader.java From adaptive-alerting with Apache License 2.0 | 4 votes |
public Config loadBaseConfig() { log.info("Loading base configuration: appKey={}", appKey); val baseAppConfigs = ConfigFactory.load(BASE_APP_CONFIG_PATH); val defaultAppConfig = baseAppConfigs.getConfig(CK_KSTREAM_APP_DEFAULT_CONFIG); return baseAppConfigs.getConfig(appKey).withFallback(defaultAppConfig); }
Example 14
Source File: DefaultStreamingConfigTest.java From ditto with Eclipse Public License 2.0 | 4 votes |
@BeforeClass public static void initTestFixture() { streamingTestConfig = ConfigFactory.load("streaming-test"); }
Example 15
Source File: LmdbBinderStore.java From mewbase with MIT License | 4 votes |
@Deprecated public LmdbBinderStore() { this(ConfigFactory.load()); }
Example 16
Source File: GatewayHttpConfigTest.java From ditto with Eclipse Public License 2.0 | 4 votes |
@BeforeClass public static void setUp() { gatewayHttpTestConfig = ConfigFactory.load("gateway-http-test"); }
Example 17
Source File: Settings.java From opencensus-java with Apache License 2.0 | 4 votes |
private static Config readConfig() { Config config = ConfigFactory.load(); config.checkValid(ConfigFactory.defaultReference(), CONFIG_ROOT); return config.getConfig(CONFIG_ROOT); }
Example 18
Source File: DefaultIndexInitializationConfigTest.java From ditto with Eclipse Public License 2.0 | 4 votes |
@BeforeClass public static void initTestFixture() { indexInitializationTestConf = ConfigFactory.load("index-initialization-test"); }
Example 19
Source File: ParsecConfigFactory.java From parsec-libraries with Apache License 2.0 | 2 votes |
/** * prepare config for later use. * @param envString environment string * @return config */ public static ParsecConfig load(String envString) { Config config = ConfigFactory.load(envString); return new TypeSafeConfWrapper(config); }
Example 20
Source File: FileBinderStore.java From mewbase with MIT License | votes |
public FileBinderStore() { this(ConfigFactory.load() ); }