io.helidon.config.Config.value()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中io.helidon.config.Config.value()方法的一些代码示例,展示了Config.value()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.value()方法的具体详情如下:
包路径:io.helidon.config.Config
类名称:Config
方法名:value

Config.value介绍

暂无

代码示例

代码示例来源:origin: io.helidon.webserver/helidon-webserver-zipkin

  1. /**
  2. * Update this builder from configuration.
  3. *
  4. * @param config configuration that contains at least the key service (if using configuration only).
  5. * @return updated builder instance
  6. */
  7. public ZipkinTracerBuilder fromConfig(Config config) {
  8. config.get("service").value().ifPresent(this::serviceName);
  9. config.get("protocol").value().ifPresent(this::protocol);
  10. config.get("host").value().ifPresent(this::zipkinHost);
  11. config.get("port").asOptionalInt().ifPresent(this::port);
  12. config.get("path").value().ifPresent(this::path);
  13. config.get("api-version").value().ifPresent(this::configApiVersion);
  14. return this;
  15. }

代码示例来源:origin: io.helidon.webserver/helidon-webserver-zipkin

  1. /**
  2. * Create a new builder based on values in configuration.
  3. * This requires at least a key "service" in the provided config.
  4. *
  5. * @param config configuration to load this builder from
  6. * @return a new builder instance.
  7. * @see ZipkinTracerBuilder#fromConfig(Config)
  8. */
  9. public static ZipkinTracerBuilder from(Config config) {
  10. String serviceName = config.get("service").value()
  11. .orElseThrow(() -> new IllegalArgumentException("Configuration must at least contain the service key"));
  12. return ZipkinTracerBuilder.forService(serviceName)
  13. .fromConfig(config);
  14. }

代码示例来源:origin: io.helidon.security/helidon-security-integration-webserver

  1. private void registerRouting(Routing.Rules routing) {
  2. Config wsConfig = config.get("security.web-server");
  3. SecurityHandler defaults = SecurityHandler.from(wsConfig.get("defaults"), defaultHandler);
  4. wsConfig.get("paths").nodeList().ifPresent(configs -> {
  5. for (Config pathConfig : configs) {
  6. List<Http.RequestMethod> methods = pathConfig.get("methods").mapList(Http.RequestMethod::from, listOf());
  7. String path = pathConfig.get("path")
  8. .value()
  9. .orElseThrow(() -> new SecurityException(pathConfig
  10. .key() + " must contain path key with a path to "
  11. + "register to web server"));
  12. if (methods.isEmpty()) {
  13. routing.any(path, SecurityHandler.from(pathConfig, defaults));
  14. } else {
  15. routing.anyOf(methods, path, SecurityHandler.from(pathConfig, defaults));
  16. }
  17. }
  18. });
  19. }
  20. }

代码示例来源:origin: io.helidon.security/helidon-security-integration-webserver

  1. builder.config(config);
  2. OptionalHelper.from(config.get(KEY_AUTHENTICATOR).value()).or(() -> defaults.explicitAuthenticator).asOptional()
  3. .ifPresent(builder::authenticator);
  4. OptionalHelper.from(config.get(KEY_AUTHORIZER).value()).or(() -> defaults.explicitAuthorizer).asOptional()
  5. .ifPresent(builder::authorizer);
  6. OptionalHelper.from(config.get(KEY_AUTHENTICATE).asOptional(Boolean.class)).or(() -> defaults.authenticate).asOptional()
  7. OptionalHelper.from(config.get(KEY_AUTHORIZE).asOptional(Boolean.class)).or(() -> defaults.authorize).asOptional()
  8. .ifPresent(builder::authorize);
  9. OptionalHelper.from(config.get(KEY_AUDIT_EVENT_TYPE).value()).or(() -> defaults.auditEventType).asOptional()
  10. .ifPresent(builder::auditEventType);
  11. OptionalHelper.from(config.get(KEY_AUDIT_MESSAGE_FORMAT).value()).or(() -> defaults.auditMessageFormat).asOptional()
  12. .ifPresent(builder::auditMessageFormat);
  13. config.get(KEY_QUERY_PARAM_HANDLERS).asOptionalList(QueryParamHandler.class)
  14. config.get(KEY_AUTHENTICATOR).value().ifPresent(value -> {
  15. if (!config.get(KEY_AUTHENTICATE).exists()) {
  16. builder.authenticate(true);
  17. config.get(KEY_AUTHORIZER).value().ifPresent(value -> {
  18. if (!config.get(KEY_AUTHORIZE).exists()) {
  19. builder.authorize(true);

相关文章