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

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

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

Config.asInt介绍

[英]Integer typed value.
[中]整型值。

代码示例

代码示例来源:origin: oracle/helidon

private SocketConfiguration.Builder configureSocket(Config config, SocketConfiguration.Builder soConfigBuilder) {
  config.get("port").asInt().ifPresent(soConfigBuilder::port);
  config.get("bind-address")
      .asString()
      .map(this::string2InetAddress)
      .ifPresent(soConfigBuilder::bindAddress);
  config.get("backlog").asInt().ifPresent(soConfigBuilder::backlog);
  config.get("timeout").asInt().ifPresent(soConfigBuilder::timeoutMillis);
  config.get("receive-buffer").asInt().ifPresent(soConfigBuilder::receiveBufferSize);
  // ssl
  Config sslConfig = config.get("ssl");
  if (sslConfig.exists()) {
    try {
      soConfigBuilder.ssl(SSLContextBuilder.create(sslConfig));
    } catch (IllegalStateException e) {
      throw new ConfigException("Cannot load SSL configuration.", e);
    }
  }
  return soConfigBuilder;
}

代码示例来源:origin: oracle/helidon

/**
   * Load all properties for this thread pool executor from configuration.
   * Expected keys:
   * <ul>
   * <li>core-pool-size</li>
   * <li>max-pool-size</li>
   * <li>keep-alive-minutes</li>
   * <li>queue-capacity</li>
   * <li>is-daemon</li>
   * <li>thread-name-prefix</li>
   * <li>should-prestart</li>
   * </ul>
   *
   * @param config config located on the key of executor-service
   * @return updated builder instance
   */
  public Builder config(Config config) {
    config.get("core-pool-size").asInt().ifPresent(this::corePoolSize);
    config.get("max-pool-size").asInt().ifPresent(this::maxPoolSize);
    config.get("keep-alive-minutes").asInt().ifPresent(this::keepAliveMinutes);
    config.get("queue-capacity").asInt().ifPresent(this::queueCapacity);
    config.get("is-daemon").asBoolean().ifPresent(this::daemon);
    config.get("thread-name-prefix").asString().ifPresent(this::threadNamePrefix);
    config.get("should-prestart").asBoolean().ifPresent(this::prestart);
    return this;
  }
}

代码示例来源:origin: oracle/helidon

static Optional<Resource> fromConfigUrl(Config config, String keyPrefix) {
  return config.get(keyPrefix + "-url")
      .as(URI.class)
      .map(uri -> config.get("proxy-host").asString()
          .map(proxyHost -> {
            if (config.get(keyPrefix + "-use-proxy").asBoolean().orElse(true)) {
              Proxy proxy = new Proxy(Proxy.Type.HTTP,
                          new InetSocketAddress(proxyHost,
                                     config.get("proxy-port").asInt().orElse(
                                         DEFAULT_PROXY_PORT)));
              return Resource.create(uri, proxy);
            } else {
              return Resource.create(uri);
            }
          })
          .orElseGet(() -> Resource.create(uri)));
}

代码示例来源:origin: oracle/helidon

/**
 * Creates new instance of builder from config.
 *
 * @param metaConfig config
 * @return new builder instance
 */
public static MyConfigSourceBuilder2 from(Config metaConfig) {
  return from(metaConfig.get("myProp1").asString().get(),
        metaConfig.get("myProp2").asInt().get())
      .init(metaConfig);
}

代码示例来源:origin: oracle/helidon

/**
 * Creates new instance of builder from config.
 *
 * @param metaConfig config
 * @return new builder instance
 */
public static MyConfigSourceBuilder1 from(Config metaConfig) {
  return from(metaConfig.get("myProp1").asString().get(),
        metaConfig.get("myProp2").asInt().get())
      .init(metaConfig);
}

代码示例来源:origin: oracle/helidon

/**
 * Creates {@link SSLContext} from the provided configuration.
 *
 * @param sslConfig the ssl configuration
 * @return a built {@link SSLContext}
 * @throws IllegalStateException in case of a problem; will wrap either an instance of {@link IOException} or
 *                               a {@link GeneralSecurityException}
 */
public static SSLContext create(Config sslConfig) {
  return new SSLContextBuilder().privateKeyConfig(KeyConfig.create(sslConfig.get("private-key")))
                 .sessionCacheSize(sslConfig.get("session-cache-size").asInt().orElse(0))
                 .sessionTimeout(sslConfig.get("session-timeout").asInt().orElse(0))
                 .trustConfig(KeyConfig.create(sslConfig.get("trust")))
                 .build();
}

代码示例来源:origin: oracle/helidon

/**
   * Load all properties for this thread pool executor from configuration.
   * Expected keys:
   * <ul>
   * <li>core-pool-size</li>
   * <li>is-daemon</li>
   * <li>thread-name-prefix</li>
   * <li>should-prestart</li>
   * </ul>
   *
   * @param config config located on the key of executor-service
   * @return updated builder instance
   */
  public Builder config(Config config) {
    config.get("core-pool-size").asInt().ifPresent(this::corePoolSize);
    config.get("is-daemon").asBoolean().ifPresent(this::daemon);
    config.get("thread-name-prefix").asString().ifPresent(this::threadNamePrefix);
    config.get("should-prestart").asBoolean().ifPresent(this::prestart);
    return this;
  }
}

代码示例来源:origin: oracle/helidon

/**
 * Update builder from configuration. See
 * {@link JwtProvider.JwtOutboundTarget#create(Config, TokenHandler)}
 * for configuration options description.
 *
 * @param config to update builder from
 * @return updated builder instance
 */
public Builder config(Config config) {
  config.get("outbound-token")
      .asNode()
      .map(TokenHandler::create)
      .ifPresent(this::tokenHandler);
  config.get("jwt-kid").asString().ifPresent(this::jwtKid);
  config.get("jwk-kid").asString().ifPresent(this::jwkKid);
  config.get("jwt-audience").asString().ifPresent(this::jwtAudience);
  config.get("jwt-not-before-seconds").asInt().ifPresent(this::notBeforeSeconds);
  config.get("jwt-validity-seconds").asLong().ifPresent(this::validitySeconds);
  return this;
}

代码示例来源:origin: oracle/helidon

@Override
public ZipkinTracerBuilder config(Config config) {
  config.get("service").asString().ifPresent(this::serviceName);
  config.get("protocol").asString().ifPresent(this::collectorProtocol);
  config.get("host").asString().ifPresent(this::collectorHost);
  config.get("port").asInt().ifPresent(this::collectorPort);
  config.get("path").asString().ifPresent(this::collectorPath);
  config.get("api-version").asString().ifPresent(this::configApiVersion);
  config.get("enabled").asBoolean().ifPresent(this::enabled);
  config.get("tags").detach()
      .asMap()
      .orElseGet(CollectionsHelper::mapOf)
      .forEach(this::addTracerTag);
  config.get("boolean-tags")
      .asNodeList()
      .ifPresent(nodes -> {
        nodes.forEach(node -> {
          this.addTracerTag(node.key().name(), node.asBoolean().get());
        });
      });
  config.get("int-tags")
      .asNodeList()
      .ifPresent(nodes -> {
        nodes.forEach(node -> {
          this.addTracerTag(node.key().name(), node.asInt().get());
        });
      });
  return this;
}

代码示例来源:origin: oracle/helidon

config.get("workers").asInt().ifPresent(this::workersCount);
    Http2Configuration.Builder http2Builder = new Http2Configuration.Builder();
    http2Config.get("enable").asBoolean().ifPresent(http2Builder::enable);
    http2Config.get("max-content-length").asInt().ifPresent(http2Builder::maxContentLength);
    experimentalBuilder.http2(http2Builder.build());

代码示例来源:origin: oracle/helidon

/**
 * Load an instance from configuration.
 * Expected keys:
 * <ul>
 * <li>jwt-kid - the key id to put into JWT</li>
 * <li>jwk-kid - the key id to look for when signing the JWT</li>
 * <li>jwt-audience - the audience of this JWT</li>
 * <li>jwt-not-before-seconds - not before seconds</li>
 * <li>jwt-validity-seconds - validity of JWT</li>
 * </ul>
 *
 * @param config         configuration to load data from
 * @param defaultHandler default outbound token handler
 * @return a new instance configured from config
 * @see #JwtOutboundTarget(TokenHandler, String, String, String, int, long)
 */
public static JwtOutboundTarget fromConfig(Config config, TokenHandler defaultHandler) {
  TokenHandler tokenHandler = config.get("outbound-token")
      .asNode()
      .map(TokenHandler::create)
      .orElse(defaultHandler);
  return new JwtOutboundTarget(
      tokenHandler,
      config.get("jwt-kid").asString().orElse(null),
      config.get("jwk-kid").asString().orElse(null),
      config.get("jwt-audience").asString().orElse(null),
      config.get("jwt-not-before-seconds").asInt().orElse(5),
      config.get("jwt-validity-seconds").asLong().orElse(60L * 60 * 24));
}

代码示例来源:origin: oracle/helidon

/**
   * Update this builder from configuration.
   *
   * @param config Configuration at provider (security.provider.x) key
   * @return updated builder instance
   */
  public Builder config(Config config) {
    config.get("optional").asBoolean().ifPresent(this::optional);
    config.get("client-id").asString().ifPresent(this::clientId);
    config.get("proxy-host").asString().ifPresent(this::proxyHost);
    config.get("proxy-port").asInt().ifPresent(this::proxyPort);
    config.get("realm").asString().ifPresent(this::realm);
    config.get("token").as(TokenHandler::create).ifPresent(this::tokenProvider);
    return this;
  }
}

代码示例来源:origin: oracle/helidon

Builder builder = new Builder(metaConfig.get(RETRIES_KEY).asInt().get());

代码示例来源:origin: oracle/helidon

.ifPresent(this::proxyProtocol);
config.get("proxy-host").asString().ifPresent(this::proxyHost);
config.get("proxy-port").asInt().ifPresent(this::proxyPort);

代码示例来源:origin: io.helidon.security.providers/helidon-security-providers-jwt

/**
 * Update builder from configuration. See
 * {@link JwtProvider.JwtOutboundTarget#create(Config, TokenHandler)}
 * for configuration options description.
 *
 * @param config to update builder from
 * @return updated builder instance
 */
public Builder config(Config config) {
  config.get("outbound-token")
      .asNode()
      .map(TokenHandler::create)
      .ifPresent(this::tokenHandler);
  config.get("jwt-kid").asString().ifPresent(this::jwtKid);
  config.get("jwk-kid").asString().ifPresent(this::jwkKid);
  config.get("jwt-audience").asString().ifPresent(this::jwtAudience);
  config.get("jwt-not-before-seconds").asInt().ifPresent(this::notBeforeSeconds);
  config.get("jwt-validity-seconds").asLong().ifPresent(this::validitySeconds);
  return this;
}

代码示例来源:origin: io.helidon.microprofile.jwt/helidon-microprofile-jwt-auth

/**
 * Load an instance from configuration.
 * Expected keys:
 * <ul>
 * <li>jwt-kid - the key id to put into JWT</li>
 * <li>jwk-kid - the key id to look for when signing the JWT</li>
 * <li>jwt-audience - the audience of this JWT</li>
 * <li>jwt-not-before-seconds - not before seconds</li>
 * <li>jwt-validity-seconds - validity of JWT</li>
 * </ul>
 *
 * @param config         configuration to load data from
 * @param defaultHandler default outbound token handler
 * @return a new instance configured from config
 * @see #JwtOutboundTarget(TokenHandler, String, String, String, int, long)
 */
public static JwtOutboundTarget fromConfig(Config config, TokenHandler defaultHandler) {
  TokenHandler tokenHandler = config.get("outbound-token")
      .asNode()
      .map(TokenHandler::create)
      .orElse(defaultHandler);
  return new JwtOutboundTarget(
      tokenHandler,
      config.get("jwt-kid").asString().orElse(null),
      config.get("jwk-kid").asString().orElse(null),
      config.get("jwt-audience").asString().orElse(null),
      config.get("jwt-not-before-seconds").asInt().orElse(5),
      config.get("jwt-validity-seconds").asLong().orElse(60L * 60 * 24));
}

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

Builder builder = new Builder(metaConfig.get(RETRIES_KEY).asInt().get());

相关文章