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

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

本文整理了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

  1. private SocketConfiguration.Builder configureSocket(Config config, SocketConfiguration.Builder soConfigBuilder) {
  2. config.get("port").asInt().ifPresent(soConfigBuilder::port);
  3. config.get("bind-address")
  4. .asString()
  5. .map(this::string2InetAddress)
  6. .ifPresent(soConfigBuilder::bindAddress);
  7. config.get("backlog").asInt().ifPresent(soConfigBuilder::backlog);
  8. config.get("timeout").asInt().ifPresent(soConfigBuilder::timeoutMillis);
  9. config.get("receive-buffer").asInt().ifPresent(soConfigBuilder::receiveBufferSize);
  10. // ssl
  11. Config sslConfig = config.get("ssl");
  12. if (sslConfig.exists()) {
  13. try {
  14. soConfigBuilder.ssl(SSLContextBuilder.create(sslConfig));
  15. } catch (IllegalStateException e) {
  16. throw new ConfigException("Cannot load SSL configuration.", e);
  17. }
  18. }
  19. return soConfigBuilder;
  20. }

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

  1. /**
  2. * Load all properties for this thread pool executor from configuration.
  3. * Expected keys:
  4. * <ul>
  5. * <li>core-pool-size</li>
  6. * <li>max-pool-size</li>
  7. * <li>keep-alive-minutes</li>
  8. * <li>queue-capacity</li>
  9. * <li>is-daemon</li>
  10. * <li>thread-name-prefix</li>
  11. * <li>should-prestart</li>
  12. * </ul>
  13. *
  14. * @param config config located on the key of executor-service
  15. * @return updated builder instance
  16. */
  17. public Builder config(Config config) {
  18. config.get("core-pool-size").asInt().ifPresent(this::corePoolSize);
  19. config.get("max-pool-size").asInt().ifPresent(this::maxPoolSize);
  20. config.get("keep-alive-minutes").asInt().ifPresent(this::keepAliveMinutes);
  21. config.get("queue-capacity").asInt().ifPresent(this::queueCapacity);
  22. config.get("is-daemon").asBoolean().ifPresent(this::daemon);
  23. config.get("thread-name-prefix").asString().ifPresent(this::threadNamePrefix);
  24. config.get("should-prestart").asBoolean().ifPresent(this::prestart);
  25. return this;
  26. }
  27. }

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

  1. static Optional<Resource> fromConfigUrl(Config config, String keyPrefix) {
  2. return config.get(keyPrefix + "-url")
  3. .as(URI.class)
  4. .map(uri -> config.get("proxy-host").asString()
  5. .map(proxyHost -> {
  6. if (config.get(keyPrefix + "-use-proxy").asBoolean().orElse(true)) {
  7. Proxy proxy = new Proxy(Proxy.Type.HTTP,
  8. new InetSocketAddress(proxyHost,
  9. config.get("proxy-port").asInt().orElse(
  10. DEFAULT_PROXY_PORT)));
  11. return Resource.create(uri, proxy);
  12. } else {
  13. return Resource.create(uri);
  14. }
  15. })
  16. .orElseGet(() -> Resource.create(uri)));
  17. }

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

  1. /**
  2. * Creates new instance of builder from config.
  3. *
  4. * @param metaConfig config
  5. * @return new builder instance
  6. */
  7. public static MyConfigSourceBuilder2 from(Config metaConfig) {
  8. return from(metaConfig.get("myProp1").asString().get(),
  9. metaConfig.get("myProp2").asInt().get())
  10. .init(metaConfig);
  11. }

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

  1. /**
  2. * Creates new instance of builder from config.
  3. *
  4. * @param metaConfig config
  5. * @return new builder instance
  6. */
  7. public static MyConfigSourceBuilder1 from(Config metaConfig) {
  8. return from(metaConfig.get("myProp1").asString().get(),
  9. metaConfig.get("myProp2").asInt().get())
  10. .init(metaConfig);
  11. }

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

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

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

  1. /**
  2. * Load all properties for this thread pool executor from configuration.
  3. * Expected keys:
  4. * <ul>
  5. * <li>core-pool-size</li>
  6. * <li>is-daemon</li>
  7. * <li>thread-name-prefix</li>
  8. * <li>should-prestart</li>
  9. * </ul>
  10. *
  11. * @param config config located on the key of executor-service
  12. * @return updated builder instance
  13. */
  14. public Builder config(Config config) {
  15. config.get("core-pool-size").asInt().ifPresent(this::corePoolSize);
  16. config.get("is-daemon").asBoolean().ifPresent(this::daemon);
  17. config.get("thread-name-prefix").asString().ifPresent(this::threadNamePrefix);
  18. config.get("should-prestart").asBoolean().ifPresent(this::prestart);
  19. return this;
  20. }
  21. }

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

  1. /**
  2. * Update builder from configuration. See
  3. * {@link JwtProvider.JwtOutboundTarget#create(Config, TokenHandler)}
  4. * for configuration options description.
  5. *
  6. * @param config to update builder from
  7. * @return updated builder instance
  8. */
  9. public Builder config(Config config) {
  10. config.get("outbound-token")
  11. .asNode()
  12. .map(TokenHandler::create)
  13. .ifPresent(this::tokenHandler);
  14. config.get("jwt-kid").asString().ifPresent(this::jwtKid);
  15. config.get("jwk-kid").asString().ifPresent(this::jwkKid);
  16. config.get("jwt-audience").asString().ifPresent(this::jwtAudience);
  17. config.get("jwt-not-before-seconds").asInt().ifPresent(this::notBeforeSeconds);
  18. config.get("jwt-validity-seconds").asLong().ifPresent(this::validitySeconds);
  19. return this;
  20. }

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

  1. @Override
  2. public ZipkinTracerBuilder config(Config config) {
  3. config.get("service").asString().ifPresent(this::serviceName);
  4. config.get("protocol").asString().ifPresent(this::collectorProtocol);
  5. config.get("host").asString().ifPresent(this::collectorHost);
  6. config.get("port").asInt().ifPresent(this::collectorPort);
  7. config.get("path").asString().ifPresent(this::collectorPath);
  8. config.get("api-version").asString().ifPresent(this::configApiVersion);
  9. config.get("enabled").asBoolean().ifPresent(this::enabled);
  10. config.get("tags").detach()
  11. .asMap()
  12. .orElseGet(CollectionsHelper::mapOf)
  13. .forEach(this::addTracerTag);
  14. config.get("boolean-tags")
  15. .asNodeList()
  16. .ifPresent(nodes -> {
  17. nodes.forEach(node -> {
  18. this.addTracerTag(node.key().name(), node.asBoolean().get());
  19. });
  20. });
  21. config.get("int-tags")
  22. .asNodeList()
  23. .ifPresent(nodes -> {
  24. nodes.forEach(node -> {
  25. this.addTracerTag(node.key().name(), node.asInt().get());
  26. });
  27. });
  28. return this;
  29. }

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

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

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

  1. /**
  2. * Load an instance from configuration.
  3. * Expected keys:
  4. * <ul>
  5. * <li>jwt-kid - the key id to put into JWT</li>
  6. * <li>jwk-kid - the key id to look for when signing the JWT</li>
  7. * <li>jwt-audience - the audience of this JWT</li>
  8. * <li>jwt-not-before-seconds - not before seconds</li>
  9. * <li>jwt-validity-seconds - validity of JWT</li>
  10. * </ul>
  11. *
  12. * @param config configuration to load data from
  13. * @param defaultHandler default outbound token handler
  14. * @return a new instance configured from config
  15. * @see #JwtOutboundTarget(TokenHandler, String, String, String, int, long)
  16. */
  17. public static JwtOutboundTarget fromConfig(Config config, TokenHandler defaultHandler) {
  18. TokenHandler tokenHandler = config.get("outbound-token")
  19. .asNode()
  20. .map(TokenHandler::create)
  21. .orElse(defaultHandler);
  22. return new JwtOutboundTarget(
  23. tokenHandler,
  24. config.get("jwt-kid").asString().orElse(null),
  25. config.get("jwk-kid").asString().orElse(null),
  26. config.get("jwt-audience").asString().orElse(null),
  27. config.get("jwt-not-before-seconds").asInt().orElse(5),
  28. config.get("jwt-validity-seconds").asLong().orElse(60L * 60 * 24));
  29. }

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

  1. /**
  2. * Update this builder from configuration.
  3. *
  4. * @param config Configuration at provider (security.provider.x) key
  5. * @return updated builder instance
  6. */
  7. public Builder config(Config config) {
  8. config.get("optional").asBoolean().ifPresent(this::optional);
  9. config.get("client-id").asString().ifPresent(this::clientId);
  10. config.get("proxy-host").asString().ifPresent(this::proxyHost);
  11. config.get("proxy-port").asInt().ifPresent(this::proxyPort);
  12. config.get("realm").asString().ifPresent(this::realm);
  13. config.get("token").as(TokenHandler::create).ifPresent(this::tokenProvider);
  14. return this;
  15. }
  16. }

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

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

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

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

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

  1. /**
  2. * Update builder from configuration. See
  3. * {@link JwtProvider.JwtOutboundTarget#create(Config, TokenHandler)}
  4. * for configuration options description.
  5. *
  6. * @param config to update builder from
  7. * @return updated builder instance
  8. */
  9. public Builder config(Config config) {
  10. config.get("outbound-token")
  11. .asNode()
  12. .map(TokenHandler::create)
  13. .ifPresent(this::tokenHandler);
  14. config.get("jwt-kid").asString().ifPresent(this::jwtKid);
  15. config.get("jwk-kid").asString().ifPresent(this::jwkKid);
  16. config.get("jwt-audience").asString().ifPresent(this::jwtAudience);
  17. config.get("jwt-not-before-seconds").asInt().ifPresent(this::notBeforeSeconds);
  18. config.get("jwt-validity-seconds").asLong().ifPresent(this::validitySeconds);
  19. return this;
  20. }

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

  1. /**
  2. * Load an instance from configuration.
  3. * Expected keys:
  4. * <ul>
  5. * <li>jwt-kid - the key id to put into JWT</li>
  6. * <li>jwk-kid - the key id to look for when signing the JWT</li>
  7. * <li>jwt-audience - the audience of this JWT</li>
  8. * <li>jwt-not-before-seconds - not before seconds</li>
  9. * <li>jwt-validity-seconds - validity of JWT</li>
  10. * </ul>
  11. *
  12. * @param config configuration to load data from
  13. * @param defaultHandler default outbound token handler
  14. * @return a new instance configured from config
  15. * @see #JwtOutboundTarget(TokenHandler, String, String, String, int, long)
  16. */
  17. public static JwtOutboundTarget fromConfig(Config config, TokenHandler defaultHandler) {
  18. TokenHandler tokenHandler = config.get("outbound-token")
  19. .asNode()
  20. .map(TokenHandler::create)
  21. .orElse(defaultHandler);
  22. return new JwtOutboundTarget(
  23. tokenHandler,
  24. config.get("jwt-kid").asString().orElse(null),
  25. config.get("jwk-kid").asString().orElse(null),
  26. config.get("jwt-audience").asString().orElse(null),
  27. config.get("jwt-not-before-seconds").asInt().orElse(5),
  28. config.get("jwt-validity-seconds").asLong().orElse(60L * 60 * 24));
  29. }

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

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

相关文章