本文整理匯總了Java中com.typesafe.config.ConfigRenderOptions類的典型用法代碼示例。如果您正苦於以下問題:Java ConfigRenderOptions類的具體用法?Java ConfigRenderOptions怎麽用?Java ConfigRenderOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ConfigRenderOptions類屬於com.typesafe.config包,在下文中一共展示了ConfigRenderOptions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testStockTradesPersisted
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
@Test
public void testStockTradesPersisted(TestContext context) throws ClassNotFoundException {
Async async = context.async();
JsonObject jdbcConfig = new JsonObject(config.getObject("jdbc").render(ConfigRenderOptions.concise()));
JDBCClient jdbc = JDBCClient.createNonShared(vertx, jdbcConfig);
Class.forName(jdbcConfig.getString("driverclass"));
jdbc.getConnection(ar -> {
SQLConnection connection = ar.result();
if (ar.failed()) {
context.fail(ar.cause());
} else {
connection.query(SELECT_STATEMENT, result -> {
ResultSet set = result.result();
List<JsonObject> operations = set.getRows().stream()
.map(json -> new JsonObject(json.getString("OPERATION")))
.collect(Collectors.toList());
context.assertTrue(operations.size() >= 3);
connection.close();
async.complete();
});
}
});
}
示例2: HoconFileSource
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
private HoconFileSource(final Builder builder) {
super(builder);
_file = builder._file;
JsonNode jsonNode = null;
if (_file.canRead()) {
try {
final Config config = ConfigFactory.parseFile(_file);
final String hoconAsJson = config.resolve().root().render(ConfigRenderOptions.concise());
jsonNode = _objectMapper.readTree(hoconAsJson);
} catch (final IOException e) {
throw new RuntimeException(e);
}
} else if (builder._file.exists()) {
LOGGER.warn()
.setMessage("Cannot read file")
.addData("file", _file)
.log();
} else {
LOGGER.debug()
.setMessage("File does not exist")
.addData("file", _file)
.log();
}
_jsonNode = Optional.ofNullable(jsonNode);
}
示例3: process
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
@Override
public void process(Vertx vertx, JsonObject configuration, Buffer input, Handler<AsyncResult<JsonObject>> handler) {
// Use executeBlocking even if the bytes are in memory
// Indeed, HOCON resolution can read others files (includes).
vertx.executeBlocking(
future -> {
Reader reader = new StringReader(input.toString("UTF-8"));
try {
Config conf = ConfigFactory.parseReader(reader);
conf = conf.resolve();
String output = conf.root().render(ConfigRenderOptions.concise()
.setJson(true).setComments(false).setFormatted(false));
JsonObject json = new JsonObject(output);
future.complete(json);
} catch (Exception e) {
future.fail(e);
} finally {
closeQuietly(reader);
}
},
handler
);
}
示例4: notifyDataSubscribers
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
private void notifyDataSubscribers(JsonNode entities, RequestContext requestContext) {
if (subscribers == null) {
return;
}
ObjectNode reqBody = Json.newObject();
IOUtilities.parseEntityFromJsonNode(requestContext.getRequestBody(), reqBody);
ObjectNode daoConfig = Json.newObject();
daoConfig.put(ConfigKey.ENTITY_DAO_NAME_KEY.get(), ConfigKey.REQUEST_ENTITY_DAO_NAME.get());
daoConfig.set(ConfigKey.REQUEST_ENTITY_DAO_ENTITIES_KEY.get(), entities);
reqBody.set(daoConfigKey, daoConfig);
RequestContext pseudoReq = new RequestContext(reqBody, requestContext.getEngineName());
for (Configuration configuration : subscribers) {
String name = configuration.getString(ConfigKey.ENGINE_COMPONENT_NAME.get());
String type = configuration.getString(ConfigKey.ENGINE_COMPONENT_TYPE.get());
JsonNode configReq = Json.parse(configuration.getConfig(ConfigKey.REQUEST_CONTEXT.get())
.underlying().root().render(ConfigRenderOptions.concise()));
IOUtilities.parseEntityFromJsonNode(configReq, reqBody);
EngineComponent.valueOf(type).getComponent(configService, name, pseudoReq);
}
}
示例5: save
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
/**
* Save file.
*
* @return the file
*/
public File save() {
ConfigRenderOptions renderOptions = ConfigRenderOptions.defaults()
.setComments(true)
.setFormatted(true)
.setOriginComments(false)
.setJson(false);
bumpVersion();
String configData = configImpl.root().render(renderOptions);
FileWriter writer = null;
try {
writer = new FileWriter(tmpFile.toFile());
writer.write(configData);
} catch (IOException e) {
logger.warn("failed to write file, message={}", e.getMessage());
} finally {
CloseableUtils.closeQuietly(writer);
}
return tmpFile.toFile();
}
示例6: get
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
public static ITestMetastoreDatabase get(String version, Config dbConfig) throws Exception {
try {
synchronized (syncObject) {
ensureDatabaseExists(dbConfig);
TestMetadataDatabase instance = new TestMetadataDatabase(testMetastoreDatabaseServer, version);
instances.add(instance);
return instance;
}
}
catch (Exception e) {
throw new RuntimeException("Failed to create TestMetastoreDatabase with version " + version +
" and config " + dbConfig.root().render(ConfigRenderOptions.defaults().setFormatted(true).setJson(true))
+ " cause: " + e, e);
}
}
示例7: main
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
public static void main(String[] args) {
Config config = ConfigFactory.parseFile(new File("c:/reference.conf"));
String str = config.root().render(
ConfigRenderOptions.concise().setFormatted(true).setJson(true).setComments(true));
// response.getWriter().write(ConfigFactory.load().root().render());
/**
*
*
* ConfigParseOptions options = ConfigParseOptions.defaults()
* .setSyntax(ConfigSyntax.JSON)
* .setAllowMissing(false)
*
*
*/
System.out.println(str);
}
示例8: main
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
public static void main(final String[] args) throws IOException {
File file = new File("build/db_template.json");
System.out.println("Generating template json to file: "
+ file.getAbsolutePath());
ConfigRenderOptions renderOptions = ConfigRenderOptions.defaults()
.setJson(true).setComments(false).setOriginComments(false);
String json = CONFIG.getValue("template").render(renderOptions);
FileWriter fileWriter = new FileWriter(file);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
bufferedWriter.write(json);
bufferedWriter.close();
}
示例9: mainInternal
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
/**
* @param args Arguments from the main method.
* @throws ValidationException if an invalid actor is being created
*/
@VisibleForTesting
static void mainInternal(final String... args) throws ValidationException {
if (args.length != 4) {
log.error("Usage:");
log.error("ActorBootstrap <actorName> <className> " + //
"<tmpClusterConfigFile> <tmpActorConfigFile>");
throw new IllegalArgumentException();
}
ActorKey actorKey = new ActorKey(args[0]);
String className = checkClassName(args[1]);
String tmpClusterConfig = checkFilePath(args[2]);
String tmpActorConfig = checkFilePath(args[3]);
log.info("{} starting...", actorKey);
// Read and delete temporary config files
Config clusterConfig = parseClusterConfig(readAndDelete(tmpClusterConfig));
String jsonActorConfig = readAndDelete(tmpActorConfig);
log.debug("{} bootstrap with clusterConfig {}, actorConfig {}",
actorKey,
clusterConfig.root().render(ConfigRenderOptions.concise()),
jsonActorConfig);
AgentClusterClientFactory clientFactory = ClusterClients.newFactory(AgentClusterClientFactory.class,
clusterConfig,
new ActorRegistry());
ActorBootstrap actorBootstrap = new ActorBootstrap(clientFactory);
RuntimeActor actor = actorBootstrap.createActor(actorKey, className, jsonActorConfig);
installShutdownHook(actorBootstrap, actor);
log.info("{} started.", actorKey);
}
示例10: createActorProcess
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
private Process createActorProcess(final ActorConfig actorConfig, final Config clusterConfig) {
try {
File tempActorConfig = writeTmpFile(actorConfig.getActorJsonConfig());
File tempClusterConfig = writeTmpFile(clusterConfig.root().render(ConfigRenderOptions.concise()));
return forkProcess(actorConfig, tempActorConfig.getAbsolutePath(), tempClusterConfig.getAbsolutePath());
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
示例11: clusterConfigFor
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
@Override
public Config clusterConfigFor(@NotNull final ActorKey actorKey) {
return ConfigFactory.parseString("{\"" + ClusterClients.FACTORY_CLASS + "\":" + //
"\"" + JMSClusterClientFactory.class.getName() + "\"," + //
"\"" + ClusterClients.FACTORY_CONFIG + "\":" + //
"" + serverEndpoint.toConfig().root().render(ConfigRenderOptions.concise()) + "}");
}
示例12: clusterConfigFor
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
@Override
public Config clusterConfigFor(@NotNull final ActorKey actorKey) {
return ConfigFactory.parseString("{\"" + ClusterClients.FACTORY_CLASS + "\":" + //
"\"" + JgroupsClusterClientFactory.class.getName() + "\"," + //
"\"" + ClusterClients.FACTORY_CONFIG + "\":" + //
jgroupsFactoryConfig.root().render(ConfigRenderOptions.concise()) + "}");
}
示例13: create
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
@Override
public void create(final Environment environment) {
final String json =
environment.config().getValue("rktLauncher").render(ConfigRenderOptions.concise());
final RktLauncherConfig rktLauncherConfig;
try {
rktLauncherConfig = Json.deserialize(json, RktLauncherConfig.class);
} catch (IOException e) {
throw new RktLauncherServiceException("invalid configuration", e);
}
final ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("async-command-executor-thread-%d")
.build();
final ExecutorService asyncCommandExecutorService =
Executors.newFixedThreadPool(ASYNC_COMMAND_EXECUTOR_THREADS, threadFactory);
final RktCommandResource rktCommandResource =
new RktCommandResource(rktLauncherConfig, asyncCommandExecutorService);
final RktImageCommandResource rktImageCommandResource =
new RktImageCommandResource(rktLauncherConfig);
environment.routingEngine()
.registerAutoRoute(Route.sync("GET", "/ping", rc -> "pong"))
.registerRoutes(rktCommandResource.routes())
.registerRoutes(rktImageCommandResource.routes());
}
示例14: DrillConfig
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
@VisibleForTesting
public DrillConfig(Config config, boolean enableServerConfigs) {
super(config);
logger.debug("Setting up DrillConfig object.");
logger.trace("Given Config object is:\n{}",
config.root().render(ConfigRenderOptions.defaults()));
mapper = new ObjectMapper();
if (enableServerConfigs) {
SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule")
.addDeserializer(LogicalExpression.class, new LogicalExpression.De(this))
.addDeserializer(SchemaPath.class, new SchemaPath.De());
mapper.registerModule(deserModule);
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
mapper.configure(Feature.ALLOW_COMMENTS, true);
mapper.registerSubtypes(LogicalOperatorBase.getSubTypes(this));
mapper.registerSubtypes(StoragePluginConfigBase.getSubTypes(this));
mapper.registerSubtypes(FormatPluginConfigBase.getSubTypes(this));
}
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
this.startupArguments = ImmutableList.copyOf(bean.getInputArguments());
logger.debug("DrillConfig object initialized.");
}
示例15: build
import com.typesafe.config.ConfigRenderOptions; //導入依賴的package包/類
public Config build() {
// Resolve substitutions.
conf = conf.resolve();
if (log.isDebugEnabled()) {
log.debug("Logging properties. Make sure sensitive data such as passwords or secrets are not logged!");
log.debug(conf.root().render(ConfigRenderOptions.concise().setFormatted(true)));
}
return conf;
}