Skip to content

Commit

Permalink
Replaced Quarkus Config Profiles and Expansion with SmallRye Config i…
Browse files Browse the repository at this point in the history
…nterceptors.
  • Loading branch information
radcortez committed Jun 15, 2020
1 parent fd413f3 commit 2a95fc3
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 436 deletions.
2 changes: 1 addition & 1 deletion bom/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<microprofile-opentracing-api.version>1.3.3</microprofile-opentracing-api.version>
<microprofile-reactive-streams-operators.version>1.0.1</microprofile-reactive-streams-operators.version>
<microprofile-rest-client.version>1.4.1</microprofile-rest-client.version>
<smallrye-config.version>1.7.0</smallrye-config.version>
<smallrye-config.version>1.8.1</smallrye-config.version>
<smallrye-health.version>2.2.1</smallrye-health.version>
<smallrye-metrics.version>2.4.2</smallrye-metrics.version>
<smallrye-open-api.version>1.2.4</smallrye-open-api.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.quarkus.runtime.configuration.ConfigUtils;
import io.quarkus.runtime.configuration.ExpandingConfigSource;
import io.quarkus.runtime.configuration.HyphenateEnumConverter;
import io.quarkus.runtime.configuration.NameIterator;
import io.smallrye.config.Converters;
import io.smallrye.config.Expressions;
import io.smallrye.config.SmallRyeConfig;

/**
Expand Down Expand Up @@ -354,13 +354,9 @@ ReadResult run() {
matched = runTimePatternMap.match(ni);
if (matched != null) {
// it's a specified run-time default (record for later)
boolean old = ExpandingConfigSource.setExpanding(false);
try {
specifiedRunTimeDefaultValues.put(propertyName,
config.getOptionalValue(propertyName, String.class).orElse(""));
} finally {
ExpandingConfigSource.setExpanding(old);
}
specifiedRunTimeDefaultValues.put(propertyName, Expressions.withoutExpansion(
() -> config.getOptionalValue(propertyName, String.class).orElse("")));

continue;
}
// also check for the bootstrap properties since those need to be added to specifiedRunTimeDefaultValues as well
Expand All @@ -369,23 +365,13 @@ ReadResult run() {
matched = bootstrapPatternMap.match(ni);
if (matched != null) {
// it's a specified run-time default (record for later)
boolean old = ExpandingConfigSource.setExpanding(false);
try {
specifiedRunTimeDefaultValues.put(propertyName,
config.getOptionalValue(propertyName, String.class).orElse(""));
} finally {
ExpandingConfigSource.setExpanding(old);
}
specifiedRunTimeDefaultValues.put(propertyName, Expressions.withoutExpansion(
() -> config.getOptionalValue(propertyName, String.class).orElse("")));
}
} else {
// it's not managed by us; record it
boolean old = ExpandingConfigSource.setExpanding(false);
try {
specifiedRunTimeDefaultValues.put(propertyName,
config.getOptionalValue(propertyName, String.class).orElse(""));
} finally {
ExpandingConfigSource.setExpanding(old);
}
specifiedRunTimeDefaultValues.put(propertyName, Expressions.withoutExpansion(
() -> config.getOptionalValue(propertyName, String.class).orElse("")));
}
}
return new ReadResult(objectsByRootClass, specifiedRunTimeDefaultValues, buildTimeRunTimeVisibleValues,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ public static SmallRyeConfigBuilder configBuilder(final boolean runTime, final b
final ApplicationPropertiesConfigSource.InJar inJar = new ApplicationPropertiesConfigSource.InJar();
final ApplicationPropertiesConfigSource.MpConfigInJar mpConfig = new ApplicationPropertiesConfigSource.MpConfigInJar();
builder.withSources(inFileSystem, inJar, mpConfig, new DotEnvConfigSource());
final ExpandingConfigSource.Cache cache = new ExpandingConfigSource.Cache();
builder.withWrapper(ExpandingConfigSource.wrapper(cache));
builder.withWrapper(DeploymentProfileConfigSource.wrapper());
builder.withProfile(ProfileManager.getActiveProfile());
builder.addDefaultInterceptors();
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (runTime) {
builder.addDefaultSources();
Expand All @@ -92,6 +91,7 @@ public static SmallRyeConfigBuilder configBuilder(final boolean runTime, final b
}
if (addDiscovered) {
builder.addDiscoveredSources();
builder.addDiscoveredInterceptors();
builder.addDiscoveredConverters();
}
return builder;
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2a95fc3

Please sign in to comment.