forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#42106 from radcortez/rest-client-config
Move REST Client configuration to use @ConfigMapping
- Loading branch information
Showing
38 changed files
with
1,339 additions
and
1,331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...g/runtime/src/main/java/io/quarkus/restclient/config/AbstractRestClientConfigBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.quarkus.restclient.config; | ||
|
||
import java.util.List; | ||
|
||
import io.quarkus.runtime.configuration.ConfigBuilder; | ||
import io.smallrye.config.SmallRyeConfigBuilder; | ||
|
||
/** | ||
* Registers and force load REST Client configuration. | ||
* <p> | ||
* Usually, named configuration is mapped using a <code>Map</code> because the names are dynamic and unknown to | ||
* Quarkus. In the case of the REST Client, configuration names are fixed and known at build time, but not to the point | ||
* where the names can be mapped statically, so they still need to be mapped in a <code>Map</code>. | ||
* <p> | ||
* To populate a <code>Map</code>, because the names are dynamic, the Config system has to rely on the list of | ||
* property names provided by each source. This also applies to the REST Client, but since the names are known to | ||
* Quarkus, the REST Client configuration could be loaded even for sources that don't provide a list of property | ||
* names. To achieve such behaviour, we provide a dummy configuration under each REST Client name to force | ||
* the Config system to look up the remaining configuration in the same tree. | ||
* <p> | ||
* The concrete implementation is bytecode generated in | ||
* <code>io.quarkus.restclient.config.deployment.RestClientConfigUtils#generateRestClientConfigBuilder</code> | ||
*/ | ||
public abstract class AbstractRestClientConfigBuilder implements ConfigBuilder { | ||
@Override | ||
public SmallRyeConfigBuilder configBuilder(final SmallRyeConfigBuilder builder) { | ||
List<RegisteredRestClient> restClients = getRestClients(); | ||
builder.withInterceptors(new RestClientNameFallbackConfigSourceInterceptor(restClients)); | ||
for (RegisteredRestClient restClient : restClients) { | ||
builder.withDefaultValue("quarkus.rest-client.\"" + restClient.getFullName() + "\".force", "true"); | ||
builder.withDefaultValue("quarkus.rest-client." + restClient.getSimpleName() + ".force", "true"); | ||
if (restClient.getConfigKey() != null) { | ||
builder.withDefaultValue("quarkus.rest-client." + restClient.getConfigKey() + ".force", "true"); | ||
} | ||
} | ||
return builder; | ||
} | ||
|
||
public abstract List<RegisteredRestClient> getRestClients(); | ||
} |
11 changes: 0 additions & 11 deletions
11
...t-config/runtime/src/main/java/io/quarkus/restclient/config/QueryParamStyleConverter.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
...lient-config/runtime/src/main/java/io/quarkus/restclient/config/RegisteredRestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.quarkus.restclient.config; | ||
|
||
public class RegisteredRestClient { | ||
private final String fullName; | ||
private final String simpleName; | ||
private final String configKey; | ||
|
||
public RegisteredRestClient(final String fullName, final String simpleName) { | ||
this(fullName, simpleName, null); | ||
} | ||
|
||
public RegisteredRestClient(final String fullName, final String simpleName, final String configKey) { | ||
this.fullName = fullName; | ||
this.simpleName = simpleName; | ||
this.configKey = configKey; | ||
} | ||
|
||
public String getFullName() { | ||
return fullName; | ||
} | ||
|
||
public String getSimpleName() { | ||
return simpleName; | ||
} | ||
|
||
public String getConfigKey() { | ||
return configKey; | ||
} | ||
} |
50 changes: 0 additions & 50 deletions
50
...ient-config/runtime/src/main/java/io/quarkus/restclient/config/RestClientBuildConfig.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.