Skip to content

Commit

Permalink
Register RuntimeOverrideConfigSource in STATIC_INIT
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Oct 11, 2023
1 parent 049f6f0 commit 6a97cab
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.spi.ConfigBuilder;
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.eclipse.microprofile.config.spi.Converter;
import org.objectweb.asm.Opcodes;
import org.wildfly.common.Assert;
Expand Down Expand Up @@ -191,12 +190,12 @@ public final class RunTimeConfigurationGenerator {

static final MethodDescriptor SRCB_WITH_CONVERTER = MethodDescriptor.ofMethod(SmallRyeConfigBuilder.class,
"withConverter", ConfigBuilder.class, Class.class, int.class, Converter.class);
static final MethodDescriptor SRCB_WITH_SOURCES = MethodDescriptor.ofMethod(SmallRyeConfigBuilder.class,
"withSources", ConfigBuilder.class, ConfigSource[].class);
static final MethodDescriptor SRCB_WITH_CUSTOMIZER = MethodDescriptor.ofMethod(AbstractConfigBuilder.class,
"withCustomizer", void.class, SmallRyeConfigBuilder.class, String.class);
static final MethodDescriptor SRCB_BUILD = MethodDescriptor.ofMethod(SmallRyeConfigBuilder.class, "build",
SmallRyeConfig.class);
static final MethodDescriptor ROCS_REGISTER = MethodDescriptor.ofMethod(RuntimeOverrideConfigSource.class,
"registerRuntimeOverrideConfigSource", void.class, SmallRyeConfigBuilder.class);

static final MethodDescriptor PU_FILTER_PROPERTIES_IN_ROOTS = MethodDescriptor.ofMethod(PropertiesUtil.class,
"filterPropertiesInRoots", Iterable.class, Iterable.class, Set.class);
Expand Down Expand Up @@ -307,6 +306,11 @@ public static final class GenerateOperation implements AutoCloseable {
// static config builder
clinit.invokeStaticMethod(SRCB_WITH_CUSTOMIZER, buildTimeBuilder, clinit.load(CONFIG_STATIC_NAME));

// add in our custom sources
if (launchMode.isDevOrTest()) {
clinit.invokeStaticMethod(ROCS_REGISTER, buildTimeBuilder);
}

clinitConfig = clinit.checkCast(clinit.invokeVirtualMethod(SRCB_BUILD, buildTimeBuilder), SmallRyeConfig.class);

// block for converter setup
Expand All @@ -330,6 +334,10 @@ public void run() {
final ResultHandle buildTimeBuilder = reinit.newInstance(SRCB_NEW);
// static config builder
reinit.invokeStaticMethod(SRCB_WITH_CUSTOMIZER, buildTimeBuilder, reinit.load(CONFIG_STATIC_NAME));
// add in our custom sources
if (launchMode.isDevOrTest()) {
reinit.invokeStaticMethod(ROCS_REGISTER, buildTimeBuilder);
}

ResultHandle clinitConfig = reinit.checkCast(reinit.invokeVirtualMethod(SRCB_BUILD, buildTimeBuilder),
SmallRyeConfig.class);
Expand Down Expand Up @@ -393,10 +401,7 @@ public void run() {

// add in our custom sources
if (launchMode.isDevOrTest()) {
MethodDescriptor registerRuntimeOverrideConfigSource = MethodDescriptor.ofMethod(
RuntimeOverrideConfigSource.class, "registerRuntimeOverrideConfigSource", void.class,
SmallRyeConfigBuilder.class);
readConfig.invokeStaticMethod(registerRuntimeOverrideConfigSource, runTimeBuilder);
readConfig.invokeStaticMethod(ROCS_REGISTER, runTimeBuilder);
}

final ResultHandle runTimeConfig = readConfig.invokeVirtualMethod(SRCB_BUILD, runTimeBuilder);
Expand Down

0 comments on commit 6a97cab

Please sign in to comment.