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.
Use relocation for changing config properties
Follows up on quarkusio#37445
- Loading branch information
Showing
4 changed files
with
71 additions
and
23 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
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
60 changes: 60 additions & 0 deletions
60
...e/src/main/java/io/quarkus/runtime/configuration/CoreRelocateConfigSourceInterceptor.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,60 @@ | ||
package io.quarkus.runtime.configuration; | ||
|
||
import java.io.Serial; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import io.smallrye.config.ConfigSourceInterceptorContext; | ||
import io.smallrye.config.ConfigValue; | ||
import io.smallrye.config.RelocateConfigSourceInterceptor; | ||
|
||
/** | ||
* Central location for all relocated core configuration entries. | ||
*/ | ||
public final class CoreRelocateConfigSourceInterceptor extends RelocateConfigSourceInterceptor { | ||
@Serial | ||
private static final long serialVersionUID = -3096467506527701713L; | ||
|
||
private static final Map<String, String> MAPPINGS = Map.of( | ||
// relocated in #37445 | ||
"quarkus.package.decompiler.enabled", "quarkus.package.vineflower.enabled", | ||
"quarkus.package.decompiler.jar-directory", "quarkus.package.vineflower.jar-directory"); | ||
|
||
private static final Map<String, String> REV_MAPPINGS = MAPPINGS.entrySet().stream() | ||
.collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); | ||
|
||
public CoreRelocateConfigSourceInterceptor() { | ||
super(MAPPINGS); | ||
} | ||
|
||
public Iterator<String> iterateNames(final ConfigSourceInterceptorContext context) { | ||
Iterator<String> itr = super.iterateNames(context); | ||
return new Iterator<String>() { | ||
public boolean hasNext() { | ||
return itr.hasNext(); | ||
} | ||
|
||
public String next() { | ||
String next = itr.next(); | ||
return REV_MAPPINGS.getOrDefault(next, next); | ||
} | ||
}; | ||
} | ||
|
||
public Iterator<ConfigValue> iterateValues(final ConfigSourceInterceptorContext context) { | ||
Iterator<ConfigValue> itr = super.iterateValues(context); | ||
return new Iterator<ConfigValue>() { | ||
public boolean hasNext() { | ||
return itr.hasNext(); | ||
} | ||
|
||
public ConfigValue next() { | ||
ConfigValue next = itr.next(); | ||
String name = next.getName(); | ||
String mapped = REV_MAPPINGS.getOrDefault(name, name); | ||
return name.equals(mapped) ? next : next.withName(name); | ||
} | ||
}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
core/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor
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 @@ | ||
io.quarkus.runtime.configuration.CoreRelocateConfigSourceInterceptor |