Skip to content

Commit

Permalink
Use helidon-common-config where possible/applicable (#6448)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjav-desai authored Mar 28, 2023
1 parent 570893b commit 88ddd36
Show file tree
Hide file tree
Showing 93 changed files with 193 additions and 178 deletions.
14 changes: 13 additions & 1 deletion common/config/src/main/java/io/helidon/common/config/Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022 Oracle and/or its affiliates.
* Copyright (c) 2018, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -225,6 +225,18 @@ default Config get(Key key) {
*/
<T> ConfigValue<List<T>> asList(Class<T> type) throws ConfigException;

/**
* Returns a list of child {@code Config} nodes if the node is {@code Type#OBJECT}.
* Returns a list of element nodes if the node is {@code Type#LIST}.
* Throws {@code MissingValueException} if the node is {@code Type#MISSING}.
* Otherwise, if node is {@code Type#VALUE}, it throws {@code ConfigMappingException}.
*
* @return a list of {@code Type#OBJECT} members or a list of {@code Type#LIST} members
* @param <C> the common config derived type
* @throws io.helidon.common.config.ConfigException in case the node is {@code Type#VALUE}
*/
<C extends Config> ConfigValue<List<C>> asNodeList() throws ConfigException;

/**
* Transform all leaf nodes (values) into Map instance.
*
Expand Down
11 changes: 2 additions & 9 deletions config/config/src/main/java/io/helidon/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -827,15 +827,8 @@ default ConfigValue<Config> asNode() {
Config::asNode);
}

/**
* Returns a list of child {@code Config} nodes if the node is {@link Type#OBJECT}.
* Returns a list of element nodes if the node is {@link Type#LIST}.
* Throws {@link MissingValueException} if the node is {@link Type#MISSING}.
* Otherwise, if node is {@link Type#VALUE}, it throws {@link ConfigMappingException}.
*
* @return a list of {@link Type#OBJECT} members or a list of {@link Type#LIST} members
* @throws ConfigMappingException in case the node is {@link Type#VALUE}
*/
@Override
@SuppressWarnings("unchecked")
ConfigValue<List<Config>> asNodeList() throws ConfigMappingException;

/**
Expand Down
4 changes: 2 additions & 2 deletions cors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

<dependencies>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config</artifactId>
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common-config</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.common</groupId>
Expand Down
10 changes: 5 additions & 5 deletions cors/src/main/java/io/helidon/cors/Aggregator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,11 +22,11 @@
import java.util.function.Supplier;
import java.util.logging.Logger;

import io.helidon.common.config.Config;
import io.helidon.common.config.ConfigValue;
import io.helidon.common.http.PathMatcher;
import io.helidon.common.http.PathMatchers;
import io.helidon.common.uri.UriPath;
import io.helidon.config.Config;
import io.helidon.config.ConfigValue;
import io.helidon.cors.LogHelper.MatcherChecks;

/**
Expand Down Expand Up @@ -118,7 +118,7 @@ public Aggregator build() {

Builder config(Config config) {
if (config.exists()) {
ConfigValue<CrossOriginConfig.Builder> configValue = config.as(CrossOriginConfig::builder);
ConfigValue<CrossOriginConfig.Builder> configValue = config.map(CrossOriginConfig::builder);
if (configValue.isPresent()) {
CrossOriginConfig crossOriginConfig = configValue.get().build();
addPathlessCrossOrigin(crossOriginConfig);
Expand All @@ -136,7 +136,7 @@ Builder config(Config config) {
Builder mappedConfig(Config config) {

if (config.exists()) {
ConfigValue<MappedCrossOriginConfig.Builder> mappedConfigValue = config.as(MappedCrossOriginConfig::builder);
ConfigValue<MappedCrossOriginConfig.Builder> mappedConfigValue = config.map(MappedCrossOriginConfig::builder);
if (mappedConfigValue.isPresent()) {
MappedCrossOriginConfig mapped = mappedConfigValue.get().build();
/*
Expand Down
4 changes: 2 additions & 2 deletions cors/src/main/java/io/helidon/cors/CorsSupportBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import io.helidon.config.Config;
import io.helidon.common.config.Config;

/**
* A Helidon service and handler implementation that implements CORS, for both the application and for built-in Helidon
Expand Down
4 changes: 2 additions & 2 deletions cors/src/main/java/io/helidon/cors/CorsSupportHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,9 +28,9 @@
import java.util.function.Supplier;
import java.util.logging.Logger;

import io.helidon.common.config.Config;
import io.helidon.common.http.Http;
import io.helidon.common.http.Http.Header;
import io.helidon.config.Config;
import io.helidon.cors.LogHelper.Headers;

import static io.helidon.cors.LogHelper.DECISION_LEVEL;
Expand Down
4 changes: 2 additions & 2 deletions cors/src/main/java/io/helidon/cors/CrossOriginConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@

import java.util.Arrays;

import io.helidon.config.Config;
import io.helidon.common.config.Config;
import io.helidon.config.metadata.Configured;
import io.helidon.config.metadata.ConfiguredOption;

Expand Down
8 changes: 4 additions & 4 deletions cors/src/main/java/io/helidon/cors/Loader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,8 @@
*/
package io.helidon.cors;

import io.helidon.config.Config;
import io.helidon.config.ConfigValue;
import io.helidon.common.config.Config;
import io.helidon.common.config.ConfigValue;

import static io.helidon.cors.Aggregator.PATHLESS_KEY;
import static io.helidon.cors.CrossOriginConfig.CORS_PATHS_CONFIG_KEY;
Expand Down Expand Up @@ -78,7 +78,7 @@ static MappedCrossOriginConfig.Builder applyConfig(MappedCrossOriginConfig.Build
if (!item.exists()) {
break;
}
ConfigValue<CrossOriginConfig.Builder> basicConfigValue = item.as(CrossOriginConfig::builder);
ConfigValue<CrossOriginConfig.Builder> basicConfigValue = item.map(CrossOriginConfig::builder);
if (!basicConfigValue.isPresent()) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@
import java.util.Optional;
import java.util.function.BiConsumer;

import io.helidon.config.Config;
import io.helidon.common.config.Config;

/**
* Cross-origin {@link CrossOriginConfig} instances linked to paths, plus an {@code enabled} setting. Most developers will not
Expand Down
4 changes: 2 additions & 2 deletions cors/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
module io.helidon.cors {
requires java.logging;
requires io.helidon.common.http;
requires io.helidon.config;
requires io.helidon.common.config;

requires static io.helidon.config.metadata;

Expand Down
8 changes: 6 additions & 2 deletions graphql/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@
<artifactId>graphql-java</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config</artifactId>
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common-config</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,7 @@
import java.util.Map;
import java.util.Set;

import io.helidon.config.Config;
import io.helidon.common.config.Config;

import graphql.GraphQL;
import graphql.execution.SubscriptionExecutionStrategy;
Expand Down
3 changes: 2 additions & 1 deletion graphql/server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
module io.helidon.graphql.server {

requires transitive com.graphqljava;
requires io.helidon.config;
requires io.helidon.common;
requires io.helidon.common.config;

exports io.helidon.graphql.server;
}
8 changes: 0 additions & 8 deletions grpc/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@
<groupId>io.helidon.grpc</groupId>
<artifactId>helidon-grpc-core</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-object-mapping</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.tracing</groupId>
<artifactId>helidon-tracing</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions grpc/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
<artifactId>helidon-reactive-health</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config</artifactId>
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common-config</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.tracing</groupId>
Expand Down
2 changes: 1 addition & 1 deletion grpc/server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
requires io.helidon.common;
requires io.helidon.common.context;
requires io.helidon.common.pki;
requires io.helidon.config;
requires io.helidon.common.config;
requires transitive io.helidon.grpc.core;
requires transitive io.helidon.reactive.health;
requires io.helidon.tracing;
Expand Down
4 changes: 2 additions & 2 deletions health/health-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<artifactId>helidon-health</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config</artifactId>
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common-config</artifactId>
</dependency>
<dependency>
<!-- only needed for compilation, not required in runtime -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@
import java.util.List;

import io.helidon.common.NativeImageHelper;
import io.helidon.config.Config;
import io.helidon.common.config.Config;
import io.helidon.health.HealthCheck;
import io.helidon.health.spi.HealthCheckProvider;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022 Oracle and/or its affiliates.
* Copyright (c) 2018, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,7 +24,7 @@
import java.util.Formatter;
import java.util.Locale;

import io.helidon.config.Config;
import io.helidon.common.config.Config;
import io.helidon.health.HealthCheck;
import io.helidon.health.HealthCheckException;
import io.helidon.health.HealthCheckResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022 Oracle and/or its affiliates.
* Copyright (c) 2018, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
import java.util.List;

import io.helidon.common.NativeImageHelper;
import io.helidon.config.Config;
import io.helidon.common.config.Config;
import io.helidon.health.HealthCheck;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022 Oracle and/or its affiliates.
* Copyright (c) 2018, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@
import java.util.Formatter;
import java.util.Locale;

import io.helidon.config.Config;
import io.helidon.common.config.Config;
import io.helidon.health.HealthCheck;
import io.helidon.health.HealthCheckResponse;
import io.helidon.health.HealthCheckType;
Expand Down
2 changes: 1 addition & 1 deletion health/health-checks/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
requires static jakarta.inject;

requires io.helidon.common;
requires io.helidon.config;
requires io.helidon.common.config;
requires transitive io.helidon.health;

exports io.helidon.health.checks;
Expand Down
6 changes: 3 additions & 3 deletions health/health/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@

<dependencies>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config</artifactId>
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common</artifactId>
<artifactId>helidon-common-config</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@

import java.util.List;

import io.helidon.config.Config;
import io.helidon.common.config.Config;
import io.helidon.health.HealthCheck;

/**
Expand Down
Loading

0 comments on commit 88ddd36

Please sign in to comment.